LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   writing a game - what is the linux folder layout? (http://www.linuxquestions.org/questions/linux-general-1/writing-a-game-what-is-the-linux-folder-layout-461415/)

jarro_2783 07-06-2006 04:08 AM

writing a game - what is the linux folder layout?
 
I'm writing a cross platform game at the moment, and I'm wondering what folders I should put everything in. For windows it's fine because everything all just goes in the same folder. But for linux there's /bin and /usr/bin and /usr/share and all these other folders that I don't know what to do with. So I'm wondering what a standard way of laying out game files is (binaries, shared libraries, resources, maps, textures etc).

sudya 07-06-2006 04:22 AM

I think this might help http://www.pathname.com/fhs/pub/fhs-2.3.html

jarro_2783 07-06-2006 04:45 AM

woh, that's long. That's a great help thanks.

cs-cam 07-06-2006 08:26 PM

Could just chuck everything in the same directory as with Windows and leave it up to the packagers to put stuff in it's correct spot. This is how it's done with Nexuiz, Warsow, Tremulous, Sauerbraten, the list goes on...

It wouldn't be seen as you being slack, lots of people do it for sake of convenience. That way a distro can choose to have it in /usr/share or /opt :)

jarro_2783 07-07-2006 12:20 AM

well it's more for loading resources. If I want to load an image I might do something like:
LoadImage("res/sdk/toolbar.tga");
and that would mean the executable needs to be in the base folder.
So I could do something like have an ini file that points to all the folder paths, but even then I'd still need to know what to put in the ini.

cs-cam 07-07-2006 12:30 AM

Well I can't tell you the "best" way to do it but I can tell you that there are plenty of games being distributed that require the executable to be run from the base directory. This works as it's not hard to drop a shell script into /usr/bin that cd's to the correct location and runs the executable. Another option could be to let people pass the basedir to the executable as an option, eg.
Code:

/usr/bin/yourgame.bin -basedir=/usr/share/yourgame

jschiwal 07-07-2006 12:41 AM

The one linux game that I have is Civilization. It installs a directory /usr/local/games/CivCTP. This directory the binary and data directories needed to run. The setup program asks where you want to create the symbolic link to the binary. The options are the common directories that would be in someones path; /usr/bin/ and /usr/local/bin are the most logical.

According to the Filesystem Hierarchy Standard, the proper location would be /usr/local/bin/, however this location may not be in everyones path variable. Everyone has /usr/bin/ in their PATH so offering to create a link their would be wanted.

If you have libraries of your own, you could have a lib directory in your partition and the install program (or package system) could add the location to your library location in /etc/ld.so.conf and then run "ldconfig".

A distro's package system will usually use /usr/ as it's base directory. The /usr/local/ hierarchy is for programs that a user installs, such as from a tarball installation.

You might also check out documentation for Linux Standard Base for recommendations.

jarro_2783 07-07-2006 01:00 AM

with the libraries, is it valid to put them in /usr/local/lib?
If so, do I have to do anything to make them work, or do they just work?

jschiwal 07-07-2006 06:06 AM

On my system at least, /usr/local/lib is in my /etc/ld.so.conf. I have /usr/local/lib64 as well because I have an Amd64 in my laptop. Your install script might grep for '/usr/local/lib' in /etc/ld.so.conf and add it to the end and run "ldconfig" if it isn't found.

grep '/usr/local/lib$' || echo '/usr/local/lib/' >> /etc/ldconfig ; ldconfig
would do it.

The '/usr/local/lib' path entry will most likely exist.

jarro_2783 07-07-2006 09:00 PM

so does ldconfig just put whatever is in /etc/ld.so.conf in the library search path, so whenever you start up a program that needs one of those libraries it searches all those paths?

jschiwal 07-08-2006 04:09 AM

ldconfig takes the library locations found in ld.so.conf, and examines the headers of the libraries in those locations. From that information it may make changes to ld.so.cache which contains links to the libraries. The ld.so.cache is used by the loader when it needs to load a library.

cs-cam 07-08-2006 08:20 AM

Weighing out of this thread but again, dump it all in one directory and let the packager worry about it. Different distros do things differently and you can't cover them all.


All times are GMT -5. The time now is 03:30 PM.