LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 07-06-2006, 03:08 AM   #1
jarro_2783
LQ Newbie
 
Registered: Jul 2006
Posts: 11

Rep: Reputation: 0
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).
 
Old 07-06-2006, 03:22 AM   #2
sudya
LQ Newbie
 
Registered: Mar 2005
Location: CA
Distribution: SuSE, Debian
Posts: 27

Rep: Reputation: 15
I think this might help http://www.pathname.com/fhs/pub/fhs-2.3.html
 
Old 07-06-2006, 03:45 AM   #3
jarro_2783
LQ Newbie
 
Registered: Jul 2006
Posts: 11

Original Poster
Rep: Reputation: 0
woh, that's long. That's a great help thanks.
 
Old 07-06-2006, 07:26 PM   #4
cs-cam
Senior Member
 
Registered: May 2004
Location: Australia
Distribution: Gentoo
Posts: 3,545

Rep: Reputation: 57
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
 
Old 07-06-2006, 11:20 PM   #5
jarro_2783
LQ Newbie
 
Registered: Jul 2006
Posts: 11

Original Poster
Rep: Reputation: 0
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.
 
Old 07-06-2006, 11:30 PM   #6
cs-cam
Senior Member
 
Registered: May 2004
Location: Australia
Distribution: Gentoo
Posts: 3,545

Rep: Reputation: 57
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
 
Old 07-06-2006, 11:41 PM   #7
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
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.
 
Old 07-07-2006, 12:00 AM   #8
jarro_2783
LQ Newbie
 
Registered: Jul 2006
Posts: 11

Original Poster
Rep: Reputation: 0
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?
 
Old 07-07-2006, 05:06 AM   #9
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
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.
 
Old 07-07-2006, 08:00 PM   #10
jarro_2783
LQ Newbie
 
Registered: Jul 2006
Posts: 11

Original Poster
Rep: Reputation: 0
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?
 
Old 07-08-2006, 03:09 AM   #11
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
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.
 
Old 07-08-2006, 07:20 AM   #12
cs-cam
Senior Member
 
Registered: May 2004
Location: Australia
Distribution: Gentoo
Posts: 3,545

Rep: Reputation: 57
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.
 
  


Reply

Tags
folder, layout, program



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
anonymous folder writing with vsftpd thomas.jt Linux - Networking 3 10-31-2005 08:18 PM
writing windows share folder boToo Linux - Newbie 2 06-09-2005 10:30 AM
Writing to a shared home folder confused_bof Linux - Networking 5 05-18-2004 06:50 AM
Directory/Folder Layout TJandE Linux - Newbie 4 03-30-2004 10:02 PM
Petitioning game companies and writing to them MNKyDeth1 Linux - Games 3 10-08-2003 02:32 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:13 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration