[CMake] UseSWIG creates module instead of shared library, which can't be dynamically loaded

Mathieu Malaterre mathieu.malaterre at gmail.com
Thu Aug 6 06:02:23 EDT 2009


On Wed, Aug 5, 2009 at 6:55 PM, Stephen Roderick<kiwi.net at mac.com> wrote:
> The existing UseSWIG.cmake file creates a MODULE and not a SHARED library.
> The module is unuseable by any program trying to load dynamic libraries (eg
> wrapped Java). The attached patch fixes this problem for our situations.
> Demonstrated on both Mac OS X Leopard and Ubuntu Jaunty.
>
> Is this a known issue? I searched what I could of the list and the 'net, and
> couldn't find anything on this.

No, you are confusing the C++ library and the Java binding. Instead:

ADD_LIBRARY(foo SHARED ${foo_SRCS}) # the actual shared lib
SWIG_ADD_MODULE(foojni java foo.i)
SWIG_LINK_LIBRARIES(foojni foo
  ${JNI_LIBRARIES}
)

The next time you will want to create -say- a python module you'll
simply link to your *shared C++* library:

SWIG_ADD_MODULE(foopython python foo.i)
SWIG_LINK_LIBRARIES(foopython foo
  ${PYTHON_LIBRARIES}
)


-- 
Mathieu
http://mathieumalaterre.com


More information about the CMake mailing list