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

Author Topic: Linking on Linux  (Read 13090 times)

0 Members and 1 Guest are viewing this topic.

shadowmouse

  • Sr. Member
  • ****
  • Posts: 302
    • View Profile
Re: Linking on Linux
« Reply #15 on: November 14, 2015, 11:33:42 pm »
Well I've got libx11-xcb1, libx11-xcb1dbg, libx11-xcb-dev and libxcb1 installed according to my package manager, as well as a load of the extensions and a few other ones as well. I can't find anything else in the package manager under either xcb, x11, x11-xcb or xlib that might be helpful.

Spirro

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
Re: Linking on Linux
« Reply #16 on: November 14, 2015, 11:38:34 pm »
If you read the quote I posted again it states you have to link against:
Quote
libX11-xcb and a version of Xlib built with XCB support

Are you checking to make sure your libraries match both criteria?

shadowmouse

  • Sr. Member
  • ****
  • Posts: 302
    • View Profile
Re: Linking on Linux
« Reply #17 on: November 14, 2015, 11:44:43 pm »
Yep, just checked and they all mention both xlib and xcb.

Spirro

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
Re: Linking on Linux
« Reply #18 on: November 14, 2015, 11:48:26 pm »
I don't think I have anything else I can add here then, unless what I am reading is that you need to link to 2 libraries, not just one.  That's something you'll need to investigate to see if there is another lib file to add to your linker settings from one of those two areas.

Spirro

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
Re: Linking on Linux
« Reply #19 on: November 15, 2015, 01:57:02 am »
Ok so being the anal personally I am I just had to investigate more.  I remembered trying to static link on linux before so I tried again and of course failed.  I investigated a lot further and here is where I am stopping for now after looking at it a couple of hours.  I do no use an ubuntu variant anymore.  Previously I used mint, but run arch now.  I tried staticly compiling the source on this page:
sfml-graphics-s;sfml-window-s;sfml-system-s;OSMesa;GL;freetype;xcb-image;jpeg;udev;pthread;xcb-randr;xcb;X11;X11-xcb

I do get it to compile and link, but not work entirely.  I get the following message from the command console:

Quote
Warning: The created OpenGL context does not fully meet the settings that were requested
Requested: version = 1.1 ; depth bits = 0 ; stencil bits = 0 ; AA level = 0 ; core = false ; debug = false
Created: version = 0.0 ; depth bits = 24 ; stencil bits = 0 ; AA level = 0 ; core = false ; debug = false
sfml-graphics requires support for OpenGL 1.1 or greater
Ensure that hardware acceleration is enabled if available

I didn't investigate further because I'm hungry and it's been a while so stopping to eat and may look at it later tonight.  But for your information, this is what I send to the linker to get it to compile:

Quote
sfml-graphics-s;sfml-window-s;sfml-system-s;OSMesa;GL;freetype;xcb-image;jpeg;udev;pthread;xcb-randr;xcb;X11;X11-xcb

Hopefully this is enough information for someone better informed than I to point out the problem.  My guess is I need to check and see if I have hardware accelleration enabled and check to see why when I link I am using opengl 0.0(if that's actually true?).

Edit:  Forgot to mention that the window opens and displays at the settings dictated, but the shape is not displayed.  Hence the notation in the command window by SFML.
« Last Edit: November 15, 2015, 02:00:46 am by Spirro »

shadowmouse

  • Sr. Member
  • ****
  • Posts: 302
    • View Profile
Re: Linking on Linux
« Reply #20 on: November 15, 2015, 11:59:17 am »
I linked all the libraries that you have done (I had previously only linked the ones that it says to in the CodeBlocks tutorial), and now this has happened:

(click to show/hide)

These are my linker settings:

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: Linking on Linux
« Reply #21 on: November 15, 2015, 12:57:05 pm »
And what is the exact problem now? (post complete error messages)
« Last Edit: November 15, 2015, 12:59:42 pm by zsbzsb »
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

shadowmouse

  • Sr. Member
  • ****
  • Posts: 302
    • View Profile
Re: Linking on Linux
« Reply #22 on: November 15, 2015, 01:13:11 pm »
I did, it's under the spoiler

dabbertorres

  • Hero Member
  • *****
  • Posts: 506
    • View Profile
    • website/blog
Re: Linking on Linux
« Reply #23 on: November 15, 2015, 07:20:11 pm »
You've mixed 32bit and 64bit libraries at some point it looks like. Previously at some point though it seems. I'd do a full clean and rebuild.

Spirro

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
Re: Linking on Linux
« Reply #24 on: November 15, 2015, 07:27:28 pm »
First, let me restate I am running arch so to get things to work some, if not all, of the linker options I listed before will have different names on ubuntu distibutions.  The method I used to get things as far as I did was to compile with options:
Quote
sfml-graphics-s;sfml-window-s;sfml-system-s;freetype;jpeg;
I believe(booted to windows on the reply.)  The one difference is I probably had a mesa lib after sfml-system-s.  What would happen here  are lots of unresolved references so I would grab the one at the top of the list and search on it.  Once I found what library that reference belonged to I would include it by using this page:
http://www.sfml-dev.org/tutorials/2.3/compile-with-cmake.php
as reference to give me a good guess at where in the link order to put the added library for linking.  Now the shape was not drawn properly on my last attempt last night, but the program compiled and gave me a symptom to look in to to fix it.

Second, those errors look a lot like one of the beginning points I made in that it seems the wrong toolchain is being used.  i386 architecture tends to be 32bit and the linker is, I think, trying to use a 32bit lib with 64bit libs.  That's something you need to look in to.  If you can, start from scratch and use the method above to see if you can follow the chain of errors to figure out the right libs to include and see if that works out, but you do still need to look at the tool chain.

Personally I never liked any full ubuntu distributions.  If you like that one then get more info on it.  Particularly information on compiling from source and linking.

There is also a tool for linux called 'ldd'  look it up.  With that tool you can run it on the various SFML .so files and it will list out the dependencies that library has.  That will help you figure out what you need to link.

Edit:  dabbertorres posted while I was typing this up and backed up my thoughts that you need to check your tool chain and linked libs to find out what they are doing.

shadowmouse

  • Sr. Member
  • ****
  • Posts: 302
    • View Profile
Re: Linking on Linux
« Reply #25 on: November 15, 2015, 07:30:08 pm »
That seems to have got it working (full rebuild) except for the fact that I was relying on C++14, which the version of g++ that came with Ubuntu doesn't support, so I'll have to find out how to update that (EDIT: found out how) and then rebuild the libraries using CMake. Thanks for the information on ldd Spirro. Would it be possible to get the fact that winmm and gdi32 are only necessary on Windows and that all the other libraries have to be linked put into the codeblocks tutorial, seeing as codeblocks is multiplatform so I don't think it's right to make the tutorial only for Windows.
« Last Edit: November 15, 2015, 07:36:45 pm by shadowmouse »

Spirro

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
Re: Linking on Linux
« Reply #26 on: November 15, 2015, 08:11:51 pm »
That seems to have got it working (full rebuild) except for the fact that I was relying on C++14, which the version of g++ that came with Ubuntu doesn't support, so I'll have to find out how to update that (EDIT: found out how) and then rebuild the libraries using CMake. Thanks for the information on ldd Spirro. Would it be possible to get the fact that winmm and gdi32 are only necessary on Windows and that all the other libraries have to be linked put into the codeblocks tutorial, seeing as codeblocks is multiplatform so I don't think it's right to make the tutorial only for Windows.
winmm and gdi32 ARE Windows only.  If you want the tutorial updated for linux you will need to learn how to make a fully working compile on your distribution and submit it for review to one of the maintainers of SFML and see what happens.

I believe the reasoning behind not providing a library listing for static linking on linux is that static linking on linux is more frowned upon than on any other OS.

One of the big reasons I did not like using the ubuntu distributions is that the tool chains were a few generations behind the most current up to date tool chain(speaking mostly of gcc here, but also cmake, git, g++, etc...).  That's why I moved to arch.  There are tutorials out there to upgrade the default gcc compiler chain, but I never got them to fully work properly after upgrading.

And if you do not mind, please post what you linked to get a fully working static link on ubuntu.  I got it almost fully working.  I just need to investigate how opengl is being linked to fix the display of the 'shape' in the example tutorial code.

shadowmouse

  • Sr. Member
  • ****
  • Posts: 302
    • View Profile
Re: Linking on Linux
« Reply #27 on: November 15, 2015, 08:18:17 pm »
I've got it working now: this is the build log
(click to show/hide)
, and these are my linking settings: Please tell me if you need anything else. I had to do quite a lot of terminalling to finally get it to switch to g++-5, but it's finally compiling with -std-c++14.

Spirro

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
Re: Linking on Linux
« Reply #28 on: November 15, 2015, 08:31:40 pm »
Thank you for posting that.  It looks to me like you didn't change your linker libs from the previous post you made so the difference between arch and ubuntu is my problem.  I'll investigate it further later.

Last thing I would say is you seem to want to make a guide for using CodeBlocks.  I personally don't like CodeBlocks and if I need to use an IDE on linux I use CodeLite for a couple of reasons.

For one, CodeLite's abilities are less intrusive to me than those of CodeBlocks.  Talking about things like code completion mainly.

Second, in order to use CodeLite you need to be more familiar with your tool chain.  To me this is a good thing.  CodeBlocks automates a lot of the tool chain functions by making checkboxes to turn on/off options.  For CodeLite you need to know the command line usage of the tool chain and put those commands into CodeLite's compilation settings.  Imo this is better.  Knowing your tool chain and how it operates helps immensely in diagnosing problems that come up through compilation and allows you to use the command line when small code or quick and dirty testing code is created and a full IDE just isn't necessary.

The CodeLite does maintain a PPA for ubuntu distributions so you should be able to easily add that to your repository list to get their current build to have a look at it.

shadowmouse

  • Sr. Member
  • ****
  • Posts: 302
    • View Profile
Re: Linking on Linux
« Reply #29 on: November 15, 2015, 08:35:21 pm »
All I was saying is that there is a guide for CodeBlocks which lists what libraries you have to link to when linking statically and I was just asking that it be updated to say things like (Windows only) next to winmm and gdi32 or putting things like X11-xcb (Linux only). I just think that a library for a multiplatform IDE should give information for more than one platform.

 

anything