<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Linux programming...</title>
		<link>http://www.allegro.cc/forums/view/589384</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Wed, 03 Jan 2007 07:12:44 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Ok...I&#39;ve never actually did any linux programming before, but I made my project multiplatform as I could. Everything compiles just fine, and I can even run the resulting executeable while in Code Blocks....but when I try to run the program from within KDE it trys to open a window and closes down with no error message or anything <img src="http://www.allegro.cc/forums/smileys/shocked.gif" alt=":o" />! I use GFX_AUTODETECT_WINDOWED...I read in the manual that the accelerated drivers require root access...how do I do that so my end users can have accelerated graphics? I don&#39;t know if that is the problem, but seems likely to me...any suggestions or comments on this would be a great help...::)</p><p>Thanks to all,<br />Donald
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Don Freeman)</author>
		<pubDate>Tue, 02 Jan 2007 23:13:31 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Run it from a terminal and it will probably say &quot;Shutting down Allegro due to signal number 11&quot;. Find out what file you aren&#39;t checking fails to load, and fix the problem <img src="http://www.allegro.cc/forums/smileys/wink.gif" alt=";)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (CGamesPlay)</author>
		<pubDate>Tue, 02 Jan 2007 23:27:36 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
but when I try to run the program from within KDE it trys to open a window and closes down with no error message or anything <img src="http://www.allegro.cc/forums/smileys/shocked.gif" alt=":o" />!
</p></div></div><p>
It tries to open a file, but this fails. Make sure the program looks for the file in a sensible location (such as the location of the executable, for instance), not just the current directory.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
I read in the manual that the accelerated drivers require root access...how do I do that so my end users can have accelerated graphics?
</p></div></div><p>
<i>You</i> don&#39;t. The adminstrator has to install the program in such a way that it runs with root privileges (&quot;suid root&quot;).</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
I don&#39;t know if that is the problem
</p></div></div><p>
No.</p><p>EDIT (from below)
</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
it seg faults with 11
</p></div></div><p>
Actually, signal 11 means a segmentation fault.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Evert)</author>
		<pubDate>Tue, 02 Jan 2007 23:32:29 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>See that is what I thought might also be the problem (trying to load an image, but fails)...the program looks for the GFX/ folder in the current directory to get it&#39;s graphics...I even changed the code so it would just load from the current directory...same thing!</p><p>Edit:<br />Found how to run the console command...been a while since I used linux...::)<br />Yeah...it seg faults with 11...so it&#39;s not looking for the right file, but why does it work from CodeBlocks?</p><p>Edit #2:<br />Ok...this is even weirder...it runs from CodeBlocks and the console using ./War but when I click the icon in KDE...it doesn&#39;t actual continue to load!? WTF!</p><p>Edit #3:<br />I attached the zip...it contains the executable and the graphics...
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Don Freeman)</author>
		<pubDate>Tue, 02 Jan 2007 23:35:56 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>#2<br />in linux you have to set the current path by yourself - this is code i&#39;m using:
</p><div class="source-code snippet"><div class="inner"><pre><span class="p">#ifndef _WIN32</span>
<span class="k1">char</span> path <span class="k2">[</span><span class="n">128</span><span class="k2">]</span><span class="k2">;</span>
<a href="http://www.allegro.cc/manual/get_executable_name" target="_blank"><span class="a">get_executable_name</span></a><span class="k2">(</span>path,<span class="n">128</span><span class="k2">)</span><span class="k2">;</span>
<a href="http://www.allegro.cc/manual/replace_filename" target="_blank"><span class="a">replace_filename</span></a><span class="k2">(</span>path,path,<span class="s">""</span>,<span class="n">128</span><span class="k2">)</span><span class="k2">;</span>
<a href="http://www.delorie.com/djgpp/doc/libc/libc_92.html" target="_blank">chdir</a><span class="k2">(</span>path<span class="k2">)</span><span class="k2">;</span>
<span class="p">#endif</span>
</pre></div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Frank Drebin)</author>
		<pubDate>Wed, 03 Jan 2007 00:34:37 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
in linux you have to set the current path by yourself - this is code i&#39;m using:
</p></div></div><p>This has nothing to do with Linux versus Windows, and it&#39;s wrong <img src="http://www.allegro.cc/forums/smileys/rolleyes.gif" alt="::)" /></p><p>The path is the same as the path you were at when you ran the program. If you ran it from the same directory (&quot;./program&quot;), the CWD will be that directory.</p><p>Don: Use a log file to find out which bitmap fails to load.</p><p>[append]<br />I like this idea better, actually:
</p><div class="source-code snippet"><div class="inner"><pre><a href="http://www.delorie.com/djgpp/doc/libc/libc_351.html" target="_blank">freopen</a><span class="k2">(</span><span class="s">"output.txt"</span>, <span class="s">"w"</span>, stdout<span class="k2">)</span><span class="k2">;</span>
<a href="http://www.delorie.com/djgpp/doc/libc/libc_351.html" target="_blank">freopen</a><span class="k2">(</span><span class="s">"errors.txt"</span>, <span class="s">"w"</span>, stderr<span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>Put that in main, run the program, and check those files.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (CGamesPlay)</author>
		<pubDate>Wed, 03 Jan 2007 00:48:09 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
The path is the same as the path you were at when you ran the program. If you ran it from the same directory (&quot;./program&quot;), the CWD will be that directory.
</p></div></div><p>

</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
in linux you have to set the current path by yourself
</p></div></div><p>

Both wrong, in linux the working directory is (AFAIK) the home directory of the current user.<br />The code written by Frank Drebin should work perfectly.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (psycho)</author>
		<pubDate>Wed, 03 Jan 2007 01:09:45 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Both wrong, in linux the working directory is (AFAIK) the home directory of the current user.
</p></div></div><p>
Wrong again.<br />The current working directory (CWD) defaults to the CWD of the parent process. If launching from a a file manager, this could very well be the user&#39;s home directory; if you run it from a terminal, it&#39;s normally fairly obvious what the CWD is.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
The code written by Frank Drebin should work perfectly.
</p></div></div><p>
Yes. Except that you normally need the exact same code in Windows too.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Evert)</author>
		<pubDate>Wed, 03 Jan 2007 01:18:49 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
The adminstrator has to install the program in such a way that it runs with root privileges (&quot;suid root&quot;).
</p></div></div><p>

Are you serious? <img src="http://www.allegro.cc/forums/smileys/shocked.gif" alt=":o" /><img src="http://www.allegro.cc/forums/smileys/shocked.gif" alt=":o" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Michael Faerber)</author>
		<pubDate>Wed, 03 Jan 2007 01:20:46 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Evert:<br />That totally makes sense! But how would you know at runtime what the CMD would be? I want to keep this as portable as possible, but I am just learning how the linux system is setup and what is stored where...also...at least on my machine, you are correct Evert. The CMD is set to the users home. I copyed the files there and it ran just fine!
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Don Freeman)</author>
		<pubDate>Wed, 03 Jan 2007 01:47:20 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Hmmm. The Mac version of Allegro sets the cwd to be the resources folder of your application bundle (or an Allegro-specific subdirectory of it if that exists), would it make sense to have the other platforms automatically set the cwd to wherever the executable is so that behaviour is &quot;uniform&quot; across platforms in the sense that it sets the cwd to be where your data files probably are?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Harte)</author>
		<pubDate>Wed, 03 Jan 2007 01:53:58 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
But how would you know at runtime what the CMD would be?
</p></div></div><p>
<span class="source-code"><a href="http://www.delorie.com/djgpp/doc/libc/libc_386.html" target="_blank">getcwd</a></span></p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
would it make sense to have the other platforms automatically set the cwd to wherever the executable is so that behaviour is &quot;uniform&quot; across platforms in the sense that it sets the cwd to be where your data files probably are?
</p></div></div><p>
Probably not.<br />For one thing, this breaks current programs (so it breaks the API), for another, at least on UNIX system, exectables are normally not kept in the same location as the game&#39;s datafiles, so it wouldn&#39;t be the proper analogue. It will also make it harder to write programs that take a filename from the commandline.</p><p>The MacOS X port is special in this, but I think that makes sense, since the concept of application bundles is also MacOS X specific (and something I actually quite like).</p><p>EDIT
</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
I want to keep this as portable as possible
</p></div></div><p>
Then you should definately include that code; as I said, it&#39;s generally also nescessary in Windows.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Evert)</author>
		<pubDate>Wed, 03 Jan 2007 02:32:28 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Since we&#39;re on the subject of application bundles, how come you cant load the special &quot;#&quot; datafile when your executable is in an application bundle?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (ImLeftFooted)</author>
		<pubDate>Wed, 03 Jan 2007 03:30:02 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>My guess is that it&#39;s looking for the game executable in the resource directory of the application bundle and fails to find it (thus failing to load the embedded datafile), but that&#39;s just a random guess (yes, I&#39;m saying that&#39;s a bug).<br />On the other hand, if your program is in a bundle, why do you need to append the datafile to the executable in the first place?</p><p>EDIT: For got to reply to this before
</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Are you serious?
</p></div></div><p>
In that the administrator has to install the program to use root privileges rather than the user just telling it to? Of course I am, it wouldn&#39;t make sense otherwise.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Evert)</author>
		<pubDate>Wed, 03 Jan 2007 03:44:46 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
why do you need to append the datafile to the executable in the first place?
</p></div></div><p>
Because you&#39;re porting your game over from windows and would prefer to maintain the same build system.  That and maybe you want to make your game data just a bit harder for someone to reverse engineer.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (ImLeftFooted)</author>
		<pubDate>Wed, 03 Jan 2007 05:20:33 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Because you&#39;re porting your game over from windows and would prefer to maintain the same build system.
</p></div></div><p>
Can&#39;t do that anyway; linking options are already different and Windows doesn&#39;t know about application bundles in the first place.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Evert)</author>
		<pubDate>Wed, 03 Jan 2007 05:24:35 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>It was easy to add new options to my build system for OSX, but to change the location of the datafile requires me to write new code to handle that and make other weird changes to my build system that don&#39;t fit well with the other OS&#39;s build system stuff.</p><p>But I&#39;ve already done it all anyway.  I just think it would be cool if &quot;#&quot; worked.  After all, the docs do say it does.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (ImLeftFooted)</author>
		<pubDate>Wed, 03 Jan 2007 07:01:31 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
I just think it would be cool if &quot;#&quot; worked. After all, the docs do say it does.
</p></div></div><p>
As I said, it&#39;s a bug.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Evert)</author>
		<pubDate>Wed, 03 Jan 2007 07:12:44 +0000</pubDate>
	</item>
</rss>
