[Cmake] Building DLLs

Andy Cedilnik andy.cedilnik at kitware.com
Wed Mar 19 08:08:04 EST 2003


Hi Ian,


On Wed, 2003-03-19 at 03:42, Ian Main wrote:
> So, thanks to all your help I got roy building on unix now all spiffy
> like!
> 
> Now, I've moved onto getting it working on windows.  I've been building
> on win2k using MSVC++ 6.0.
> 
> I can build it fine with static libs, however, I added:
> 
> SET(BUILD_SHARED_LIBS "ON" CACHE BOOL "Turn on to build shared libraries.")
> 
> So that I could build shared libraries.. If I enable this on windows though
> I get problems.  My setup is actually a lot like the example Hello one.  I have
> libroy building along with some other libaries and some tests that need to link
> to it.  With shared libs on I get:
> 
> cannot open file "roy.lib"
> 
> So obviously it is still trying to link against the static version.

On Windows all libraries should have corresponding .lib file. If you do
not have it, then your export macros are wrong. Find those
__dclspwhatever(export) things.

> Another odd thing happens when I try to use the DLL for zlib.  I select it in the
> configuration and I get:
> cannot open file "E:\cvs\zlib\dll32\zlib.dll.lib"
> Now I'm probly missing something, and I know there's a lot more magic involved
> with DLLs than with .so's..

I suspect you specified zlib.dll and not zlib.lib. Read previous answer.
The deal is, on windows you link to .lib file not to .dll file.

> Any Ideas?
> 
> Oh, I gather it's not possible to build both shared and static libs?  That's
> generally what us unix folk do, though I'm not sure why I suppose :)

If you give libraries different name, then no problem:

ADD_LIBRARY(fooStatic STATIC ${foo_sources})
ADD_LIBRARY(fooShared SHARED ${foo_sources})

				Andy




More information about the CMake mailing list