<div dir="ltr"><div style>All of these articles say the way to avoid having an absolute path stored in the linked output is to use -L &lt;dir&gt; -l &lt;lib&gt; ... which is definatly not what cmake is producing.  Reflecting on this, maybe I can replace target_link_libraries with manually specified link_flags; maybe some sort of similarly named macro</div>
<div><br></div><a href="http://stackoverflow.com/questions/14551204/any-way-to-make-ld-record-shared-library-name-only-no-subdirs">http://stackoverflow.com/questions/14551204/any-way-to-make-ld-record-shared-library-name-only-no-subdirs</a><br>
<br><div><a href="http://stackoverflow.com/questions/1124809/embedding-absolute-path-for-shared-libraries">http://stackoverflow.com/questions/1124809/embedding-absolute-path-for-shared-libraries</a><br></div><div><br></div>
<div><a href="http://stackoverflow.com/questions/2726993/g-how-to-specify-preference-of-library-path">http://stackoverflow.com/questions/2726993/g-how-to-specify-preference-of-library-path</a><br></div><div><br></div><div>
<br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Apr 2, 2013 at 9:29 AM, J Decker <span dir="ltr">&lt;<a href="mailto:d3ck0r@gmail.com" target="_blank">d3ck0r@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">So from the silence, either I described my issue badly, or there isn&#39;t a way?<div><br></div><div>From the script at the end, when generating &#39;unix makefiles&#39; with a mingw environment, or MingW makefiles, these are the gcc commands....</div>

<div><br></div><div>(compile .obj)</div><div><div>c:/tools/unix/mingw.mangled/bin/gcc.exe  -Dtest2_EXPORTS  -o CMakeFiles/test2.dir/test2.c.obj   -c M:/tmp/cmake_crash/test4/test2.c</div><div><div>(link .dll)</div>
<div>c:/tools/unix/mingw.mangled/bin/gcc.exe     -shared -o libtest2.dll -Wl,--out-implib,libtest2.dll.a -Wl,--major-image-version,0,--minor-image-version,0 -Wl,@CMakeFiles/test2.dir/objects1.rsp -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 </div>

<div><div>(compile .obj)</div><div></div><div>c:/tools/unix/mingw.mangled/bin/gcc.exe    -o CMakeFiles/test1.dir/test1.c.obj   -c M:/tmp/cmake_crash/test4/test1.c</div><div><div>(link .exe)</div><div>c:/tools/unix/mingw.mangled/bin/gcc.exe      -Wl,@CMakeFiles/test1.dir/objects1.rsp  -o test1.exe -Wl,--out-implib,libtest1.dll.a -Wl,--major-image-version,0,--minor-image-version,0  libtest2.dll.a -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 </div>

<div><br></div></div></div></div><div>In the link .exe step, it references the full name (and full path) of the libtest2.dll.a ... if this were a more complex case where a library is built in the root, the path could be like ../../../../liblib.dll.a.  Now, as a windows target this doesn&#39;t matter so much, but when using a toolchain file to target android, the full path to the .so gets embedded..... </div>

<div class="gmail_extra"><br></div><div class="gmail_extra"><br></div><div class="gmail_extra"><br></div><div class="gmail_extra"><br></div><div class="gmail_extra"><br></div><div class="gmail_extra"><div class="gmail_extra">

c:\general\android-ndk-r8c\toolchains\arm-linux-androideabi-4.6\prebuilt\windows\bin\arm-linux-androideabi-gcc.exe --sysroot=c:/general/android-ndk-r8c/platforms/android-14/arch-arm -Dtest2_EXPORTS -fPIC -Ic:\general\android-ndk-r8c\platforms\android-14\arch-arm\usr\include -Ic:\general\android-ndk-r8c\sources\cxx-stl\gnu-libstdc++\4.6\include -Ic:\general\android-ndk-r8c\sources\cxx-stl\gnu-libstdc++\4.6\libs\armeabi\include    -o CMakeFiles\test2.dir\test2.c.obj   -c M:\tmp\cmake_crash\test4\test2.c</div>

<div class="gmail_extra"><br></div></div><div class="gmail_extra"><div class="gmail_extra">c:\general\android-ndk-r8c\toolchains\arm-linux-androideabi-4.6\prebuilt\windows\bin\arm-linux-androideabi-gcc.exe --sysroot=c:/general/android-ndk-r8c/platforms/android-14/arch-arm -fPIC    -shared  -o libtest2.so CMakeFiles/test2.dir/test2.c.obj  -Lc:\general\android-ndk-r8c\platforms\android-14\arch-arm\usr\lib  -Lc:\general\android-ndk-r8c\sources\cxx-stl\gnu-libstdc++\4.6\libs\armeabi </div>

<div class="gmail_extra"><br></div></div><div class="gmail_extra"><div class="gmail_extra">c:\general\android-ndk-r8c\toolchains\arm-linux-androideabi-4.6\prebuilt\windows\bin\arm-linux-androideabi-gcc.exe --sysroot=c:/general/android-ndk-r8c/platforms/android-14/arch-arm  -Ic:\general\android-ndk-r8c\platforms\android-14\arch-arm\usr\include -Ic:\general\android-ndk-r8c\sources\cxx-stl\gnu-libstdc++\4.6\include -Ic:\general\android-ndk-r8c\sources\cxx-stl\gnu-libstdc++\4.6\libs\armeabi\include    -o CMakeFiles\test1.dir\test1.c.obj   -c M:\tmp\cmake_crash\test4\test1.c</div>

<div class="gmail_extra"><br></div><div class="gmail_extra"><div class="gmail_extra">c:\general\android-ndk-r8c\toolchains\arm-linux-androideabi-4.6\prebuilt\windows\bin\arm-linux-androideabi-gcc.exe --sysroot=c:/general/android-ndk-r8c/platforms/android-14/arch-arm     CMakeFiles/test1.dir/test1.c.obj  -o test1  -Lc:\general\android-ndk-r8c\platforms\android-14\arch-arm\usr\lib  -Lc:\general\android-ndk-r8c\sources\cxx-stl\gnu-libstdc++\4.6\libs\armeabi  libtest2.so </div>

<div class="gmail_extra"><br></div></div><div class="gmail_extra">see... libtest2.so <br></div><div class="gmail_extra"><br></div><div class="gmail_extra">.....</div><div class="gmail_extra">So, since I REALLY need a solution for this; I guess, what I can do is stretch out the projects into multiple cmake passes, and treat it more like an installed library.</div>
<div><div class="h5">
<div class="gmail_extra"><br></div><div class="gmail_extra"><br></div><br><div class="gmail_quote">On Tue, Mar 19, 2013 at 3:05 AM, J Decker <span dir="ltr">&lt;<a href="mailto:d3ck0r@gmail.com" target="_blank">d3ck0r@gmail.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">I&#39;m using MinGW Makefiles as a base and a toolchain file.<div>

<br></div><div>I made a (somewhat) simple cmakelists that makes a library, and an executable that links against it.</div><div><br></div><div>Without specifying the toolchain, the link command looks something like</div>
<div><br></div><div>gcc test1.c.obj -o test1 -ltest2   </div><div>(hmm no, that&#39;s what I want it to say) </div><div><br></div><div>what it does say is more like</div><div><br></div><div>gcc test1.c.obj -o test1 test2.dll.a</div>


<div>or</div><div>gcc test1.c.obj -o test1 libtest2.so</div><div><br></div><div><br></div><div>can I convince Cmake to generate references to libraries with -l instead of the path to the library it linked?</div><div><br>

</div>
<div>; or, the warnings (potential errors?) I&#39;m getting say like...</div><div><div>..../bin/ld.exe: warning: libbag.so, needed by ..\..\..\..\libbag.psi++.so, not found (try using -rpath or -rpath-link)</div><div>.../bin/ld.exe: warning: libbag++.so, needed by ..\..\..\..\libbag.psi++.so, not found (try using -rpath or -rpath-link)</div>


<div>.../bin/ld.exe: warning: <a href="http://libbag.externals.so" target="_blank">libbag.externals.so</a>, needed by ..\..\..\..\libbag.psi++.so, not found (try using -rpath or -rpath-link)</div></div><div><br></div><div>

these libraries appear in the actual link line several times, both before and after the libraries in question...</div>
<div><br></div><div>so do I apply the rpath (or rpath-link to the executable or the component library... (it&#39;s actually a program:lib:lib:lib dependency)</div><div>(I tried both, and it helped, but only for a little while; probably because it didn&#39;t need to rebuilt, so it wasn&#39;t an error. THere aren&#39;t any unresolved symbols (but could there be?)</div>


<div><br></div><div><br></div><div>----- a cmake to make a lib and executable -----------</div><div><br></div><div>cmake_minimum_required(VERSION 2.8)</div><div><div><br></div><div>FILE( WRITE ${CMAKE_CURRENT_SOURCE_DIR}/test1.c &quot;int main() { return f(); } &quot; )</div>


<div>FILE( WRITE ${CMAKE_CURRENT_SOURCE_DIR}/test2.c &quot;int f() { return 1; } &quot; )</div><div><br></div><div>add_library( test2 SHARED test2.c )</div><div>add_executable( test1 test1.c )</div><div>target_link_libraries( test1 test2 )</div>


<div><div><br></div><div>----------------------</div></div></div><div><br></div>
</blockquote></div><br></div></div></div></div></div>
</blockquote></div><br></div>