[PyQt] SIP hello world problem
Pim Schellart
P.Schellart at student.science.ru.nl
Fri Apr 17 12:24:09 BST 2009
Dear Users/Developers,
I would like to combine some C++ code with my Python programs.
I have looked at several options:
- Boost
- Swig
and of course SIP.
SIP seems to be best suited to my goal but when building a simple
hello world program I ran into the following problem:
c++ -c -pipe -fPIC -Os -Wall -W -I. -I/Applications/scisoft/i386/
library/Frameworks/Python.framework/Versions/2.5/include/python2.5 -o
siphellocmodule.o siphellocmodule.cpp
c++ -c -pipe -fPIC -Os -Wall -W -I. -I/Applications/scisoft/i386/
library/Frameworks/Python.framework/Versions/2.5/include/python2.5 -o
siphelloHello.o siphelloHello.cpp
c++ -headerpad_max_install_names -bundle -F/Applications/scisoft//i386/
library/Frameworks -framework Python -o hello.so siphellocmodule.o
siphelloHello.o -lhello
ld: library not found for -lhello
collect2: ld returned 1 exit status
make: *** [hello.so] Error 1
Does anyone know what is going wrong here?
The program consists of a header file hello.h:
class Hello
{
public:
void print();
};
a source file hello.cpp:
#include <iostream>
#include "hello.h"
void Hello::print()
{
std::cout<<"Hello world!"<<std::endl;
}
A SIP definition file (or whatever it is called) hello.sip:
%Module hello 0
class Hello
{
%TypeHeaderCode
#include <hello.h>
%End
public:
void print();
};
And finally the configure.py file:
import os
import sipconfig
# The name of the SIP build file generated by SIP and used by the build
# system.
build_file = "hello.sbf"
# Get the SIP configuration information.
config = sipconfig.Configuration()
# Run SIP to generate the code.
os.system(" ".join([config.sip_bin, "-c", ".", "-b", build_file,
"hello.sip"]))
# Create the Makefile.
makefile = sipconfig.SIPModuleMakefile(config, build_file)
# Add the library we are wrapping. The name doesn't include any
platform
# specific prefixes or extensions (e.g. the "lib" prefix on UNIX, or the
# ".dll" extension on Windows).
makefile.extra_libs = ["hello"]
# Generate the Makefile itself.
makefile.generate()
The generated Makefile looks like:
TARGET = hello.so
OFILES = siphellocmodule.o siphelloHello.o
HFILES = sipAPIhello.h
CC = cc
CXX = c++
LINK = c++
CPPFLAGS = -I. -I/Applications/scisoft/i386/library/Frameworks/
Python.framework/Versions/2.5/include/python2.5
CFLAGS = -pipe -fPIC -Os -Wall -W
CXXFLAGS = -pipe -fPIC -Os -Wall -W
LFLAGS = -headerpad_max_install_names -bundle -F/Applications/scisoft//
i386/library/Frameworks -framework Python
LIBS = -lhello
.SUFFIXES: .c .o .cpp .cc .cxx .C
.cpp.o:
$(CXX) -c $(CXXFLAGS) $(CPPFLAGS) -o $@ $<
.cc.o:
$(CXX) -c $(CXXFLAGS) $(CPPFLAGS) -o $@ $<
.cxx.o:
$(CXX) -c $(CXXFLAGS) $(CPPFLAGS) -o $@ $<
.C.o:
$(CXX) -c $(CXXFLAGS) $(CPPFLAGS) -o $@ $<
.c.o:
$(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ $<
$(TARGET): $(OFILES)
$(LINK) $(LFLAGS) -o $(TARGET) $(OFILES) $(LIBS)
$(OFILES): $(HFILES)
install: $(TARGET)
@test -d $(DESTDIR)/Applications/scisoft/i386/library/Frameworks/
Python.framework/Versions/2.5/lib/python2.5/site-packages || mkdir -p $
(DESTDIR)/Applications/scisoft/i386/library/Frameworks/
Python.framework/Versions/2.5/lib/python2.5/site-packages
cp -f $(TARGET) $(DESTDIR)/Applications/scisoft/i386/library/
Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/$
(TARGET)
clean:
-rm -f $(TARGET)
-rm -f siphellocmodule.o
-rm -f siphelloHello.o
Any help would be much appreciated.
Kind regards,
Pim Schellart
P.S. The SIP tool looks great but I cant seem to find any good
documentation. The reference guide starts OK but then turns into a
summing up of keywords. If anyone knows some decent documentation I
would like to have the link. Otherwise setting up a wiki with this
kind of info might be a good idea.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 1590 bytes
Desc: not available
Url : http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20090417/bd64be06/smime.bin
More information about the PyQt
mailing list