[CMake] using cmake to link window lib and dll files
Tyler Roscoe
tyler at cryptio.net
Sun Nov 15 11:50:16 EST 2009
On Sun, Nov 15, 2009 at 09:37:31PM +0800, Cheng Zhigao wrote:
> The project name is TEST, i put the external library in a folder named
> ${TEST_SOURCE_DIR}/epanet/ which contains the epanet2.h epanet2.lib
> and epanet2.dll files. I use the Include_directories and
> link_directories to point to the /epanet/ folder. And i use
> TARGET_LINK_LIBRARIES to link the library. However, i still have to
> put the full path like ${TEST_SOURCE_DIR}/epanet2/epanet2.lib to link
> to the library including file extension. And I do not know how to link
link_directories() + target_link_libraries() should work. Maybe the
problem has to do with your confusion on this issue:
> to the epanet2.dll file. I have to manually copy the dll file in order
> to make the code to work otherwise it will complain cannot find the
> .dll file. How can i do that in cmake so that both the .lib file and
> .dll file will be linked without manual actions? Thanks.
You don't link against a dll. You link against the import library (.lib)
and then the DLL must be available to your application at runtime.
There's a page in the CMake wiki with more details about building
libraries on Windows.
tyler
More information about the CMake
mailing list