From 8d2092603203d3f565dbb32b86db625bbdd6a415 Mon Sep 17 00:00:00 2001 From: Paul MARTZ Date: Sun, 22 May 2011 18:49:43 +0000 Subject: [PATCH] 2.8 branch: This is a backport of r11055 from trunk so that libosg and libosgDB link against libdl on Linux systems. Backported by Ryan Pavlik. Trunk commit messages: "From Jim Brooks, fix for FreeBSD build where FIND_LIBRARY(DL_LIBRARY..) return NOT_FOUND. And From Alberto Luaces, "he new GNU linker, "gold", is going to replace soon the current ld in almost all Linux distributions. Although it is 100% compatible with ld, by default it gives an error if a library has unresolved symbols at link time, that is, it has set -Wl,--no-undefined by default. Debian folks have found that libosg.so and libosgDB.so use some functions belonging to libdl.so {dlsym,dlopen,dlclose,dlerror} without linking to it. My changes link those two libraries to libdl.so explicitly in the same way it is already done for libm.so and librt.so." --- CMakeLists.txt | 6 ++++++ src/osg/CMakeLists.txt | 2 +- src/osgDB/CMakeLists.txt | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9bb960cdf..75b233cc2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -153,6 +153,12 @@ IF(UNIX) FIND_PACKAGE(X11) # Some Unicies need explicit linkage to the Math library or the build fails. FIND_LIBRARY(MATH_LIBRARY m) + + FIND_LIBRARY(DL_LIBRARY dl) + IF(NOT DL_LIBRARY) + SET(DL_LIBRARY "") # change from NOTFOUND to empty when passed to linker + ENDIF() + ENDIF(UNIX) # Make the headers visible to everything diff --git a/src/osg/CMakeLists.txt b/src/osg/CMakeLists.txt index 5bb3d96f1..7b5b029a3 100644 --- a/src/osg/CMakeLists.txt +++ b/src/osg/CMakeLists.txt @@ -326,7 +326,7 @@ ADD_LIBRARY(${LIB_NAME} LINK_INTERNAL(${LIB_NAME} OpenThreads ) -LINK_EXTERNAL(${LIB_NAME} ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIBRARY} ) +LINK_EXTERNAL(${LIB_NAME} ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIBRARY} ${DL_LIBRARY}) LINK_CORELIB_DEFAULT(${LIB_NAME} ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIBRARY} ) INCLUDE(ModuleInstall OPTIONAL) diff --git a/src/osgDB/CMakeLists.txt b/src/osgDB/CMakeLists.txt index 300bce174..19bce40b3 100644 --- a/src/osgDB/CMakeLists.txt +++ b/src/osgDB/CMakeLists.txt @@ -110,7 +110,7 @@ LINK_INTERNAL(${LIB_NAME} osg OpenThreads ) -LINK_EXTERNAL(${LIB_NAME} ${OSGDB_PLATFORM_SPECIFIC_LIBRARIES} ) +LINK_EXTERNAL(${LIB_NAME} ${OSGDB_PLATFORM_SPECIFIC_LIBRARIES} ${DL_LIBRARY}) LINK_CORELIB_DEFAULT(${LIB_NAME}) INCLUDE(ModuleInstall OPTIONAL)