Hi John,

I'm a bit surpised it didn't work, similar code elsewhere in the OSG
works for other libs, so I can only guess the that directory env var
for XRANDR isn't being set.

To try a fix it I've changed the code to be:

            IF  (X11_Xrandr_LIB)
                SET(LIB_EXTRA_LIBS ${X11_Xrandr_LIB} ${LIB_EXTRA_LIBS})
            ELSE(X11_Xrandr_LIB)
                SET(LIB_EXTRA_LIBS ${XRANDR_LIBRARIES} ${LIB_EXTRA_LIBS})
            ENDIF(X11_Xrandr_LIB)

The first branch is what was compiling on your machine before I
applied my patch to fix CMake 2.4.8 build, the second branch should
now be picked up for 2.4.8 support.

Could you let me know if this works.

Cheers,
Robert.


On Mon, Feb 2, 2009 at 7:49 PM, Shue, John A <[email protected]> wrote:
> Robert,
>
> The INCLUDE_DIRECTORIES() line didn't fix the error.  It added
> "-I/usr/local/lib" to the command lines used to compile the cpp files,
> but didn't add the requried "-L/usr/local/lib".
>
> Looking at the output of "grep Xrandr CMakeCache.txt", I see the
> following:
>
> XRANDR_LDFLAGS:INTERNAL=-L/usr/local/lib;-lXrandr
>
> which has both the -L and -l options we need to pass to the linker.
> Question is, how does this get added to the linker commandline?  Looking
> through osgViewer's CmakeLists.txt file, I don't see any obvious place.
>
> I got it to link with the following change:
>
> #            SET(LIB_EXTRA_LIBS ${XRANDR_LIBRARIES} ${LIB_EXTRA_LIBS})
>            SET(LIB_EXTRA_LIBS ${XRANDR_LDFLAGS} ${LIB_EXTRA_LIBS})
>
> I have no idea if this is correct usage.
>
> -john
>
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of Robert
> Osfield
> Sent: Monday, February 02, 2009 12:47 PM
> To: OpenSceneGraph Users
> Subject: Re: [osg-users] CDash errors/warnings
>
> Hi John,
>
> Could you try the attached src/osgViewer/CMakeLists.txt.   This adds a :
>
>            INCLUDE_DIRECTORIES(${XRANDR_LIBDIR})
>
> Robert.
>
> On Mon, Feb 2, 2009 at 5:24 PM, Shue, John A <[email protected]>
> wrote:
>> Robert,
>>
>> I haven't read all the messages on the other thread with Cedric, but I
>> tried this new CMakeLists.txt and it fails like the original one:
>>
>> Linking CXX shared library ../../lib/libosgViewer.so
>> cd /home/jshue/working-OSG/OpenSceneGraph/src/osgViewer &&
>> /usr/local/bin/cmake -E cmake_link_script
>> CMakeFiles/osgViewer.dir/link.txt --verbose=1
>> /usr/bin/c++  -fPIC  -Wall -Wparentheses -Wformat=2 -Wno-long-long
>> -Wno-import -pedantic -Wreturn-type -Wmissing-braces -Wunknown-pragmas
>> -Wunused -fpermissive -O3 -DNDEBUG  -shared
>> -Wl,-soname,libosgViewer.so.54 -o ../../lib/libosgViewer.so.2.7.9
>> CMakeFiles/osgViewer.dir/CompositeViewer.o
>> CMakeFiles/osgViewer.dir/HelpHandler.o
>> CMakeFiles/osgViewer.dir/Renderer.o CMakeFiles/osgViewer.dir/Scene.o
>> CMakeFiles/osgViewer.dir/ScreenCaptureHandler.o
>> CMakeFiles/osgViewer.dir/StatsHandler.o
>> CMakeFiles/osgViewer.dir/Version.o CMakeFiles/osgViewer.dir/View.o
>> CMakeFiles/osgViewer.dir/Viewer.o
> CMakeFiles/osgViewer.dir/ViewerBase.o
>> CMakeFiles/osgViewer.dir/ViewerEventHandlers.o
>> CMakeFiles/osgViewer.dir/GraphicsWindowX11.o
>> CMakeFiles/osgViewer.dir/PixelBufferX11.o ../../lib/libosgGA.so.2.7.9
>> ../../lib/libosgText.so.2.7.9 ../../lib/libosgDB.so.2.7.9
>> ../../lib/libosgUtil.so.2.7.9 ../../lib/libosg.so.2.7.9
>> ../../lib/libOpenThreads.so.2.3.1 -lXrandr -lm
> /usr/X11R6/lib/libGLU.so
>> /usr/X11R6/lib/libGL.so /usr/local/lib/libSM.so
> /usr/local/lib/libICE.so
>> /usr/local/lib/libX11.so /usr/local/lib/libXext.so -lpthread
>>
> -Wl,-rpath,/home/jshue/working-OSG/OpenSceneGraph/lib:/usr/local/lib:/us
>> r/X11R6/lib
>> /usr/bin/ld: cannot find -lXrandr
>> gmake[2]: *** [lib/libosgViewer.so.2.7.9] Error 1
>>
>>
>> My libXrandr.so is in /usr/local/lib.  I don't see a -L option for
>> /usr/local/lib in the commandline above.  Also the end of that
>> commandline doesn't look right to me, namely
>>
> "-Wl,-rpath,/home/jshue/working-OSG/OpenSceneGraph/lib:/usr/local/lib:/u
>> sr/X11R6/lib".
>>
>> If I add -L/usr/local/lib to the end of the above commandline, it
> links.
>>
>> -john
>>
>> -----Original Message-----
>> From: [email protected]
>> [mailto:[email protected]] On Behalf Of
> Robert
>> Osfield
>> Sent: Monday, February 02, 2009 7:06 AM
>> To: OpenSceneGraph Users
>> Subject: Re: [osg-users] CDash errors/warnings
>>
>> Hi John,
>>
>> On Sat, Jan 31, 2009 at 10:34 PM, Shue, John A <[email protected]>
>> wrote:
>>> That did the trick. Compiled all the way to the end of the build
>> without
>>> errors.
>>
>> Turns out that this fix that works for you and me using CMake 2.6.x,
>> breaks the build with Cmake 2.4.8 so we'll need to try out another
>> iteration, instead of using the X11_xrand_LIB we'll need to try
>> XRANDR_LIBRARIES var.  Could you try the attached CMakeLists.txt.
>>
>> Thanks,
>> Robert.
>> This communication, along with any attachments, is covered by federal
> and state law governing electronic communications and may contain
> company proprietary and legally privileged information.
>> If the reader of this message is not the intended recipient, you are
> hereby notified that any dissemination, distribution, use or copying of
> this message is strictly prohibited.
>> If you have received this in error, please reply immediately to the
> sender and delete this message.  Thank you.
>>
>> _______________________________________________
>> osg-users mailing list
>> [email protected]
>>
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.or
> g
>>
> This communication, along with any attachments, is covered by federal and 
> state law governing electronic communications and may contain company 
> proprietary and legally privileged information.
> If the reader of this message is not the intended recipient, you are hereby 
> notified that any dissemination, distribution, use or copying of this message 
> is strictly prohibited.
> If you have received this in error, please reply immediately to the sender 
> and delete this message.  Thank you.
>
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
# FIXME: For OS X, need flag for Framework or dylib
IF   (DYNAMIC_OPENSCENEGRAPH)
    ADD_DEFINITIONS(-DOSGVIEWER_LIBRARY)
ELSE (DYNAMIC_OPENSCENEGRAPH)
    ADD_DEFINITIONS(-DOSG_LIBRARY_STATIC)
ENDIF(DYNAMIC_OPENSCENEGRAPH)

SET(LIB_NAME osgViewer)

SET(HEADER_PATH ${OpenSceneGraph_SOURCE_DIR}/include/${LIB_NAME})
SET(LIB_PUBLIC_HEADERS
    ${HEADER_PATH}/CompositeViewer
    ${HEADER_PATH}/Export
    ${HEADER_PATH}/GraphicsWindow
    ${HEADER_PATH}/Renderer
    ${HEADER_PATH}/Scene
    ${HEADER_PATH}/Version
    ${HEADER_PATH}/View
    ${HEADER_PATH}/Viewer
    ${HEADER_PATH}/ViewerBase
    ${HEADER_PATH}/ViewerEventHandlers
)

SET(LIB_COMMON_FILES
    CompositeViewer.cpp
    HelpHandler.cpp
    Renderer.cpp
    Scene.cpp
    ScreenCaptureHandler.cpp
    StatsHandler.cpp
    Version.cpp
    View.cpp
    Viewer.cpp
    ViewerBase.cpp
    ViewerEventHandlers.cpp
)

SET(LIB_EXTRA_LIBS)

IF(WIN32)

    #
    # Enable workaround for OpenGL driver issues when used in 
multithreaded/multiscreen with NVidia drivers on Windows XP 
    # For example: osgviewer dumptruck.osg was showing total garbage (screen 
looked like shattered, splashed hedgehog) 
    # There were also serious issues with render to texture cameras.
    # Workaround repeats makeCurrentContext call as it was found that this 
causes the problems to dissapear.
    #
    OPTION(OSG_MULTIMONITOR_MULTITHREAD_WIN32_NVIDIA_WORKAROUND "Set to ON if 
you have NVidia board and drivers earlier than 177.92 ver" OFF)
    MARK_AS_ADVANCED(OSG_MULTIMONITOR_MULTITHREAD_WIN32_NVIDIA_WORKAROUND)
    IF(OSG_MULTIMONITOR_MULTITHREAD_WIN32_NVIDIA_WORKAROUND)
        ADD_DEFINITIONS(-DOSG_MULTIMONITOR_MULTITHREAD_WIN32_NVIDIA_WORKAROUND)
    ENDIF(OSG_MULTIMONITOR_MULTITHREAD_WIN32_NVIDIA_WORKAROUND)

    SET(LIB_PUBLIC_HEADERS ${LIB_PUBLIC_HEADERS}
        ${HEADER_PATH}/api/Win32/GraphicsWindowWin32
        ${HEADER_PATH}/api/Win32/PixelBufferWin32
    )
        
    SET(LIB_COMMON_FILES ${LIB_COMMON_FILES} 
        GraphicsWindowWin32.cpp
        PixelBufferWin32.cpp
    )

ELSE(WIN32)

    IF(APPLE)
        SET(OSG_WINDOWING_SYSTEM "Carbon" CACHE STRING "Windowing system type 
for graphics window creation, options Carbon or X11.")
    ELSE(APPLE)
        SET(OSG_WINDOWING_SYSTEM "X11" CACHE STRING "Windowing system type for 
graphics window creation. options only X11")
    ENDIF(APPLE)
    

    IF(${OSG_WINDOWING_SYSTEM} STREQUAL "Carbon")

        # FIXME: OS X needs selection mechanism for Cocoa, Carbon, X11
        SET(LIB_PUBLIC_HEADERS ${LIB_PUBLIC_HEADERS} 
            ${HEADER_PATH}/api/Carbon/GraphicsWindowCarbon
            ${HEADER_PATH}/api/Carbon/PixelBufferCarbon
        )
        SET(LIB_COMMON_FILES ${LIB_COMMON_FILES} 
            GraphicsWindowCarbon.cpp
            PixelBufferCarbon.cpp
        )

    ELSE(${OSG_WINDOWING_SYSTEM} STREQUAL "Carbon")

        # X11 for everybody else


        INCLUDE(FindPkgConfig OPTIONAL)
        IF (PKG_CONFIG_FOUND)

            PKG_CHECK_MODULES(XRANDR xrandr)
            
            IF (XRANDR_FOUND) 
                OPTION(OSGVIEWER_USE_XRANDR "Set to ON to enable Xrandr support 
for GraphicsWindowX11." ON)
            ELSE(XRANDR_FOUND) 
                SET(OSGVIEWER_USE_XRANDR OFF)
            ENDIF (XRANDR_FOUND)
        ELSE(PKG_CONFIG_FOUND)
            SET(OSGVIEWER_USE_XRANDR OFF)
        ENDIF(PKG_CONFIG_FOUND)


        SET(LIB_PUBLIC_HEADERS ${LIB_PUBLIC_HEADERS}
            ${HEADER_PATH}/api/X11/GraphicsWindowX11
            ${HEADER_PATH}/api/X11/PixelBufferX11
        )


        SET(LIB_COMMON_FILES ${LIB_COMMON_FILES} 
            GraphicsWindowX11.cpp 
            PixelBufferX11.cpp
        )
        
        IF(OSGVIEWER_USE_XRANDR)
        
            ADD_DEFINITIONS(-DOSGVIEWER_USE_XRANDR)
            SET(LIB_PRIVATE_HEADERS ${LIB_PRIVATE_HEADERS} 
${XRANDR_INCLUDE_DIRS} )

            IF  (X11_Xrandr_LIB)
                SET(LIB_EXTRA_LIBS ${X11_Xrandr_LIB} ${LIB_EXTRA_LIBS})
            ELSE(X11_Xrandr_LIB)
                SET(LIB_EXTRA_LIBS ${XRANDR_LIBRARIES} ${LIB_EXTRA_LIBS})
            ENDIF(X11_Xrandr_LIB)
            
        ENDIF(OSGVIEWER_USE_XRANDR)

        # X11 on Apple requires X11 library plus OpenGL linking hack on Leopard
        IF(APPLE)
            # Find GL/glx.h 
            IF(EXISTS ${CMAKE_OSX_SYSROOT}/usr/X11/include/GL/glx.h)
                SET(OPENGL_INCLUDE_DIR /usr/X11/include)
                SET(OPENGL_LIBRARIES /usr/X11/lib/libGL.dylib)
            ELSEIF(EXISTS ${CMAKE_OSX_SYSROOT}/usr/X11R6/include/GL/glx.h)
                SET(OPENGL_INCLUDE_DIR /usr/X11R6/include)
                SET(OPENGL_LIBRARIES /usr/X11R6/lib/libGL.dylib)
            ENDIF(EXISTS ${CMAKE_OSX_SYSROOT}/usr/X11/include/GL/glx.h)
            INCLUDE_DIRECTORIES(BEFORE SYSTEM ${OPENGL_INCLUDE_DIR})

            SET(LIB_EXTRA_LIBS ${X11_X11_LIB} ${OPENGL_LIBRARIES} 
${LIB_EXTRA_LIBS})
            SET(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} 
-Wl,-dylib_file,/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib:${CMAKE_OSX_SYSROOT}/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib")
        ENDIF(APPLE)
            

    ENDIF(${OSG_WINDOWING_SYSTEM} STREQUAL "Carbon")

ENDIF(WIN32)


ADD_LIBRARY(${LIB_NAME}
    ${OPENSCENEGRAPH_USER_DEFINED_DYNAMIC_OR_STATIC}
    ${LIB_PUBLIC_HEADERS}
    ${LIB_PRIVATE_HEADERS}
    ${LIB_COMMON_FILES}
)


LINK_INTERNAL(${LIB_NAME}     
    osgGA
    osgText
    osgDB
    osgUtil
    osg
    OpenThreads
    ${LIB_EXTRA_LIBS}
)

LINK_CORELIB_DEFAULT(${LIB_NAME})

IF(MINGW OR CYGWIN)
    LINK_EXTERNAL(${LIB_NAME} gdi32 )
ENDIF(MINGW OR CYGWIN)

INCLUDE(ModuleInstall OPTIONAL)

FOREACH( INCLUDEFILE ${LIB_PUBLIC_HEADERS} )
   FILE(RELATIVE_PATH REL_INCLUDEFILE ${HEADER_PATH} ${INCLUDEFILE})
   GET_FILENAME_COMPONENT(REL_INCLUDE_PATH ${REL_INCLUDEFILE} PATH)
   INSTALL(
   FILES        ${INCLUDEFILE}
   DESTINATION ${INSTALL_INCDIR}/${LIB_NAME}/${REL_INCLUDE_PATH}
   COMPONENT libopenscenegraph-dev
   )
ENDFOREACH( INCLUDEFILE)
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to