views:

49

answers:

1

I have been trying to compile TinyXML using CMake as a sort of mini project, trying to learn CMake. As an addition I am trying to make it compile into a dynamic library and install itself so it works.

So far I have managed to get it to compile and install BUT it compiles into a .dll and a .dll.a and the only way to get it to work is to have it install into both /bin and /lib, which makes it install both files in both folders. This setup works bur I'm guessing .dll should be in /bin and .dll.a should be in /lib. Is this some sort of Cygwin-specific problem or am I doing something wrong?

A: 

The .dll is the runtime library file, which must be present on the target system on run time (and be in $PATH there). The .dll.a file is the import library for the .dll, which must be present on the compiling machine at link time. You need to distribute the .dll file to the places where the program should run, and both .dll and .dll.a to places where the library is used to link other programs. you don't need the .dll.a file on the machines running the program only.

When you don't want to create a shared library, you can tell this to cmake with the static keyword in the add_library command:

add_library(mylib STATIC foo.c bar.cpp)

This way there will no shared library created, but the code from the library will be added by the linker into the final executable file.

Rudi