title: ROS catkin build - cannot find shared library
body: <p>I am trying to catkin build this ROS package <a href="https://github.com/toddhester/rl-texplore-ros-pkg" rel="nofollow noreferrer">https://github.com/toddhester/rl-texplore-ros-pkg</a> but it fails to build 'rl_experiment' with the following error:</p>
  
  <pre><code>/usr/bin/ld: cannot find -lagentlib
  /usr/bin/ld: cannot find -lenvlib
  collect2: error: ld returned 1 exit status
  </code></pre>
  
  <p>I am using ROS Kinetic. The shared libraries does exist in the folders /texplore/devel/.private/rl_env/lib/ and /texplore/devel/.private/rl_agent/lib/ with symlinks at /texplore/devel/lib/</p>
  
  <p>I tried the following:</p>
  
  <p>(1) export /texplore/devel/lib/ to LD_LIBRARY_PATH</p>
  
  <p>(2) adding symlinks to the libraries in /texplore/src/rl_experiment/src</p>
  
  <p>(3) adding the library paths to target_link_libraries</p>
  
  <pre><code>target_link_libraries(experiment agentlib envlib ${catkin_LIBRARIES} 
      "/media/usr/texplore/devel/lib/libagentlib.so"
      "/media/usr/texplore/devel/lib/libenvlib.so")
  </code></pre>
  
  <p>(4) set the search path for linker</p>
  
  <pre><code>SET(CMAKE_EXE_LINKER_FLAGS 
            "${CMAKE_EXE_LINKER_FLAGS} -Wl,-rpath -Wl,/media/usr/texplore/devel/lib/")
  </code></pre>
  
  <p>It didn't work. Lastly, I added the symlinks to /usr/local/lib and it worked. But I do not want the symlinks in this folder.</p>
  
  <p>So the linker is simply not searching the build tree. My question is, why did catkin not add the linker path in catkin_LIBRARIES? I have built ROS packages before but can't wrap my head around why this particular package is not working.</p>