Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm building something from source and I get the following output while running make:

  ...
  CC     libpromises_la-mod_outputs.lo
  CC     libpromises_la-unix.lo
  CCLD   libpromises.la
  CC     cfknow.o
  CC     manual.o
  CCLD   cf-know
./.libs/libpromises.so: undefined reference to `dlerror'
./.libs/libpromises.so: undefined reference to `dladdr'
./.libs/libpromises.so: undefined reference to `dlclose'
./.libs/libpromises.so: undefined reference to `dlopen'
./.libs/libpromises.so: undefined reference to `dlsym'
collect2: ld returned 1 exit status
gmake[2]: *** [cf-know] Error 1
gmake[2]: Leaving directory `/tmp/cfengine/cfengine-3.1.5/src'
gmake[1]: *** [all] Error 2
gmake[1]: Leaving directory `/tmp/cfengine/cfengine-3.1.5/src'
gmake: *** [all-recursive] Error 1

I've googled a bit and it seems that the linker can't find certain files. I've never had to deal with something like this so I'm wondering if someone can help me decode this message and shed insight on WHICH file can't be found and how I can tell the linker where it is.

I know that the reference comes from libpromises.so, which is a binary file. Hence, opening it in vi only gives me garble. Am I supposed to be looking for libpromises.h? libpromises.c?

share|improve this question
1  
Are you sure you have the required libraries installed? It could be an error of unfulfilled requirements. –  new123456 Jul 9 '11 at 1:24
    
I'm not well versed in C programming, so I'm not sure what those libraries are and how to search for them. Assuming I have them, how can I tell the linker where to look? –  maxmackie Jul 9 '11 at 1:25

1 Answer 1

up vote 2 down vote accepted

You should be able to edit the Makefile and accomplish this quickly.

NOTE - This assumes that the Makefile was made by GNU Autotools. According to the Cfengine tarball, they do.

First, open the Makefile and look for the flag LDFLAGS. It should look something like this:

LDFLAGS=-lfoo -lbar

Append to that listing -ldl. This adds a reference to the Dynamic Loading library.

Recompile, and the linker should be able to do it's job.


The LIBS environment variable is an environment variable that tells ./configure what extra libraries are needed, which it then sticks into the Makefile (so, to answer your question, ./configure doesn't actually run the linker - it makes the Makefile, which runs gcc with the parameters it got from ./configure).

So, use LIBS=-ldl && ./configure.

share|improve this answer
    
This looks like a fun answer, I get to edit a Makefile :) However, I'm going to have to wait until Monday to go back to work. I'll post when I get back to work and try this. –  maxmackie Jul 9 '11 at 1:59
    
I just tried this and it didn't work. –  maxmackie Jul 11 '11 at 13:24
1  
@MaxMackie Try this: export LIBS=-ldl && ./configure. Ripped from here. –  new123456 Jul 11 '11 at 14:01
    
Wow, I think that worked. Brilliant! Could you edit your answer and explain what the LIBS variable does? And exactly what that flag is telling the compiler/linker? Thanks so much. –  maxmackie Jul 11 '11 at 14:05

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.