Hi, <br><br>The library you are trying to link to is named foo, not A in the CMakeLists.txt of A.  If you export -lfoo insteadof -lA it should work fine.  in our example code we often use ${PROJECT_NAME} for the name of libraries which makes the library have the same name as the package.  <br>


<br>As a side note, you don't need to explicitly link lib A, now foo, to bar in B's CMakeLists, it's already linked due to the export.  <br><br>Tully<br><br><div class="gmail_quote">On Tue, Feb 1, 2011 at 9:25 PM, Person With question <span dir="ltr"><<a href="mailto:personwithquestion@yahoo.com">personwithquestion@yahoo.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div><div style="font-family: 'times new roman','new york',times,serif; font-size: 12pt; color: black;">

<font style="color: black; font-size: 12pt;" face="arial, helvetica, sans-serif">Hello,</font><div style="color: black; font-size: 12pt;"><font face="arial, helvetica, sans-serif"><br></font></div><div style="color: black; font-size: 12pt;">

<font face="arial, helvetica, sans-serif">I am having trouble figuring out how to include libraries from other packages I have written. I have attached a minimal example of my problem.</font></div><div style="color: black; font-size: 12pt;">

<span style="font-family: arial,helvetica,sans-serif;"><br></span></div><div style="color: black; font-size: 12pt;"><font face="arial, helvetica,
 sans-serif"></font><span style="font-family: arial,helvetica,sans-serif;">I have package A that contains foo.cpp and foo.h, and I have package B that contains bar.cpp from which it tries to call a function in foo.cpp. </span><span style="font-family: 'lucida console',sans-serif;">I have placed foo.h in "include/A/foo.h", and all cpp files are in their respective "src" folders. </span><span style="font-family: arial,helvetica,sans-serif;">I have configured the manifests of package A and B as follows:</span></div>

<div style="color: black; font-size: 12pt;"><div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="'lucida console', sans-serif">---- A ----</font></div><div><font face="'lucida console',
 sans-serif">+ <export></font></div><div><font face="'lucida console', sans-serif">+   <cpp cflags="-I${prefix}/include" lflags="-Wl,-rpath,${prefix}/lib -L${prefix}/lib -lA"/>·</font></div>

<div><font face="'lucida console', sans-serif">+ </export></font></div></div><div style="color: black; font-size: 12pt;"><font face="'lucida console', sans-serif">---- B ----</font></div><div style="color: black; font-size: 12pt;">

<span style="font-size: medium;"><font face="'lucida console', sans-serif">+ <depend package="A"/></font></span></div><div style="color: black; font-size: 12pt;"><span style="font-size: medium;"><font face="'lucida console', sans-serif"><br>

</font></span></div><div style="color: black; font-size: 12pt;"><span style="font-size: medium;"><font face="'lucida console', sans-serif"><span style="font-family: arial,helvetica,sans-serif; font-size: 16px;">...and I have configured the CMakeLists.txt of packages A and B as follows:</span></font></span></div>

<div style="color: black; font-size: 12pt;"><span style="font-size: medium;"><font face="'lucida console', sans-serif"><div style="color: black; font-size: 12pt;"><div><font face="'lucida console', sans-serif">---- A
 ----</font></div></div><div style="color: black; font-size: 12pt;"><font face="'lucida console', sans-serif">+ rosbuild_add_library(foo src/foo.cpp)</font></div><div style="color: black; font-size: 12pt;"><font face="'lucida console', sans-serif">---- B ----</font></div>

<div style="color: black; font-size: 12pt;"><font face="'lucida console', sans-serif">+ rosbuild_add_executable(bar src/bar.cpp)</font></div><div style="color: black; font-size: 12pt;"><font face="'lucida console', sans-serif">+ target_link_libraries(bar A)</font></div>

<div style="color: black; font-size: 12pt; font-family: 'Times New Roman';"><font face="'lucida console', sans-serif"><br></font></div><div style="color: black; font-size: 12pt;">It seems that I have no trouble including "A/foo.h" from bar.cpp, but I cannot use any of the
 functions. When I try to compile package B, I get the error "/usr/bin/ld: cannot find -lA" What am I doing wrong?</div></font></span></div><div style="color: black; font-size: 12pt;"><span style="font-size: medium;"><font face="'lucida console', sans-serif"><br>

</font></span></div><div style="color: black; font-size: 12pt;"><span style="font-size: medium;"><font face="'lucida console', sans-serif">I would very much appreciate it if someone could point me in the right direction, or email a new attachment with the fixed source. </font></span><span style="font-family: arial,helvetica,sans-serif;">I've followed the advice in the following links, but have had no luck getting this example to work.</span></div>

<div style="color: black; font-size: 12pt;"><a href="http://ros-users.122217.n3.nabble.com/linking-shared-library-td862667.html" target="_blank"><font face="arial, helvetica, sans-serif">http://ros-users.122217.n3.nabble.com/linking-shared-library-td862667.html</font></a></div>

<div style="color: black; font-size: 12pt;"><a href="http://www.ros.org/wiki/Manifest" target="_blank"><font face="arial, helvetica, sans-serif">http://www.ros.org/wiki/Manifest</font></a></div><div style="color: black; font-size: 12pt;">

<a href="http://www.ros.org/wiki/rosbuild/CMakeLists" target="_blank"><font face="arial, helvetica, sans-serif">http://www.ros.org/wiki/rosbuild/CMakeLists</font></a></div><div style="color: black; font-size: 12pt;"><font face="arial, helvetica, sans-serif"><br>

</font></div><div style="color: black; font-size: 12pt;"><font face="arial, helvetica, sans-serif">-Person</font></div><div style="font-family: 'times new roman','new york',times,serif; color: black; font-size: 12pt;">

<br></div></div><br>

      </div><br>_______________________________________________<br>
ros-users mailing list<br>
<a href="mailto:ros-users@code.ros.org">ros-users@code.ros.org</a><br>
<a href="https://code.ros.org/mailman/listinfo/ros-users" target="_blank">https://code.ros.org/mailman/listinfo/ros-users</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>Tully Foote<br>Systems Engineer<br>Willow Garage, Inc.<br><a href="mailto:tfoote@willowgarage.com">tfoote@willowgarage.com</a><br>(650) 475-2827<br>