[CMake] problem porting to VC++: LINK : fatal error LNK1104: cannot open file 'Exc.lib'

Wojciech Jarosz wjarosz at ucsd.edu
Thu Sep 14 14:49:48 EDT 2006


On Thursday 14 September 2006 05:52, William A. Hoffman wrote:
> 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

Thanks for the tip. I figured it had to do with my ignorance of how dlls work 
on Windows.

Is there a way to automate this process within the CMake framework? Meaning, 
I'd like everything to be exported on Windows so that it matches the behavior 
of Unix, but without having to modify the source or maintain a separate file 
listing the exports.

Thanks!
-w


More information about the CMake mailing list