[PyQt] SIP hello world problem

piotr maliński riklaunim at gmail.com
Fri Apr 17 12:54:15 BST 2009


in the sip generated config you have:

LIBS = -lhello

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 ;)

2009/4/17 Pim Schellart <P.Schellart at student.science.ru.nl>

> 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.
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20090417/fd743b10/attachment.html


More information about the PyQt mailing list