[CMake] problem porting to VC++: LINK : fatal error
LNK1104: cannot open file 'Exc.lib'
William A. Hoffman
billlist at nycap.rr.com
Thu Sep 14 08:52:02 EDT 2006
At 12:07 AM 9/14/2006, Wojciech Jarosz wrote:
>Hi,
>I have been using CMake on Linux and Mac OS X for a couple months now and am
>very happy with it. Now I am having a bit of trouble getting my project to
>work on windows using VC++ Express Edition.
>
>Among other things, my project has two (shared) libraries: Exc and Thread.
>Thread depends on Exc. When I build Exc and then Thread in VC++ I get the
>following error:
>
>------ Build started: Project: Thread, Configuration: Debug Win32 ------
>Linking...
>LINK : fatal error LNK1104: cannot open file 'Exc.lib'
>
>
>I'm not quite sure why I'm getting this error or why Thread is even trying to
>link against a static .lib file instead of a shared library.
You have some things to learn about windows programming.....
When you create a shared library or dll with the ms compiler, you
have to tell it what symbols you want exported from the library.
UNIX compilers default to exporting all symbols. Windows defaults
to NONE. When you create a dll, you get two files a Exc.dll and
IF you have exports a Exc.lib.
There are two ways to get exports:
1. create a .def file and list them out, the .def file can be listed
as a source to the shared library in cmake.
2. use __declspec(dllexport/dllimport) in a macro like this:
#ifdef _WIN32
# ifdef testc2_EXPORTS
# define CM_TEST_LIB_EXPORT __declspec( dllexport )
# else
# define CM_TEST_LIB_EXPORT __declspec( dllimport )
# endif
#else
# define CM_TEST_LIB_EXPORT
#endif
There is a full example here:
http://public.kitware.com/cgi-bin/viewcvs.cgi/Tests/COnly/?root=CMake
-Bill
More information about the CMake
mailing list