-ldl is missing when using only juce_core module

Hi,

the title says. when building a commandline app and using only juce_core module on linux the linker flag -ldl is missing.

I am on Ubuntu 11.10. Kernel 3.0.0-16-generic

Peter

Ok… but I’m a bit puzzled as to why you say this is because you’re only using juce_core, because -ldl isn’t ever added to the gcc flags under any circumstances!

I also realized that -ldl is never used, but adding -ldl solves this linker error:

Compiling Main.cpp
Compiling juce_core.cpp
In file included from ../../../../modules/juce_core/juce_core.cpp:155:0:
../../../../modules/juce_core/native/juce_posix_SharedCode.h: In member function ‘void juce::FileInputStream::openHandle()’:
../../../../modules/juce_core/native/juce_posix_SharedCode.h:423:30: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
../../../../modules/juce_core/native/juce_posix_SharedCode.h: In member function ‘void juce::FileOutputStream::openHandle()’:
../../../../modules/juce_core/native/juce_posix_SharedCode.h:468:38: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
../../../../modules/juce_core/native/juce_posix_SharedCode.h:486:34: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
Linking BinaryBuilder
build/intermediate/Debug/juce_core_1ee54a40.o: In function `juce::juce_getExecutableFile()':
/home/peter/projects/Common/juce/extras/binarybuilder/Builds/Linux/../../../../modules/juce_core/native/juce_posix_SharedCode.h:575: undefined reference to `dladdr'
build/intermediate/Debug/juce_core_1ee54a40.o: In function `juce::DynamicLibrary::open(juce::String const&)':
/home/peter/projects/Common/juce/extras/binarybuilder/Builds/Linux/../../../../modules/juce_core/native/juce_posix_SharedCode.h:930: undefined reference to `dlopen'
build/intermediate/Debug/juce_core_1ee54a40.o: In function `juce::DynamicLibrary::close()':
/home/peter/projects/Common/juce/extras/binarybuilder/Builds/Linux/../../../../modules/juce_core/native/juce_posix_SharedCode.h:938: undefined reference to `dlclose'
build/intermediate/Debug/juce_core_1ee54a40.o: In function `juce::DynamicLibrary::getFunction(juce::String const&)':
/home/peter/projects/Common/juce/extras/binarybuilder/Builds/Linux/../../../../modules/juce_core/native/juce_posix_SharedCode.h:945: undefined reference to `dlsym'
collect2: ld returned 1 exit status
make: *** [build/BinaryBuilder] Error 1

Ok. Well, I guess I’ll add -ldl to the list of libraries then!

It’s strange because when I have the gui modules included I don’t get any linker errors related to this.

Could it be related to the binutils chanages mentioned here: http://www.rawmaterialsoftware.com/viewtopic.php?f=5&t=8338

Yes, could be. Anyways, I’ll add the extra library.