apps can't be linked against libdl in 12.04

Bug #1002672 reported by lvd on 2012-05-22
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
eglibc (Ubuntu)
Undecided
Unassigned

Bug Description

An example program:

===
#include <stdio.h>
#include <dlfcn.h>

main()
{
 dlopen("/lib/example.so", RTLD_NOW);

}
===

and its compilation gives:

===
lvd@ubuserv1204:~/tmp/dltest$ gcc -c dltest.c
lvd@ubuserv1204:~/tmp/dltest$ gcc -ldl -o dltest dltest.o
dltest.o: In function `main':
dltest.c:(.text+0xf): undefined reference to `dlopen'
collect2: ld returned 1 exit status
===

This bug exists in i386, pure amd64 and in multilib (both with -m32 option to gcc and without).

Please ask me for additional info.

lvd (lvd-mhm) wrote :

my info about eglibc is wrong:

===
lvd@ubuserv1204:~$ dpkg --search libdl
libc6: /lib/x86_64-linux-gnu/libdl.so.2
libc6-dev: /usr/lib/x86_64-linux-gnu/libdl.so
libc6-dev: /usr/lib/x86_64-linux-gnu/libdl.a
libc6: /lib/x86_64-linux-gnu/libdl-2.15.so
===

so libc6 is probably the cause.

Also,
===
lvd@ubuserv1204:~$ gcc --print-file-name=libdl.so
/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/libdl.so
===

Jason Conti (jconti) wrote :

You need to specify the libraries after the code that reference them. So the correct method is:

gcc -o dltest dltest.o -ldl

The command line above would work anyways prior to oneiric, but from oneiric onward the linker is more strict. See http://wiki.debian.org/ToolChain/DSOLinking

Marking as invalid.

Changed in eglibc (Ubuntu):
status: New → Invalid
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers