<div class="gmail_extra">Hi,<br><br><div class="gmail_quote">On Mon, Apr 23, 2012 at 13:24, Vyacheslav Karamov <span dir="ltr">&lt;<a href="mailto:ubuntulist@yandex.ru" target="_blank">ubuntulist@yandex.ru</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi All!<br>
<br>
I have a problem with target_link_libraries. It  can&#39;t link with shared libraries not from directory listed in LD_LIBRARY_PATH.<br>
1. When I try to link shared library with the full path obtained from find_library, my library is passed to gcc without -l option as ordinary object file.<br></blockquote><div><br></div><div>What is the problem with linking the absolute path of the shared library? This should just work </div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
2. When I try to link by specifying short name &quot;cblas&quot; I&#39;ve got the error message:<br>
<br>
Linking CXX shared library ../../sndcompare/amd64sse3/<u></u>libsndcompared.so<br>
/usr/bin/ld: cannot find -lcblas<br>
collect2: ld returned 1 exit status<br>
make[2]: *** [../../sndcompare/amd64sse3/<u></u>libsndcompared.so] Error 1<br>
make[1]: *** [CMakeFiles/sndcompare.dir/<u></u>all] Error 2<br>
make: *** [all] Error 2<br>
*** Failed ***<br></blockquote><div><br></div><div>This is because the linker does not know the directory where to search for the library.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
add_library(${lib_name} SHARED<br>
${io_files}<br>
${utils_files}<br>
${tech_independ_files}<br>
${other_files}<br>
)<br>
<br>
find_library(atlas<br>
    NAME atlas<br>
    PATHS ${CMAKE_CURRENT_SOURCE_DIR}/${<u></u>CMAKE_SYSTEM_NAME}/atlas/${<u></u>arch}/lib<br>
    DOC &quot;Atlas library&quot;<br>
    )<br>
<br>
find_library(cblas<br>
    NAME cblas<br>
    PATHS ${CMAKE_CURRENT_SOURCE_DIR}/${<u></u>CMAKE_SYSTEM_NAME}/atlas/${<u></u>arch}/lib<br>
    DOC &quot;Cblas library&quot;<br>
    )<br>
<br>
link_directories(<br>
${CMAKE_CURRENT_SOURCE_DIR}/${<u></u>CMAKE_SYSTEM_NAME}/atlas/${<u></u>arch}/lib<br>
${CMAKE_CURRENT_SOURCE_DIR}/..<u></u>/../Sphinx/sphinxbase/${CMAKE_<u></u>SYSTEM_NAME}/${arch}/lib<br>
)<br></blockquote><div><br></div><div>link_directories is not needed at all here or should not be needed. Just make sure to pass ${cblas} and ${atlas} to</div><div>target_link_libraries. If that produces errors please provide the exact error message.</div>
<div><br></div><div>Andreas</div></div></div>