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

Author Topic: Linking on Linux  (Read 13091 times)

0 Members and 1 Guest are viewing this topic.

shadowmouse

  • Sr. Member
  • ****
  • Posts: 302
    • View Profile
Linking on Linux
« on: November 13, 2015, 03:27:47 pm »
I've just switched from using Windows 10 to using Ubuntu and installed libsfml-dev using the Ubuntu Software Centre. However I'm confused, as the package that is installed contains only header files and when I attempt to link to the libraries in codeblocks, it says it cannot find -lsfml-graphics-s etc. Am I missing something? Do you have to compile the library yourself if you download it from the software centre (option 1 in the tutorial)? Sorry if it's a stupid question.

SeriousITGuy

  • Full Member
  • ***
  • Posts: 123
  • Still learning...
    • View Profile
Re: Linking on Linux
« Reply #1 on: November 13, 2015, 03:38:05 pm »
I don't know what's exactly in the package libsfml-dev, but normally a -dev package only contains the developement headers.

It is best you compile it yourself from source, it is easy and since version 2.2 very straight forward. This way you have development headers and library files correctly installed.

shadowmouse

  • Sr. Member
  • ****
  • Posts: 302
    • View Profile
Re: Linking on Linux
« Reply #2 on: November 13, 2015, 03:58:40 pm »
Okay, will do. I've done that before on windows so I presume the process is the same using CMake on Linux? Also, do I compile the code in the dev package I downloaded, or do I download the github code linked on the SFML downloads page?

Rosme

  • Full Member
  • ***
  • Posts: 169
  • Proud member of the shoe club
    • View Profile
    • Code-Concept
Re: Linking on Linux
« Reply #3 on: November 13, 2015, 04:26:53 pm »
Clone the repository and build that one. Most of the time, the package in the official packages are out-dated anyway.
GitHub
Code Concept
Twitter
Rosme on IRC/Discord

Spirro

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
Re: Linking on Linux
« Reply #4 on: November 13, 2015, 09:15:34 pm »
I've just switched from using Windows 10 to using Ubuntu and installed libsfml-dev using the Ubuntu Software Centre. However I'm confused, as the package that is installed contains only header files and when I attempt to link to the libraries in codeblocks, it says it cannot find -lsfml-graphics-s etc. Am I missing something? Do you have to compile the library yourself if you download it from the software centre (option 1 in the tutorial)? Sorry if it's a stupid question.

Generally speaking, on linux, when you install a dev package it installs the headers and binaries, but seems as though that didn't happen in your case.  You can look at the dev package you installed and find the matching binary package and install it as well, or as Roseme suggested, compile and install it yourself.  Information on that is found here:
http://www.sfml-dev.org/tutorials/2.3/start-linux.php

and here:

http://www.sfml-dev.org/tutorials/2.3/compile-with-cmake.php

Just be sure to fully read the first page as installing from source tends to put libraries in non-standard locations, so to use what you have compiled you will need to set environment variables properly so the system can find what it needs to run your programs.

shadowmouse

  • Sr. Member
  • ****
  • Posts: 302
    • View Profile
Re: Linking on Linux
« Reply #5 on: November 13, 2015, 10:58:23 pm »
Well as I'm used to Windows I have no problem with setting it up to find the libraries wherever I installed them. Thanks for the info and links.

shadowmouse

  • Sr. Member
  • ****
  • Posts: 302
    • View Profile
Re: Linking on Linux
« Reply #6 on: November 14, 2015, 05:27:36 pm »
I've installed the libraries using cmake and checked and it made all the files and things, but Codeblocks says it can't find -lopengl32 -lwinmm or -lgdi32, and I can't find any of those in the Ubuntu package manager and CMake built it, indicating that I had installed all the necessary libraries. What am I doing wrong?
EDIT: I forgot to say, but I'm linking statically and I built the project in CMake as a Codeblocks- Unix Makefile.
« Last Edit: November 14, 2015, 05:37:00 pm by shadowmouse »

Spirro

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
Re: Linking on Linux
« Reply #7 on: November 14, 2015, 07:49:04 pm »
I've installed the libraries using cmake and checked and it made all the files and things, but Codeblocks says it can't find -lopengl32 -lwinmm or -lgdi32, and I can't find any of those in the Ubuntu package manager and CMake built it, indicating that I had installed all the necessary libraries. What am I doing wrong?
EDIT: I forgot to say, but I'm linking statically and I built the project in CMake as a Codeblocks- Unix Makefile.

I'm guessing you are using a 64 bit install.  With your system saying it needs opengl32 and gdi32 you will have to install the 32bit versions.  For opengl it should be the mesa 32 bit drivers.  gdi I'd have to look(on windows atm)  I forget what winmm was when I installed dependencies, but if you install catfish from your repo you can use it as a gui to search your computer for those files to see if they are actually there and you need to export links to them if they are.

shadowmouse

  • Sr. Member
  • ****
  • Posts: 302
    • View Profile
Re: Linking on Linux
« Reply #8 on: November 14, 2015, 08:05:54 pm »
Yes I do have the 64 bit install, which I hadn't realised would be a problem. I'll have a look into catfish, and what do you mean by the mesa 32 bit drivers?

Spirro

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
Re: Linking on Linux
« Reply #9 on: November 14, 2015, 10:09:37 pm »
Yes I do have the 64 bit install, which I hadn't realised would be a problem. I'll have a look into catfish, and what do you mean by the mesa 32 bit drivers?

Some programs on linux require their 32 bit versions to run.  For example, I don't know if you use steam on linux or not, but the client is 32bit so even on a 64 bit install it pulls in 32 bit versions of several libs so it will work properly.  Mesa is one of the video driver sets and it has two versions.  64 bit and 32 bit.  From what you last posted as needing, opengl32 and gdi32 that tells me you need the 32 bit versions of those libs.  You'll just have to check your repo for 32 bit versions of those drivers, and install them as well.  Again, I'm guessing you need the 32 bit mesa drivers, but check your hardware to be sure of what particular video driver you need.  For gdi do the same.

shadowmouse

  • Sr. Member
  • ****
  • Posts: 302
    • View Profile
Re: Linking on Linux
« Reply #10 on: November 14, 2015, 10:33:35 pm »
I found a guide to getting opengl working and installed the mesa drivers and apparently on Linux it's just called GL, so I replace opengl32 in the linking options with GL and it has got rid of the can't find -lopengl32 message, but I can't find anything about getting gdi or winmm.

dabbertorres

  • Hero Member
  • *****
  • Posts: 506
    • View Profile
    • website/blog
Re: Linking on Linux
« Reply #11 on: November 14, 2015, 11:00:47 pm »
gdi and winmm are Windows only.

Spirro

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
Re: Linking on Linux
« Reply #12 on: November 14, 2015, 11:19:11 pm »
gdi and winmm are Windows only.

I never had the problems shadowmouse is having, but if the above is the case then imo shadowmouse should toss his compilation from before and redo it making 100% sure he's correctly followed instructions on the pages I linked earlier in the thread.

Edit:  Also be sure the proper toolchain is being used for compilation.  I'm sure it was, but if windows versions of libs are being asked for then perhaps a MinGW crosscompilation tool chain was used?  I don't know, but check something along those lines as well.
« Last Edit: November 14, 2015, 11:23:44 pm by Spirro »

shadowmouse

  • Sr. Member
  • ****
  • Posts: 302
    • View Profile
Re: Linking on Linux
« Reply #13 on: November 14, 2015, 11:23:12 pm »
Firstly, I've been working off those and going over them carefully, I'm fully aware of how precise you have to be. Secondly, I've got rid of gdi and winmm from the linker and that's got rid of those errors, I now have only a single error which is undefined reference to XGetXCBConnection. I've gone back through the libraries that you have to install for Linux and rechecked all the ones to do with XCB and I'm fairly sure I'm not missing any. Any ideas? And thanks everyone for all the help, I know how annoying the constant I can't set it up posts can be.

Spirro

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
Re: Linking on Linux
« Reply #14 on: November 14, 2015, 11:26:58 pm »
Firstly, I've been working off those and going over them carefully, I'm fully aware of how precise you have to be. Secondly, I've got rid of gdi and winmm from the linker and that's got rid of those errors, I now have only a single error which is undefined reference to XGetXCBConnection. I've gone back through the libraries that you have to install for Linux and rechecked all the ones to do with XCB and I'm fairly sure I'm not missing any. Any ideas? And thanks everyone for all the help, I know how annoying the constant I can't set it up posts can be.

A quick search found this: http://manpages.ubuntu.com/manpages/maverick/man3/XGetXCBConnection.3.html

Quote
The  XGetXCBConnection  function  returns the XCB connection associated
       with an Xlib  Display.   Clients  can  use  this  XCB  connection  with
       functions  from  the  XCB  library,  just  as  they  would  with an XCB
       connection created with XCB.  Callers of this  function  must  link  to
       libX11-xcb and a version of Xlib built with XCB support.

Maybe that helps.