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

Author Topic: Linking on Linux  (Read 15060 times)

0 Members and 1 Guest are viewing this topic.

jcowgill

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Linking on Linux
« Reply #30 on: November 17, 2015, 12:26:00 am »
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.

Yes libsfml-dev itself only contains the header files, but when you installed it it should have pulled in the library packages (libsfml-window2.3v5 etc) which contain the actual libraries. However, libsfml-dev does not contain any static libraries which are what you are trying to use here. If you remove the "-s" from your libraries it should work out of the box (hopefully).

If there is demand for it, I can probably add the static libraries to libsfml-dev. It's just a little "unclean" since I would have to build SFML twice to do it.

(I'm assuming you're using 15.10 / Wily here - if not, don't use libsfml-dev since its out of date)

shadowmouse

  • Sr. Member
  • ****
  • Posts: 302
    • View Profile
Re: Linking on Linux
« Reply #31 on: November 17, 2015, 12:31:07 am »
I'm using 14.04 LTS and I've installed using the source code download on the downloads page and CMake.

SeriousITGuy

  • Full Member
  • ***
  • Posts: 123
  • Still learning...
    • View Profile
Re: Linking on Linux
« Reply #32 on: November 19, 2015, 11:15:42 am »
Another side question after following your efforts: Are you compiling statically?
I'm asking cause that is not what is commonly done on a *nix-system, dynamic linking is far more common due to how libraries are handled on *nix-systems ( normally installed under /usr/lib or /usr/local/lib via package manager or make) or providing the needed libs alongside your binary and setting library path yourself via a shell script to start your application. (One of the major differences in the Linux philosophy, that's why static libs are rarely provided by binary packages)

Also one side note, do not upgrade to 14.04.2 or 14.04.3 with the new hwe-stack, this breaks some dependencies in aptitude and you are no longer able to compile sfml because of a missing opengl dependency. In 15.10 this works again, and you get a much newer kernel (4.2, especially important for newer nvidia or amd graphic cards) and GCC 5.2.0.
I cannot use 14.04 anymore because of my new graphics card (Nvidia GTX970) which requires kernel 3.17 or newer.

As a new linux aspirant I hope this helps you ;)

shadowmouse

  • Sr. Member
  • ****
  • Posts: 302
    • View Profile
Re: Linking on Linux
« Reply #33 on: November 19, 2015, 05:58:50 pm »
Yes I am compiling statically because that's what I always did on Windows and it makes things easier for me because I don't have to transfer external files. I'm on 14.04 LTS so I'll make sure to look out for .02 or .03. I only got 14.04 because that was the one that it said is generally recommended and seeing as it's my first Linux OS I thought I''d follow the guidance.

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Linking on Linux
« Reply #34 on: November 19, 2015, 09:35:28 pm »
On Linux I'd generally advice dynamic linking for the least amount of headaches.