[CMake] How to link a .so file under linux?
Andy Cedilnik
andy.cedilnik at kitware.com
Tue Nov 2 08:12:36 EST 2004
Hi Ning,
A quick solution would be to create symlink to your library:
FIND_FILE(MYLIB xxxxlib.so /path/to)
IF(NOT MYLIB)
MESSAGE(SEND_ERROR "Cannot find library xxxxlib.so")
ENDIF(NOT MYLIB)
EXEC_PROGRAM(/bin/ln ARGS "-s \"${MYLIB}\"
\"${CMAKE_CURRENT_BINARY_DIR}/libxxxxlib.so\""
RETURN_VALUE ln_res)
IF("${ln_retval}" GREATER 0)
MESSAGE(SEND_ERROR "Problem creating symlink from
\"${MYLIB}\" to \"${CMAKE_CURRENT_BINARY_DIR}/libxxxxlib.so\"")
ENDIF("${ln_retval}" GREATER 0)
TARGET_LINK_LIBRARIES(exec "${CMAKE_CURRENT_BINARY_DIR}/libxxxxlib.so")
Something like this should work.
Andy
On Mon, 2004-11-01 at 20:56, Ning Cao wrote:
> hi, Andy,
>
> Thank you for your help.
> Finally I found what's wrong with me. Instead of using the library libxxxx.so, the lib file is named as xxxxlib.so. CMake failed to process properly I think. It is ok if I rename the .so file.
>
> I will have a look at the CMake source to see if it is the manner of CMake.
>
> Best Regards,
> Yours,
> Ning
> ----- Original Message -----
> From: "Andy Cedilnik" <andy.cedilnik at kitware.com>
> To: "Ning Cao" <ningcao at uky.edu>
> Cc: <cmake at www.cmake.org>
> Sent: Friday, October 29, 2004 11:54 AM
> Subject: Re: [CMake] How to link a .so file under linux?
>
>
> > Hi Ning,
> >
> > Two options:
> >
> > 1. Just do TARGET_LINK_LIBRARIES(program /path/to/library.so)
> >
> > 2. Better one is to:
> >
> > FIND_LIBRARY(MY_LIB NAMES library
> > PATHS /path/to)
> > TARGET_LINK_LIBRARIES(program ${MY_LIB})
> >
> > Andy
> >
> > On Fri, 2004-10-29 at 10:19, Ning Cao wrote:
> >> I want to link a .so file (provided by others) to my executable file.
> >> Could anyone tell me how to do this with CMake?
> >
> >
> >
> >
>
> ______________________________________________________________________
> _______________________________________________
> CMake mailing list
> CMake at www.cmake.org
> http://www.cmake.org/mailman/listinfo/cmake
--
Andy Cedilnik
Kitware Inc.
More information about the CMake
mailing list