in the sip generated config you have:<br><br>
LIBS = -lhello<br><br>and ld won't see this if your library won't be in paths visible to ld. SIP isn't documented like for example PyQt4 so it's a bit hard to use ;)<br><br><div class="gmail_quote">2009/4/17 Pim Schellart <span dir="ltr"><<a href="mailto:P.Schellart@student.science.ru.nl">P.Schellart@student.science.ru.nl</a>></span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Dear Users/Developers,<br>
<br>
I would like to combine some C++ code with my Python programs.<br>
I have looked at several options:<br>
- Boost<br>
- Swig<br>
and of course SIP.<br>
SIP seems to be best suited to my goal but when building a simple hello world program I ran into the following problem:<br>
<br>
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<br>
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<br>
c++ -headerpad_max_install_names -bundle -F/Applications/scisoft//i386/library/Frameworks -framework Python -o hello.so siphellocmodule.o siphelloHello.o -lhello<br>
ld: library not found for -lhello<br>
collect2: ld returned 1 exit status<br>
make: *** [hello.so] Error 1<br>
<br>
Does anyone know what is going wrong here?<br>
<br>
The program consists of a header file hello.h:<br>
class Hello<br>
{<br>
public:<br>
void print();<br>
};<br>
<br>
a source file hello.cpp:<br>
#include <iostream><br>
#include "hello.h"<br>
<br>
void Hello::print()<br>
{<br>
std::cout<<"Hello world!"<<std::endl;<br>
}<br>
<br>
A SIP definition file (or whatever it is called) hello.sip:<br>
%Module hello 0<br>
<br>
class Hello<br>
{<br>
%TypeHeaderCode<br>
#include <hello.h><br>
%End<br>
<br>
public:<br>
void print();<br>
};<br>
<br>
And finally the configure.py file:<br>
import os<br>
import sipconfig<br>
<br>
# The name of the SIP build file generated by SIP and used by the build<br>
# system.<br>
build_file = "hello.sbf"<br>
<br>
# Get the SIP configuration information.<br>
config = sipconfig.Configuration()<br>
<br>
# Run SIP to generate the code.<br>
os.system(" ".join([config.sip_bin, "-c", ".", "-b", build_file, "hello.sip"]))<br>
<br>
# Create the Makefile.<br>
makefile = sipconfig.SIPModuleMakefile(config, build_file)<br>
<br>
# Add the library we are wrapping. The name doesn't include any platform<br>
# specific prefixes or extensions (e.g. the "lib" prefix on UNIX, or the<br>
# ".dll" extension on Windows).<br>
makefile.extra_libs = ["hello"]<br>
<br>
# Generate the Makefile itself.<br>
makefile.generate()<br>
<br>
The generated Makefile looks like:<br>
TARGET = hello.so<br>
OFILES = siphellocmodule.o siphelloHello.o<br>
HFILES = sipAPIhello.h<br>
<br>
CC = cc<br>
CXX = c++<br>
LINK = c++<br>
CPPFLAGS = -I. -I/Applications/scisoft/i386/library/Frameworks/Python.framework/Versions/2.5/include/python2.5<br>
CFLAGS = -pipe -fPIC -Os -Wall -W<br>
CXXFLAGS = -pipe -fPIC -Os -Wall -W<br>
LFLAGS = -headerpad_max_install_names -bundle -F/Applications/scisoft//i386/library/Frameworks -framework Python<br>
LIBS = -lhello<br>
.SUFFIXES: .c .o .cpp .cc .cxx .C<br>
<br>
<br>
.cpp.o:<br>
$(CXX) -c $(CXXFLAGS) $(CPPFLAGS) -o $@ $<<br>
<br>
.cc.o:<br>
$(CXX) -c $(CXXFLAGS) $(CPPFLAGS) -o $@ $<<br>
<br>
.cxx.o:<br>
$(CXX) -c $(CXXFLAGS) $(CPPFLAGS) -o $@ $<<br>
<br>
.C.o:<br>
$(CXX) -c $(CXXFLAGS) $(CPPFLAGS) -o $@ $<<br>
<br>
.c.o:<br>
$(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ $<<br>
<br>
$(TARGET): $(OFILES)<br>
$(LINK) $(LFLAGS) -o $(TARGET) $(OFILES) $(LIBS)<br>
<br>
$(OFILES): $(HFILES)<br>
<br>
install: $(TARGET)<br>
@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<br>
cp -f $(TARGET) $(DESTDIR)/Applications/scisoft/i386/library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/$(TARGET)<br>
<br>
clean:<br>
-rm -f $(TARGET)<br>
-rm -f siphellocmodule.o<br>
-rm -f siphelloHello.o<br>
<br>
Any help would be much appreciated.<br>
<br>
Kind regards,<br><font color="#888888">
<br>
Pim Schellart<br>
</font><br>
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.<br>
_______________________________________________<br>
PyQt mailing list <a href="mailto:PyQt@riverbankcomputing.com">PyQt@riverbankcomputing.com</a><br>
<a href="http://www.riverbankcomputing.com/mailman/listinfo/pyqt" target="_blank">http://www.riverbankcomputing.com/mailman/listinfo/pyqt</a><br></blockquote></div><br>