codeape Posted September 3, 2014 Share Posted September 3, 2014 Ok, I have experience with Linux development since before. Before I can run my Leadwerks C++ game from the command line I need to set LD_LIBRARY_PATH or add the the path to libstem_api.so in /etc/ld.so.conf.d/ or simply copy or link the lib to /usr/lib etc etc. or simply run the game from Code::Blocks. So my questions: How does this work if a game is deployed on steam. Handles steam the loading path setting to libstem_api.so? If I want to sell my game outside steam can I get rid of the libstem_api.so dependency or do I need to set the path to libstem_api.so in some bootstrap script (one of several ideas)? Thank you for all info I can get Quote Link to comment Share on other sites More sharing options...
Guppy Posted September 3, 2014 Share Posted September 3, 2014 I think this; http://www.leadwerks.com/werkspace/topic/10588-codeblocks-specify-dynamic-lib-search-path-in-cbproject/ Answers your question 1 Quote System: Linux Mint 17 ( = Ubuntu 14.04 with cinnamon desktop ) Ubuntu 14.04, AMD HD 6850, i5 2500k Link to comment Share on other sites More sharing options...
codeape Posted September 4, 2014 Author Share Posted September 4, 2014 Thank you guppy. bascially if you try to run a c++ project binary currently it will fail with "mygame: error while loading shared libraries: libsteam_api.so: cannot open shared object file: No such file or directory" now you can get around that by specifying LD_PATH=. mygame, but that is quite frankly ugly and inconvenient So please in Project -> Build options -> Linker settings -> Other linker options put -Wl,-rpath=. ( personally I use "-Wl,-rpath=sharedlibs/" to avoid causing clutter in the root dir but that's just me ) I have still some thoughts though. -Wl,-rpath= is a good option while you develop. However, -rpath will Add a directory to the runtime library search path. So if you compiled it in lets say : /home/myaccount/src/myLeadwerksgame it would add exactly that path. Am I wrong here? So if you distribute this to someone and that person puts the game in home/someone/games/myLeadwerksgame the game would still look for libsteam_api.so in /home/myaccount/src/myLeadwerksgame which will not exist on the other persons machine. Right? Quote Link to comment Share on other sites More sharing options...
Guppy Posted September 4, 2014 Share Posted September 4, 2014 Did you specify a relative path or an absolute one? if you specify a relative path ( like . or sharedlibs/ ) and do readelf -d myLeadwerksgame | grep -i rpath it should still show it as relative, no? In case it really doesn't work you could try using $ORIGIN, in order to specify that in code::blocks you need a bit of voodoo apparently; -Wl,-rpath=\\$$$ORIGIN you can make it a sub directory by changing appending /subdir/ Let me know how that works out for you Quote System: Linux Mint 17 ( = Ubuntu 14.04 with cinnamon desktop ) Ubuntu 14.04, AMD HD 6850, i5 2500k Link to comment Share on other sites More sharing options...
Guppy Posted September 4, 2014 Share Posted September 4, 2014 btw if you want to specify multiple paths it's -Wl,-rpath=path1,-rpath=path2,-rpath=ad nauseam Quote System: Linux Mint 17 ( = Ubuntu 14.04 with cinnamon desktop ) Ubuntu 14.04, AMD HD 6850, i5 2500k Link to comment Share on other sites More sharing options...
codeape Posted September 4, 2014 Author Share Posted September 4, 2014 Thanks again guppy. Well I did that and this works: ./myGame This does not: ./src/git/leadwerks/branch/branch.debug ./src/git/leadwerks/branch/branch.debug: error while loading shared libraries: libsteam_api.so: cannot open shared object file: No such file or directory I hope you see what I am doing ... being the devils advocate ... No one wants to end up with this on a released game. Quote Link to comment Share on other sites More sharing options...
Guppy Posted September 4, 2014 Share Posted September 4, 2014 Try the origin thing that should be relative to the executable Quote System: Linux Mint 17 ( = Ubuntu 14.04 with cinnamon desktop ) Ubuntu 14.04, AMD HD 6850, i5 2500k Link to comment Share on other sites More sharing options...
Guppy Posted September 4, 2014 Share Posted September 4, 2014 LD manpage for $ORIGIN So that is definitively what we want Quote System: Linux Mint 17 ( = Ubuntu 14.04 with cinnamon desktop ) Ubuntu 14.04, AMD HD 6850, i5 2500k Link to comment Share on other sites More sharing options...
codeape Posted September 4, 2014 Author Share Posted September 4, 2014 Hat off for mr Guppy ... thanks =) I can confirm that $ORIGIN works. No problems loading libsteam_api.so using any path (like ./src/git/leadwerks/branch/branch.debug or ./branch/branch.debug) However another thing that now show up is this : ./branch/branch.debug Initializing OpenGL4 graphics driver... OpenGL version 431 GLSL version 430 Device: AMD Radeon HD 5700 Series Error: Failed to load texture "Materials/Common/bfn.tex" Error: Required texture "Materials/Common/bfn.tex" is missing. Loading map "/home/codeape/src/git/leadwerks/Maps/start.map"... [s_API FAIL] SteamAPI_Init() failed; SteamAPI_IsSteamRunning() failed. [s_API FAIL] SteamAPI_Init() failed; unable to locate a running instance of Steam, or a local steamclient.so. Error: Failed to read file "/home/codeape/src/git/leadwerks/Maps/start.map". Error: Failed to load shader "./Shaders/Misc/occlusionquery.shader". So the paths to the game resources are not bullet prof. Hopefully this should easily be fixed with some path magic I have used before. However, I need to figure out where to plug it in though =) Well I will post an update about that later on this week. Quote Link to comment Share on other sites More sharing options...
Guppy Posted September 4, 2014 Share Posted September 4, 2014 It's fairly easy to fix the paths, old trick with a bit of Leadwerks flavor sprinkled on; chdir(FileSystem::ExtractDir(argv[0]).c_str()); I've no idea if it works in windows tho, I'll leave that as an excercise for the reader Quote System: Linux Mint 17 ( = Ubuntu 14.04 with cinnamon desktop ) Ubuntu 14.04, AMD HD 6850, i5 2500k Link to comment Share on other sites More sharing options...
codeape Posted September 5, 2014 Author Share Posted September 5, 2014 Now everythion works as expected: ~/src/git/leadwerks/branch> ./branch.debug ~/src/git/leadwerks/test> ../branch/branch.debug ~> ./src/git/leadwerks/branch/branch.debug All paths starts the game with loaded libsteam_api.so and all resources (textures, shaders etc.) with no errors. I added this to my Source/main.cpp: @@ -93,6 +93,9 @@ int main(int argc,const char *argv[]) } #endif App* app = new App; +#ifdef __linux__ + FileSystem::SetDir(FileSystem::ExtractDir(argv[0])); +#endif if (app->Start()) { while (app->Loop()) {} The code added is the ifdef __linux__ stuff ... to be precise. Thank you again Guppy. Awesome teamwork =) Quote Link to comment Share on other sites More sharing options...
codeape Posted September 5, 2014 Author Share Posted September 5, 2014 Extending resource file path fix to windows (it had the same problem) #ifdef __linux__ FileSystem::SetDir(FileSystem::ExtractDir(argv[0])); #else HMODULE hModule = GetModuleHandle(NULL); if (hModule != NULL) { char exePth[MAX_PATH]; GetModuleFileName(hModule, exePth, MAX_PATH); FileSystem::SetDir(FileSystem::ExtractDir(exePth)); } #endif 1 Quote Link to comment Share on other sites More sharing options...
MoustafaChamli Posted September 8, 2014 Share Posted September 8, 2014 So, I added the suggested $ORIGIN to the codeblocks linker settings, but I'm still seeing the error with libsteam_api.so when I try to run the game as a standalone project. I tried adding the code used by codeape to #ifdef __linux__, and that doesn't seem to have an effect either. Quote Link to comment Share on other sites More sharing options...
codeape Posted September 8, 2014 Author Share Posted September 8, 2014 Hello MoustafaChamli Ok so you must pick the top of the tree in the Project -> Build options -> Linker settings tree so you target both debug and release (it has the project name ... in my case branch). You must add the flags to "Other linker options" ... see the red markings I made in the image. Be sure to recompile the whole project! Quote Link to comment Share on other sites More sharing options...
MoustafaChamli Posted September 9, 2014 Share Posted September 9, 2014 Hello codeape, Thanks for the response! It doesn't seem to work here, even after recompiling the full project and updating the project files. This might be relevant, but Leadwerk had generated an ifdef __linux__, my main.cpp currentl has these lines: #ifdef __linux__ FileSystem::SetDir(FileSystem::ExtractDir(argv[0])); #else HMODULE hModule = GetModuleHandle(NULL); if (hModule !=NULL) { char exePth[MAX_PATH]; GetModuleFileName(hModule, exePth, MAX_PATH0); FileSystem::SetDir(FileSystem::ExtractDir(exePth)) } #endif #ifdef __linux__ #ifndef __ANDROID__ settingsdir = settingsdir + "/." + String::Lower(settingsfile); #else settingsdir = settingsdir + "/" + settingsfile; #endif #else settingsdir = settingsdir + "/" + settingsfile; #endif Maybe that's not helping the compilation? I can see libsteam_api.so in the project's root directory, so it's definitely not a case of a missing file. Any ideas? Quote Link to comment Share on other sites More sharing options...
Guppy Posted September 9, 2014 Share Posted September 9, 2014 Did you actually rebuild? what does readelf -d yourgameexe | grep -i rpath write? Quote System: Linux Mint 17 ( = Ubuntu 14.04 with cinnamon desktop ) Ubuntu 14.04, AMD HD 6850, i5 2500k Link to comment Share on other sites More sharing options...
MoustafaChamli Posted September 10, 2014 Share Posted September 10, 2014 Hello, sorry for the long reply. I did actually rebuild. This is what the command outputs: 0x000000000000000f (RPATH) Library rpath: [$ORIGIN] Quote Link to comment Share on other sites More sharing options...
Guppy Posted September 10, 2014 Share Posted September 10, 2014 Hello, sorry for the long reply. I did actually rebuild. This is what the command outputs: 0x000000000000000f (RPATH) Library rpath: [$ORIGIN] In that case there remains two possible error causes; libsteam_api.so is NOT in the same directory as your executable ( or is broken, try replacing it with the with one from a fresh project ) Your missreading the error and what you see is just the "no running steam instance found" message Quote System: Linux Mint 17 ( = Ubuntu 14.04 with cinnamon desktop ) Ubuntu 14.04, AMD HD 6850, i5 2500k Link to comment Share on other sites More sharing options...
MoustafaChamli Posted September 10, 2014 Share Posted September 10, 2014 It turns out libsteam_api.so isn't copied into the directory when I build the project, which is a bit of an annoyance. But it seems to work when I copy libsteam_api.so to the published project's root directory. Quote Link to comment Share on other sites More sharing options...
codeape Posted September 10, 2014 Author Share Posted September 10, 2014 It turns out libsteam_api.so isn't copied into the directory when I build the project, which is a bit of an annoyance. But it seems to work when I copy libsteam_api.so to the published project's root directory. Try to update your project with the in editor tool project manager. It should add the correct libsteam_api.so file. I had the same problem. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.