[cfe-dev] bug: LIBRARY_PATH handling difference with GCC (?)
René J. V. Bertin via cfe-dev
cfe-dev at lists.llvm.org
Tue Aug 1 00:56:37 PDT 2017
René J.V. Bertin via cfe-dev wrote:
Ping?
> Hi,
>
> I ran into an issue linking a library with a specific libpng today.
>
> The cmake build system found the desired library and set
> PNG_LIBRARIES="/opt/local/lib/libpng.so;/opt/local/lib/libz.so" . However, my
> build script also sets LIBRARY_PATH=/opt/local/lib so that I don't have to add
> -L/opt/local/lib to each and every linker call.
>
> Because of this, cmake rewrites the PNG_LIBRARIES value to "-lpng -lz" when I
> use it in a link command.
>
> That works fine with GCC but for some reason not with clang (4.0.1, installed
> via the Ubuntu .deb from llvm.org). With clang I get errors about missing
> symbols, which indicate that the system libpng is being pulled in.
>
> I did a very simple test comparing
>
> %> env LIBRARY_PATH=/opt/local/lib g++ -v test.cpp -lpng
> %> env LIBRARY_PATH=/opt/local/lib clang++ -v test.cpp -lpng
>
> With g++ (7.1.0) the resulting a.out is linked to /opt/local/lib/libpng16.so
> while with clang++ it links to Ubuntu's libpng12.so . Comparing the actual
> link commands I notice that g++ invokes collect2 with -L/opt/local/lib BEFORE
> the first -lfoo library spec, while clang++ invokes /usr/bin/ld with
> -L/opt/local/lib set AFTER the user-specified -lfoo library specs.
>
> Is there a reason for that, or is this a bug?
>
> Thanks,
> René
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
More information about the cfe-dev
mailing list