How to set compilation on linux support rpath?

hello, I am a noob linux user, and pool english.
I want to compile a portable version to play after I being back home.
I think a relocatable path version is very convenient when I cannet connect Internet.
how to?
thanks!

here I have some thinking, I dont know if mine is right.
In Linux, if I set -DCMAKE_INSTALL_PREFIX while building, the program will be installed in a absolute path.
If I move the path to another path, the program cannot find gamedata, so an error display:

Resource with name CONFIG/FILESYSTEM and type TEXT wasn't found.
terminate called after throwing an instance of 'std::runtime_error'
  what():  Resource with name CONFIG/FILESYSTEM and type TEXT wasn't found.
Aborted

thus, you can create a vcmi.sh in root path of program,then add these codes:

#/bin/bash
export LD_LIBRARY_PATH=./lib/vcmi:./lib/vcmi/AI:$LD_LIBRARY_PATH
export XDG_DATA_DIRS=./share:$XDG_DATA_DIRS
./bin/vcmiclient 

Then if you run vcmi.sh, the terminal display

 xiaoji@debian:~/桌面/vcmi$ sh vcmi.sh
Starting... 
Creating console and configuring logger: 5
The log file will be saved to "/home/xiaoji/.cache/vcmi/VCMI_Client_log.txt"
	 Initialization: 7
	 Data loading: 2
	Mod handler: 0
	 Mod filesystems: 10
Basic initialization: 20
Initialized logging system based on settings successfully.
Error: Heroes III data was not found!
terminate called after throwing an instance of 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::lock_error> >'
  what():  boost: mutex lock failed in pthread_mutex_lock: Invalid argument
Aborted

I think you can likely set XDG_DATA_HOME, XDG_CONFIG_HOME and XDG_CACHE_HOME to make sure everything is in same directory. Then you can use strace to check where game is looking for files:

strace -e open ./vcmiclient

Then it’s will be easier to find out why it’s not working.

thanks,it is happy to work!


After I use my chinese verion original Heroes3:WOG files,it display:
very thanks!


Can you please share script you end up with for everyone?
As well as used commands to build it. Thanks.

PS: I want to have daily builds for Linux with Steam Runtime one day.

OK, that is my things should be done

but there has display a error:
when I click singleplay-begin, it appera:

sh: 1: /home/vcmi/bin/vcmiserver: not found
Error: server failed to close correctly or crashed!

when I run the vcmiserver in terminal, it appera:

terminate called after throwing an instance of 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::bad_any_cast> >'
  what():  boost::bad_any_cast: failed conversion using boost::any_cast
./vcmiclient.sh: 行 6:  7941 已放弃               vcmiserver

this is the strace output file:
output.txt (224 KB)

Unfortunately this is normal. Server don’t have option to be manually started.

To make server start properly it’s will likely be enough to add your directory into PATH:

export PATH=$PATH:/home/login/vcmi-build

I have tried, but it seems cant effective.
I think I should modified the cmake file.

Just want to reply to this topic because recently I finally implemented options to run VCMI from single directory.
It’s enabled on both macOS and Linux when following files / directories are present:

config Mods AI vcmiclient vcmiserver

Also on Linux VCMI running from single directory won’t try to read any assets from /usr.