[CMake] using cmake to link window lib and dll files

Cheng Zhigao ZGCHENG at ntu.edu.sg
Sun Nov 15 22:04:03 EST 2009


Thanks for your reply. I am pretty sure without giving the full path, The link_directories and target_link_library does not work under my case. And for the dll thing, is there a way i can use cmake to make it available for the application at runtime?

Regards,
zhigao
________________________________________
From: Tyler Roscoe [tyler at cryptio.net]
Sent: Monday, November 16, 2009 12:50 AM
To: Cheng Zhigao
Cc: cmake at cmake.org
Subject: Re: [CMake] using cmake to link window lib and dll files

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

CONFIDENTIALITY: This email is intended solely for the person(s) named. The contents may be confidential and/or privileged. If you are not the intended recipient, please delete it, notify us, and do not copy or use it, nor disclose its contents. Thank you.

Towards A Sustainable Earth: Print Only When Necessary


More information about the CMake mailing list