Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Linking in Linux  (Read 8748 times)

0 Members and 1 Guest are viewing this topic.

hatfarm

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: Linking in Linux
« Reply #15 on: August 18, 2013, 04:03:46 am »
Alright, doing the example following, I added find_package(OpenGL REQUIRED) and I link it, but now I get an error in CMake that says:

Cannot specify link libraries for target
  "/usr/lib/i386-linux-gnu/libGLU.so" which is not built by this project.

When I try to link ${OPENGL_LIBRARIES}

Any ideas?
« Last Edit: August 18, 2013, 04:12:41 am by hatfarm »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Linking in Linux
« Reply #16 on: August 18, 2013, 09:38:42 am »
The first argument of target_link_libraries must be the target (your executable), not the libraries to link.
Laurent Gomila - SFML developer

hatfarm

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: Linking in Linux
« Reply #17 on: August 18, 2013, 09:57:46 pm »
Ah, that wasn't exactly the problem, but that lead me to figure out what the problem was.  The problem was that I copied the code from my executable's CMakeLists.txt into my library, and I didn't change the target name, so it was telling me that EXEC_NAME didn't have a build target, because it was supposed to be LIBR_NAME.  That resolved the linking with SFML issues, now I'm having issues where it's not able to link my library to my executable, but since that's not an SFML issue,  I'll keep that outta here.  Thanks for all your help everyone, much appreciated!

hatfarm

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: Linking in Linux
« Reply #18 on: August 19, 2013, 05:59:46 am »
Gah!  I resolved the issues with my own linking, but now it's having problems with X11.  I've got this in my CMakeLists.txt files:

IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
    find_package(X11 REQUIRED)
    set(LIB_INCLUDES
        ${LIB_INCLUDES}
        ${X11_INCLUDE_DIR})
    set(LIB_LINKS
        ${LIB_LINKS} ${X11_LIBRARIES} )
ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")

However, I get this error when it goes to link:

/usr/bin/ld: /home/hatfarm/SFML-2.1//lib/libsfml-window-s.a(WindowImplX11.cpp.o): undefined reference to symbol 'XGetWindowAttributes'
/usr/bin/ld: note: 'XGetWindowAttributes' is defined in DSO /usr/lib/gcc/i686-linux-gnu/4.7/../../../i386-linux-gnu/libX11.so so try adding it to the linker command line
/usr/lib/gcc/i686-linux-gnu/4.7/../../../i386-linux-gnu/libX11.so: could not read symbols: Invalid operation
collect2: error: ld returned 1 exit status

I have it print out LIB_LINKS and it shows exactly the libx11.so is found.  I know that LIB_LINKS and LIB_INCS are not the problem, because it doesn't complain about my library or OpenGL.  I know x11 is installed, because I can see that file, and I was able to build SFML.

Anyone have any ideas?