[Cmake] how to find STATIC library, ignore DYNAMIC library
Brad King
brad.king at kitware.com
Thu Aug 19 11:11:29 EDT 2004
Liwei Peng wrote:
> I am a CMake user for a long time. Recently I have a
> problem in using CMake to find the right library.
This has been a common problem due to unix linker limitations. I have
some ideas on how to fix it which I've documented in this feature request:
http://www.cmake.org/Bug/bug.php?op=show&bugid=1105
> In my program, I need to link HDF library. In my
> computer, there are both HDF dynamic
> library(libhdf5.so) and HDF static library(libhdf5.a)
> installed under /usr/lib. I want to link the static
> library. but CMake always go to the dynamic library.
> Is there any way in CMake that I can force it to use
> static instead of dynamic?
This can be fixed on a per-platform basis by including the proper linker
flag in your CMAKE_EXE_LINKER_FLAGS variable. I think adding something
like -Bstatic will tell the linker to use only static libraries. You
will have to read the documentation for your linker to find the proper flag.
-Brad
More information about the Cmake
mailing list