Portability

  • 1 Replies
  • 151 Views
Portability
« on: 08 December 2019, 19:44:02 »
I have a project that I want to test on another Linux pc and I don't have access as a user on that computer to install the dependencies and the single idea that comes to my mind is to link statically, but the only way to obtain thoose libs is to compile sfml from source, but sfml-git package is not required by tgui-git and so on. Do you have an idea on what I can do?

*

texus

  • *****
  • 1539
    • View Profile
    • Texus's Blog
Re: Portability
« Reply #1 on: 08 December 2019, 20:12:39 »
Quote
sfml-git package is not required by tgui-git
The tgui-git package requires "sfml" as a dependency, this can either be the actual "sfml" package or the "sfml-git" package. Either one has to be installed in order to install "tgui-git". If neither is installed, the "sfml" package will be installed as dependency when trying to install "tgui-git".

You should however not rely on "sfml-git" nor "tgui-git" at all for any project that you have to show somewhere else. Although it is unlikely to happen, the git version could be broken when I put a newer version online and make some mistake in the code. Although I will likely know about it as the CI will fail, there would be a period where the git version doesn't compile at all and you wouldn't be able to install your project at such time. The "sfml" and unofficial "tgui" packages would be a safer choice.

Quote
I don't have access as a user on that computer to install the dependencies
I'm not sure why you are mentioning the sfml-git and tgui-git packages, as I don't see how you would be able to use them in this case.

I have no experience with static linking on linux so I can't help you with that.
I have however been in the scenario where I needed to run a program on a pc without root access. The solution I used was to simply build the dependencies from source on the destination pc. This is of course only possible if gcc and cmake are preinstalled, but that was the case for me. Thinking about it now, I think that SFML was preinstalled, I only had to build TGUI which made the task significantly easier.

First of all you need to find out if you can build SFML on that computer. While TGUI only has SFML as a dependency, SFML has a lot of other dependencies that may not be preinstalled. If you can't build SFML from source (even dynamically) then you have to find another solution (it is possible to run a linux executable on a different pc than it was build on with some care, even when linking dynamically).

Assuming you can build SFML, and assuming you are using cmake for your own project, the easiest solution would probably be to include SFML and TGUI as subfolders to your project and build them together with your project. I haven't actually done this myself, but I know it can work (with some caveats as you will probable have to manually tell TGUI where to find SFML). This way your project can link to the SFML and TGUI targets that were just build and cmake hopefully takes care of finding the libraries even when dynamic linking. If not, you can either overwrite the linker search path when executing the program by setting some environment variable, or link the project with $ORIGIN in the rpath, but you will have to see when you get to this point.

If you get stuck somewhere I might be able to help further, but you may have to experiment a bit yourself first.