[CMake] Testing shared library

"Flávio P. Duarte" fduarte at gisplan.com.br
Tue Jul 25 15:46:51 EDT 2006


William A. Hoffman wrote:
> At 02:19 PM 7/25/2006, Flávio P. Duarte wrote:
>> It looks like CMake is prependind LD_LIBRARY_PATH before ../src and in
>> LD_LIBRARY_PATH there is an older version of mylib.
>> The CMake command line looks like:
>> /usr/bin/c++   -g -Wall   -fPIC -L/home/user/lib/
>> "CMakeFiles/test1.dir/obj1.o" "CMakeFiles/test1.dir/obj2.o"   -o test1
>> -rdynamic -L/home/user/test/src
>> I think the first -L is being added to CMake to correspond to
>> LD_LIBRARY_PATH environment variable. The easiest solution would be get
>> rid of LD_LIBRARY_PATH, but I consider it as a last option. And if the
>> first -L corresponds to LD_LIBRARY_PATH, it might be a bug. People will
>> not be able to test their libraries without changing this variable first.
>>        As an alternative, I thought change the command line, but I open to
>> suggestions.
>>
>> Flavio
> 
> CMake is not looking at LD_LIBRARY_PATH.  You must be doing an in-source
> build and creating a library that is being put in /home/user/test/src which
> is why cmake is adding the -L.
The /home/user/test/src directory is ok. You are right about your
statement: It is where the new mylib is located. The problem is
/home/user/lib. This directory should not be there. CMake should place
the project paths before LDFLAGS.

  Apparently I forgot to paste the end of the compiler line, so I am
repeating it:
/usr/bin/c++   -g -Wall   -fPIC -L/home/user/lib/
"CMakeFiles/test1.dir/obj1.o" "CMakeFiles/test1.dir/obj2.o"   -o test1
-rdynamic -L/home/user/test/src -lmylib

Flavio


More information about the CMake mailing list