[CMake] add_test and locating dependent DLL's on Windows

Werner Smekal smekal at iap.tuwien.ac.at
Tue May 12 02:23:03 EDT 2009


Hi.
>
> As I said, on Linux when I do "make test", my_test gets run fine--I  
> think because rpath is properly recording the location of the shared  
> libraries.   On windows (Visual Studio 2005), my_test will not run.  
> When I execute ctest by hand, I am told that it cannot locate  
> 'util.dll' (as well as icuuc.dll, etc.)
>
> Forgive me if there is a simple answer to this...Windows is a  
> strange and foreign land to me.

The dlls are not found since they must be either in the same  
directory, in a path listed in the PATH environment variable or in a  
system directory.  There are some solutions to this problem, but best  
is to let cmake move all the dlls (and import libraries) to some known  
place e.g. with

if(BUILD_SHARED_LIBS AND WIN32 AND NOT CYGWIN)
   SET(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/dll)
endif(BUILD_SHARED_LIBS AND WIN32 AND NOT CYGWIN)

You must now add this directory (${CMAKE_CURRENT_BINARY_DIR}/dll) to  
the PATH environment variable, the easiest way, since you use VS 2005)  
is to go to Start->Control Panel->System->Advanced->Environment  
Variables and change the PATH variable there. You must at least quit  
Visual C++ and restart to recognize the new PATH variable and  
sometimes even this doesn't suffice - you must restart the system.  
Then the dlls will be found since they are located in a path listed in  
the PATH variable.

There is actually a possibility to tell Visual C++ directly where the  
DLL is located (by changing the PATH variable for one configuration  
inside VS), but I don't remember right now how and I'm just on the  
wrong OS right now to have a look.

HTH,
Werner


>
> Thanks,
> -scott
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake

--
Dr. Werner Smekal
Institut fuer Allgemeine Physik
Technische Universitaet Wien
Wiedner Hauptstr 8-10
A-1040 Wien
Austria

email: smekal at iap.tuwien.ac.at
web: http://www.iap.tuwien.ac.at/~smekal
phone: +43-(0)1-58801-13463 (office), +43-(0)1-58801-13469 (laboratory)
fax: +43-(0)1-58801-13499



More information about the CMake mailing list