Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to link as .so instead of .dylib on OSX 10.6 using qmake
    text
    copied!<p>I am trying to use SWIG to wrap some C++ code for the use with Python. As described <a href="https://stackoverflow.com/questions/2488016/how-to-make-python-load-dylib-on-osx" title="here">here</a> it seems to be necessary to link my C++ code against an <code>.so</code> file, not a <code>.dylib</code> file. The thread suggests to use <code>libtool</code> in combination with the <code>-module</code> flag to link, but I am using qmake and need more precise instructions on how I do that. </p> <p>My .pro file (for qmake) looks like this:</p> <pre><code>TEMPLATE = lib TARGET = CONFIG += qt debug console plugin no_plugin_name_prefix QT += opengl DEPENDPATH += . libgm src INCLUDEPATH += . libgm src /usr/include/python2.6/ LIBS += -L/usr/lib -lpython MOC_DIR = .moc OBJECTS_DIR = .tmp DESTDIR = bin TARGET = _mylibname DEFINES += COMPILE_DL=1 HEADERS += &lt;my_headers&gt; \ src/swig_wrap.h SOURCES += &lt;my_sources&gt; src/swig_wrap.cxx </code></pre> <p>I am invoking first <code>swig</code>, then <code>qmake</code>, then <code>make</code> using Eclipse builders:</p> <pre><code>cd src/ swig -c++ -python swig.i cd .. qmake -spec macx-g++ make all </code></pre> <p>Compile and Link works fine, but leaves me with <code>bin/_mylibname.dylib</code>, and when I run my python application, the statement import <code>_mylibname</code> fails.</p> <p>Does anyone know how I can get qmake to build a <code>*.so</code> instead of a <code>*.dylib</code>, possibly using <code>libtool</code> (or any other way for all I care)? My platform:</p> <ul> <li>Mac OS X Snow Leopard (10.6)</li> <li>Python 2.6</li> <li>SWIG 1.3.31</li> <li>qmake 2.01a with Qt 4.6.2</li> <li>g++ i686-apple-darwin10-g++-4.2.1</li> </ul> <p>I am not very knowledgable with linking issues, so please be gentle :-)</p> <p>Ole</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload