Discussion:
/usr/bin/ld: cannot find -ldl
(too old to reply)
Jungle Boogie
2018-07-12 21:29:50 UTC
Permalink
Hi All,

Since commit 9c38803597 I can't build fossil successfully:

.o bld/linenoise.o bld/shell.o bld/th.o bld/th_lang.o bld/th_tcl.o
bld/cson_amalgamation.o -lfuse -lm -lssl -lcrypto -lz -ldl
/usr/bin/ld: cannot find -ldl
cc: error: linker command failed with exit code 1 (use -v to see invocation)
*** Error 1 in /home/jungle/fossil-repos/fossil (./src/main.mk:670 'fossil')

Looks like there was only one minor change to the makemake.tcl file. I can
generate main.mk file without any issues:
tclsh makemake.tcl
building main.mk
building ../win/Makefile.mingw
building ../win/Makefile.dmc
building ../win/Makefile.msc
building ../win/Makefile.PellesCGMake

Just compiling is failing.


Any clues?

Thanks!
Richard Hipp
2018-07-12 21:47:46 UTC
Permalink
Post by Jungle Boogie
Any clues?
Could you tell us what platform you are trying to compile on?
--
D. Richard Hipp
***@sqlite.org
Jungle Boogie
2018-07-12 22:02:40 UTC
Permalink
Post by Richard Hipp
Post by Jungle Boogie
Any clues?
Could you tell us what platform you are trying to compile on?
Yes, sorry about that.


openBSD -current x64
$ cc -v
OpenBSD clang version 6.0.0 (tags/RELEASE_600/final) (based on LLVM 6.0.0)
Target: amd64-unknown-openbsd6.3
Thread model: posix
InstalledDir: /usr/bin
Post by Richard Hipp
--
D. Richard Hipp
Richard Hipp
2018-07-12 22:06:31 UTC
Permalink
Post by Jungle Boogie
openBSD -current x64
I don't have access to such a system for debugging purposes. Can you
suggest a patch?
--
D. Richard Hipp
***@sqlite.org
Joerg Sonnenberger
2018-07-12 22:20:49 UTC
Permalink
Post by Richard Hipp
Post by Jungle Boogie
openBSD -current x64
I don't have access to such a system for debugging purposes. Can you
suggest a patch?
-ldl should really only be used on Linux and Darwin. None of the BSDs
needs or wants it.

Joerg
Warren Young
2018-07-12 22:23:31 UTC
Permalink
Post by Richard Hipp
Post by Jungle Boogie
openBSD -current x64
I don't have access to such a system for debugging purposes. Can you
suggest a patch?
I’d suggest revisiting the decision to replace cc-check-function-in-lib with the custom check-function-in-lib variant. The logic behind it seems suspect: you *want* it to modify LIBS because you order the calls to the function in leaf-to-root order.

That is, the checks should be ordered so:

cc-check-function-in-lib dlopen dl
cc-check-function-in-lib iconv iconv
cc-check-function-in-lib inflateEnd z
cc-check-function-in-lib gethostbyname nsl
cc-check-function-in-lib ns_name_uncompress resolv
cc-check-function-in-lib sqlite3_open sqlite3 $extralibs
cc-check-function-in-lib dlopen dl

That call list is based on the current contents of auto.def, but consider it pseudocode, not a patch, intended just to show the pattern: the most depended-upon library is checked for first, because it may be needed to link one or more of those that follow, especially on non-Linux systems which usually have linkers that won’t chase dependencies for you automatically.

The stock version of cc-check-function-in-lib *prepends* each subsequent library for this very reason: so that the first-checked library ends up at the *end* of LIBS.
Warren Young
2018-07-12 22:27:24 UTC
Permalink
Post by Warren Young
cc-check-function-in-lib dlopen dl
cc-check-function-in-lib iconv iconv
cc-check-function-in-lib inflateEnd z
cc-check-function-in-lib gethostbyname nsl
cc-check-function-in-lib ns_name_uncompress resolv
cc-check-function-in-lib sqlite3_open sqlite3 $extralibs
cc-check-function-in-lib dlopen dl
Copy-paste bug: remove the second dlopen(2) check. It should be checked early, because many other libraries use this syscall.

The networking stuff is after the core syscall checks, but before any libraries that do networking, etc.

The order of the libnsl and libresolv checks might need to be swapped, but I think I’ve got it right as shown.
Artur Shepilko
2018-07-13 10:08:47 UTC
Permalink
Post by Jungle Boogie
openBSD -current x64
$ cc -v
OpenBSD clang version 6.0.0 (tags/RELEASE_600/final) (based on LLVM 6.0.0)
Target: amd64-unknown-openbsd6.3
Thread model: posix
InstalledDir: /usr/bin
Ok, I think I found the problem. This info was very helpful.

Indeed, the *BSD platforms have all the dl functionality in the
standard C library, so no libdl present.
This should make the test `[check-function-in-lib dlopen dl]` pass
without the need for -ldl.

Corrected it and pushed an update
[http://fossil-scm.org/index.html/info/7cdb522b42aad6a1]
Please try if this solves it for you.

Thank you for catching the bug!
Jungle Boogie
2018-07-13 15:35:58 UTC
Permalink
Post by Artur Shepilko
Post by Jungle Boogie
openBSD -current x64
$ cc -v
OpenBSD clang version 6.0.0 (tags/RELEASE_600/final) (based on LLVM 6.0.0)
Target: amd64-unknown-openbsd6.3
Thread model: posix
InstalledDir: /usr/bin
Ok, I think I found the problem. This info was very helpful.
Indeed, the *BSD platforms have all the dl functionality in the
standard C library, so no libdl present.
This should make the test `[check-function-in-lib dlopen dl]` pass
without the need for -ldl.
Corrected it and pushed an update
[http://fossil-scm.org/index.html/info/7cdb522b42aad6a1]
Please try if this solves it for you.
Thank you for catching the bug!
Thank YOU for fixing and pushing it to trunk. I've been able to successfully
build fossil now.

Thanks!

Artur Shepilko
2018-07-13 05:43:14 UTC
Permalink
I made the recent change that moves the -ldl to the end of the link
library list (http://fossil-scm.org/index.html/info/efbc319c32a38fab).
However its effect should be rather trivial, just moving the -ldl to
the end of the library list. Such check was there before, just the
-ldl would be inserted afer -lm
This altogether would matter for __static__ linking, in your case I
understand you configured for dynamic linking.

So if your build was succeeding prior to this change, I'd be puzzled too.

Could you share here the contents of config.log file from your fossil
build directory?

If possible, please make a fresh configure & build:
------
cd bld
make distclean
../configure <whichever-options-for-your-build>
ls config.log
ls Makefile
make
-----

I assume it shoud fail again due to -ldl. So the config.log could shed
some light on the results of testing for dl library.
We'll see what the reason for the config check to incorrectly finding
libdl on your platform.

In case you just want to have it built, you may manually edit the
generated Makefile and remove -ldl from the LIB line, supposedly it's
not needed in your configuration.
Post by Jungle Boogie
Hi All,
.o bld/linenoise.o bld/shell.o bld/th.o bld/th_lang.o bld/th_tcl.o
bld/cson_amalgamation.o -lfuse -lm -lssl -lcrypto -lz -ldl
/usr/bin/ld: cannot find -ldl
cc: error: linker command failed with exit code 1 (use -v to see invocation)
*** Error 1 in /home/jungle/fossil-repos/fossil (./src/main.mk:670 'fossil')
Looks like there was only one minor change to the makemake.tcl file. I can
tclsh makemake.tcl
building main.mk
building ../win/Makefile.mingw
building ../win/Makefile.dmc
building ../win/Makefile.msc
building ../win/Makefile.PellesCGMake
Just compiling is failing.
Any clues?
Thanks!
_______________________________________________
fossil-users mailing list
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users
Loading...