tags:

views:

269

answers:

2

I've got a library definition in CMake that builds a shared library out of a small set of files, and I've got it compiling just fine on both linux and windows.

However, I've also got another library that links against the shared library and it works fine on linux, however, on windows I get a message along the lines or "error can't find Release/nnet.lib" during link-time. Is there something special I have to do to get this to link on windows?

Edit, example:

Main shared library (filenames changed to protect the innocent):

ADD_LIBRARY(nnet SHARED
  src/nnet/file_1.cc src/nnet/file_3.cc  
  src/nnet/file_2.cc src/nnet/file_4.cc)

And then I'm building a python module that links in the library:

# Build python module
ADD_LIBRARY            (other_lib SHARED ${CMAKE_SOURCE_DIR}/src/boost/boost_main.cc)
TARGET_LINK_LIBRARIES  (other_lib nnet   ${PYTHON_LIBRARIES})

The rest is just boilerplate (eg: changing module extension to .pyd on windows, finding python libraries/headers, etc) And then when building in VS 2008 I get:

fatal error LNK1181: cannot open input file 'Release\nnet.lib'

when building other_lib. Note no errors are thrown while building nnet.

A: 

No, you shouldn't have to do anything special. Can you show us a minimal CMakeLists.txt which demonstrates the problem? Are you setting any of the variables available for changing where CMake places the output files?

JesperE
Sure thing, see above!
gct
+3  A: 

Ah, my problem was I forgot to include a __declspec(dllexport) in suitable places when building the library (can you tell I don't do windows programming a lot?).

gct
On windows no .lib import library file is generated if no symbols are exported. You need at least one dllexport for the file to be created. I have beaten my head against this before.
Christopher Bruns