Hi I'm using cmake to call swig to generate my a python interface to my C++ library. I crafted the following CMakeLists.txt from the FAQ:
FIND_PACKAGE(SWIG REQUIRED) INCLUDE(${SWIG_USE_FILE}) FIND_PACKAGE(PythonLibs) INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH}) SET_SOURCE_FILES_PROPERTIES(stir.i PROPERTIES CPLUSPLUS ON) SWIG_ADD_MODULE(stir python stir.i ${STIR_REGISTRIES}) SWIG_LINK_LIBRARIES(stir ${STIR_LIBRARIES} ${PYTHON_LIBRARIES}) Here the variables STIR_REGISTRIES and STIR_LIBRARIES are set elsewhere. The "registries" are .cxx files that initialise some global variables (initialising some registries). These .cxx files need to compiled and then passed explicitly to the linker. The above works just fine on Ubuntu. However, now I'm also trying to build on Windows using mingw (with shared libraries "ON"). Unfortunately, in this case the "registries" are ignored for the linking step. For example, the link.txt file that cmake generates looks like "C:\Program Files (x86)\CMake 2.8\bin\cmake.exe" -E remove -f CMakeFiles\_stir.dir/objects.a C:\MinGW32-xy\bin\ar.exe cr CMakeFiles\_stir.dir/objects.a @CMakeFiles\_stir.dir\objects1.rsp C:\MinGW32-xy\bin\g++.exe -shared -o _stir.pyd -Wl,--major-image-version,0,--minor-image-version,0 -Wl,--whole-archive CMakeFiles\_stir.dir/objects.a -Wl,--no-whole-archive ..\buildblock\libbuildblock.dll.a C:\Python27\libs\libpython27.a -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 While on ubuntu it looks like /usr/bin/c++ -fPIC -DSTIR_USE_BOOST_SPTR -g -shared -Wl,-soname,_stir.so -o _stir.so CMakeFiles/_stir.dir/stirPYTHON_wrap.cxx.o CMakeFiles/_stir.dir/__/buildblock/buildblock_registries.cxx.o ../buildblock/libbuildblock.so -Wl,-rpath,<ETC> You can see that there's no explicit mention of buildblock_registries.cxx.obj or so in the mingw version. In fact, it is listed in the objects1.rsp file, so it will be added to the library, but not passed to the linker. This doesn't work in my case (see end of email). Any suggestions? I'm using CMake 2.8.5 on Windows 7, mingw 4.5.2.2. Thanks Kris PS: the reason I need to pass these registry files to the linker is that they contain global variables (whose initialisation has some side effects). These global variables are nowhere referenced in the code, and so the linker doesn't import them from the objects.a library. -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake