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

Author Topic: How to compile a binary for different Linux systems  (Read 5016 times)

0 Members and 2 Guests are viewing this topic.

ramaskrik

  • Newbie
  • *
  • Posts: 45
    • View Profile
How to compile a binary for different Linux systems
« on: February 16, 2016, 05:08:09 pm »
I have a self-set-up automatic build system for Windows and Linux on my VPS (it fetches the latest commit on master on BitBucket repo, compiles it for boh Linux and Windows and uploads it to my page).

The Windows version is linked statically (using MXE), so everything works just fine, even under Wine.

What bothers me, is the Linux version. In this case, I am linking the binary dynamically.
  • On the VPS, I have downloaded the precompiled 64-bit binaries and moved the lib/ and include/ files to the  appropriate folders.
  • On my home computer, the SFML is self-compiled, (again, I used the official stable link from the download page)


However, when trying to run the downloaded example, this pops up:
./leyes: symbol lookup error: ./leyes: undefined symbol: _ZN2sf7Texture12loadFromFileERKSsRKNS_4RectIiEE
c++filt _ZN2sf7Texture12loadFromFileERKSsRKNS_4RectIiEE
sf::Texture::loadFromFile(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, sf::Rect<int> const&)
 

I am guessing the only way of working around this is linking the SFML against the binary statically.
How do I do that? From the official tutorial it seems static SFML builds on Linux are not meant to work at all.

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: How to compile a binary for different Linux systems
« Reply #1 on: February 16, 2016, 05:30:33 pm »
Quote
From the official tutorial it seems static SFML builds on Linux are not meant to work at all.

I don't remember the exact wording used by the tutorial for Linux but it will most probably work. However, on Unixes in general, people tends to use shared libraries.

The problem you're experiencing is probably related to different c++ compiler/stdlib combination being used on your different machines (and the one used to compile SFML). Make sure the same is environment is used for compiling SFML and your application and also at runtime.
SFML / OS X developer

ramaskrik

  • Newbie
  • *
  • Posts: 45
    • View Profile
Re: How to compile a binary for different Linux systems
« Reply #2 on: February 16, 2016, 06:18:05 pm »
What about the others? Even if I can make sure the environment I am working in is the same as on VPS, I can't do that in the case of potential users. How should I make a universal build for Linux users (at least Ubuntu)?

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: How to compile a binary for different Linux systems
« Reply #3 on: February 16, 2016, 06:20:08 pm »
If you create a .deb you can specify the dependencies and therefore the runtime environment, I believe. (It's been a while since I've played with those things...)
SFML / OS X developer

ramaskrik

  • Newbie
  • *
  • Posts: 45
    • View Profile
Re: How to compile a binary for different Linux systems
« Reply #4 on: February 16, 2016, 06:24:34 pm »
OK, thanks for the info, I'll look into it.

Arcade

  • Full Member
  • ***
  • Posts: 230
    • View Profile
Re: How to compile a binary for different Linux systems
« Reply #5 on: February 16, 2016, 06:36:28 pm »
Another quick option to consider is to just bundle the appropriate SFML library files with your executable. For example, put them in a "lib" folder next to your executable and give all of those files to your users.

If you do that then you would also need to use the linker's -rpath option when building so that the runtime linker knows it should search in that directory for libraries.

ramaskrik

  • Newbie
  • *
  • Posts: 45
    • View Profile
Re: How to compile a binary for different Linux systems
« Reply #6 on: February 16, 2016, 07:42:04 pm »
Thank you Arcade, I'll use that as a temporary option.

 

anything