Undefined reference to dlopen

Undefined reference to dlopen

Welcome to LinuxQuestions.org, a friendly and active Linux Community.

You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!

Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.

Are you new to LinuxQuestions.org? Visit the following links:
Site Howto | Site FAQ | Sitemap | Register Now

If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.

Having a problem logging in? Please visit this page to clear all LQ-related cookies.

Introduction to Linux — A Hands on Guide

This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter. For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author’s experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.

Click Here to receive this Complete Guide absolutely free.

After a harddisk crash I had to reinstall my system. Now I’m having problems compiling programs, like modlogan 0.8.13.

./configure runs okay, but during make I get the error:

mplugins.o(.text+0xed): In function `mplugins_load_plugins’:
/usr/src/modlogan-0.8.13/src/mplugins.c:127: undefined reference to `dlopen’
mplugins.o(.text+0x11c):/usr/src/modlogan-0.8.13/src/mplugins.c:142: undefined reference to `dlsym’
mplugins.o(.text+0x2f5):/usr/src/modlogan-0.8.13/src/mplugins.c:134: undefined reference to `dlerror’
mplugins.o(.text+0x43c): In function `mplugins_free’:
/usr/src/modlogan-0.8.13/src/mplugins.c:212: undefined reference to `dlclose’
collect2: ld returned 1 exit status
make[3]: *** [modlogan] Error 1
make[3]: Leaving directory `/usr/src/modlogan-0.8.13/src’
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/usr/src/modlogan-0.8.13/src’
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/usr/src/modlogan-0.8.13′
make: *** [all] Error 2

In the configure output I see:
checking for dlopen. no
checking for dlopen in -ldl. no
checking for dlopen in -lsvld. no
checking for dld_link in -ldld. no
checking if libtool supports shared libraries. yes
checking whether to build shared libraries. yes
checking whether to build static libraries. yes
configure: creating libtool
appending configuration tag "CXX" to libtool

I have these packages installed:
glib-1.2.10, glib2-2.6.5, glibc-2.3.5, glibc-solibs-2.3.5, glibc-zoneinfo-2.3.5, libtool-1.5.14

I don’t know where to start, the system is fresh.
I got the same errors with checkinstall.

I work in Linux with C++ (Eclipse), and want to use a library. Eclipse shows me an error:

Do you know a solution?

Here is my code:

10 Answers 10

You have to link against libdl, add

to your linker options

@Masci is correct, but in case you’re using C (and the gcc compiler) take in account that this doesn’t work:

Took me a bit to figure out.

The topic is quite old, yet I struggled with the same issue today while compiling cegui 0.7.1 (openVibe prerequisite).

What worked for me was to set: LDFLAGS="-Wl,—no-as-needed" in the Makefile.

I’ve also tried -ldl for LDFLAGS but to no avail.

you can try to add this

to the configure options

That’s one annoying "feature" for sure

I was struggling with it when writing heredoc syntax and found some interesting facts. With CC=Clang , this works:

as well as all of these:

  • $CC -ldl -x c -o app.exe —
  • $CC -x c -ldl -o app.exe —
  • $CC -x c -o app.exe -ldl —
  • $CC -x c -o app.exe — -ldl

However, with CC=gcc , only the last variant works; -ldl after — (the stdin argument symbol).

I was using CMake to compile my project and I’ve found the same problem.

The solution described here works like a charm, simply add $ to the target_link_libraries() call

You needed to do something like this for the makefile:

That’ll pass the linker flags from make through to the linker. Doesn’t matter that the makefile was autogenerated.

I met the same problem even using -ldl .

Besides this option, source files need to be placed before libraries, see undefined reference to `dlopen’.

In order to use dl functions you need to use the -ldl flag for the linker.

how you do it in eclipse ?

Press Project —> Properties —> C/C++ build —> Settings —> GCC C++ Linker —>
Libraries —> in the "Libraries(-l)" box press the "+" sign —> write "dl" (without the quotes)-> press ok —> clean & rebuild your project.

Я работаю в Linux с C++ (Eclipse) и хочу использовать библиотеку. Затмение показывает мне ошибку:

знаете ли вы решение?

9 ответов:

вы должны связать против libdl, добавить

в параметрах линкера

@Masci правильно, но в случае, если вы используете C (и gcc компилятор) примите во внимание, что это не работает:

мне потребовалось немного, чтобы понять.

тема довольно старая, но я боролся с той же проблемой сегодня при компиляции cegui 0.7.1 (предварительное условие openVibe).

что работал для меня было установить: LDFLAGS="-Wl,—no-as-needed" в Makefile.

Я тоже пробовал -ldl на LDFLAGS но безрезультатно.

вы можете попробовать добавить это

к параметрам настройки

вам нужно было сделать что-то вроде этого для makefile:

это передаст флаги компоновщика от make до компоновщика. Не имеет значения, что makefile был создан автоматически.

Я встретил ту же проблему, даже используя -ldl .

кроме этой опции, исходные файлы должны быть размещены перед библиотеками, см. неопределенная ссылка на ‘dlopen’.

для использования функций dl необходимо использовать флаг-ldl для компоновщика.

Как вы это делаете в eclipse ?

пресс проект —>свойства —> C / C++ build —>настройки —>GCC и с++ Компоновщик —>
библиотеки —> в поле" библиотеки(-l)"нажмите на знак"+" —> написать "dl" (без кавычек)-> нажмите ОК —>очистить и восстановить ваш проект.

но есть также довольно краткое объяснение в документах От $man gcc

08-07-2005, 07:16 PM #1
Ссылка на основную публикацию
Adblock detector