Closed teto closed 4 years ago
Your case is a beautiful example of why it is difficult to do this right with Free Pascal.
pkg-config --libs-only-l Lua
will output -llua -lm
. We can't simply pass that to the compiler. The language expects that we name the library each time we declare a function from that library. So we put the name of the library into the autoconf variable lua_LIB_NAME that is substituted in src/config.inc.in. But if all we have is -llua -lm
, which is the correct library? lua
or m
? If we don't want to guess based on the name, we would have to check the exported symbols of both libraries. But what is the full name of the library? liblua.so? liblua.a? liblua.dylib? ... And in which directory can we find it? We would need to search all directories returned by pkg-config --libs-only-L Lua
and the default directories compiled into the compiler/linker. Is it a shared library so we can use nm -Dg
or do we have to use nm -g
to list the relevant symbols? It might even be a linker script disguised as a library, like it is usually done for libc and libpthread from Glibc. And what about -lm
? There must be a reason why it is listed in lua5.2.pc. Do we really have to explicitly link to the math library? Also note #188.
don't know about free pascal:
The language expects that we name the library each time we declare a function from that library.
you mean the soname ? Is there a way to force the value of lua_LIB_NAME ? In worst case, we might patch the installer.
I see we did patch it for pcre already, so I just extended that and it seems to work: NixOS/NixPkgs@fbda7ca802b. Of course, feel free to improve here in upstream and/or the expression in nixpkgs.
Please, do not create duplicate issues
Actual behaviour
Compilation fails on master with:
This is the result of the configure
Expected behaviour
I believe rather than guessing what to link, if pkg-config is available then the softwaure should just use pkg-config --libs lua to get the LDFLAGS. For instance on my system, the content of lua5.2.pc is: