[CMake] How to install a shared library on a windows system

Ryan Pavlik rpavlik at iastate.edu
Fri Jun 11 14:26:21 EDT 2010


On 06/11/2010 12:27 PM, Torri, Stephen CIV NSWCDD, W15 wrote:
>> From: Ryan Pavlik [mailto:rpavlik at iastate.edu]
>> Sent: Fri 6/11/2010 1:16 PM
>> To: Torri, Stephen CIV NSWCDD, W15
>> Cc: cmake at cmake.org
>> Subject: Re: [CMake] How to install a shared library on a windows system
>>
>>      
>>>> From: cmake-bounces at cmake.org on behalf of Ryan Pavlik
>>>> Sent: Fri 6/11/2010 12:34 PM
>>>> To: cmake at cmake.org
>>>> Subject: Re: [CMake] How to install a shared library on a windows system
>>>>
>>>>
>>>> Stephen,
>>>>
>>>> The catch is that windows searches for the DLL at runtime in specific
>>>> locations: http://msdn.microsoft.com/en-us/library/7d83bc18%28VS.80%29.aspx
>>>>
>>>>          
>>> I see that it searches the directories listed in the PATH variable. How can you tell CPACK to just always install itself to the PATH variable instead of asking?
>>>
>>>        
>> You generally don't want to put your install directory in the PATH
>> environment variable system-wide (or install to c:\windows\system32):
>> you'll probably either want to a: install a launcher script that appends
>> to the path at run time (see my other recent mailing list post), or b:
>> use something like my example so your dll ends up in the same directory
>> as your exe.
>>      
> The end goal of this project is to install a shared library than someone other than me can link against and use. I am used to programming on Linux where I can just install to /usr/lib, /lib, /opt/lib or some other directory like that where the OS knows to search. Now I read your last post again and concluded that I cannot put my library in the directory as the EXE since I don't know that directory another user will create. I hope understand I am coming from Linux and trying to convince Windows to play nice.
>
> So I am trying to be the nice library developer and set things up the right way. Now that you know what I am doing and the audience I am serving how do you recommend I install my library so that a third-party can link against it and find it a runtime?
>
> Would a phone call help?
>
> Stephen
>    

Welcome to the joy of programming on Windows - this is one of my most 
persistent headaches.

The burden is now on your developer: that said, if you install a 
-config.cmake file that, in addition to setting _INCLUDE_DIRS and 
_LIBRARIES, sets _RUNTIME_LIBRARIES and _RUNTIME_LIBRARY_DIRS, the 
consumer of the library can either a) generate a script that adds the 
runtime library dirs to the path, or b) copy the _RUNTIME_LIBRARIES into 
their binary directory.  They can also then install(FILES 
${whatever_RUNTIME_LIBRARIES} DESTINATION bin) so that their installers 
get a copy of the DLL.

I threw together a quick sample of what you might want to have in your 
library's project, based on a recent library I made - it's attached.  
Hopefully this helps.

Ryan

-- 
Ryan Pavlik
HCI Graduate Student
Virtual Reality Applications Center
Iowa State University

rpavlik at iastate.edu
http://academic.cleardefinition.com

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: CMakeLists.txt
URL: <http://www.cmake.org/pipermail/cmake/attachments/20100611/7f6e9b64/attachment.txt>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: mypackage-config.cmake.in
URL: <http://www.cmake.org/pipermail/cmake/attachments/20100611/7f6e9b64/attachment.asc>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: mypackage-config-build-tree.cmake.in
URL: <http://www.cmake.org/pipermail/cmake/attachments/20100611/7f6e9b64/attachment-0001.txt>


More information about the CMake mailing list