[CMake] /path/to/libpng.so automatic conversion to -lpng ?

René J. V. Bertin rjvbertin at gmail.com
Wed Jul 12 12:31:56 EDT 2017


Andreas Naumann wrote:

> cmake instrospects your compiler and asks for system directories. Only
> these system directories will be removed and the corresponding libraries
> will be linked by -l<...>. So, you should check your compiler and the
> environment. I had several problems years ago with the environment
> variable LIBRARY_PATH, which leads to such a behavior.

Hello Andreas,

Aha, I indeed have LIBRARY_PATH=/opt/local/lib set (by the build scripts I use).
>From what I understand, that variable allows you to specify a set of -L 
directories via an env. variable (other than LDFLAGS). 

It seems that clang handles that variable in a somewhat different manner than 
GCC does. Even in a very simple call on the commandline (including the -v 
option) I see it adds -L/opt/local/lib AFTER the user-supplied libraries, where 
GCC puts it before the 1st -l option.

R.




More information about the CMake mailing list