[CMake] building on linux, extra libraries referenced

J Decker d3ck0r at gmail.com
Mon Dec 26 13:06:11 EST 2011


Hmm Maybe this isn't what I thought it was... how do I get cmake to
link against libraries built in the same project with -l instead of
direct reference?


../../../../libbag.psi++.so ../../../../libbag.psi.so
../../../../libbag++.so ../../../../libbag.externals.so
../../../../libbag.so -lodbc -lsqlite3 -lfreetype
-Wl,-rpath,/home/d3x0r/work/build/sack/build/core:


I want the first .so's to be referenced more like sqlite3 or freetype.


On Mon, Dec 26, 2011 at 3:37 AM, Michael Wild <themiwi at gmail.com> wrote:
> On 12/26/2011 08:46 AM, J Decker wrote:
>> I have this huge project that I've been building with cmake; and even
>> under gcc (mingw) I don't have this problem... but what is happening
>> is I have a generic list of libraries that I provide for applications
>> to link against.  This includes the c version and the c++ version of
>> two libraries.  On Windows, only those libraries that are actually
>> used are referenced in the final output.  On Linux, with very recent
>> gcc compilers, the programs end up with references to both libraries,
>> and both(all 4) libraries are loaded.  I understand that this is
>> probably a feature of some sort; but now do I specify for ld to only
>> use the libraries that have referenced symbols in them?
>
> Actually, it should be just the reverse. Recent versions of Linux
> (Ubuntu and Debian I know of) should have --as-needed and
> --no-copy-dt-needed-entries in effect by default, causing the behaviour
> you want.
>
> Michael
>
> --
>
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake


More information about the CMake mailing list