Advertisement

gcc problem

Started by May 02, 2005 02:10 PM
15 comments, last by GameDev.net 19 years, 6 months ago
How are you running the program? If you are running it from the console window, make sure the dir tree is setup the way you want it and is being called appropriatly in the program.

If you are double clicking the file to run it, the program MAY be running from your home dir (usually /home/~username/).

This is a "problem" I have had before so that may or may not fix it.

HTH
Richard
Quote: Original post by rjhcomputers
If you are double clicking the file to run it, the program MAY be running from your home dir (usually /home/~username/).


Good point. Maybe you should check argument 0 of your main function, which is the name of the executable.

#include <stdio.h>int main(int argc, char **argv) {	printf(argv[0]);	printf("\n");	return 0;}

Advertisement
Weird, my engine has no trouble loading files with "models/tris.md2", it really sounds like you are running from a different directory than you should as someone pointed out.

I guess you are running it from inside some IDE? (KDevelop?,Anjuta?,Eclipse?).

try running it from the command line, if you do have a dir structure as nmi described all it should take is

$ ./mygame

if the executable is in a subdirectory like say src:

~/game (~/ is a shortcut for your home directory)
|
+--media
+--src

then:

$ cd ~/game
$ ./src/mygame

once you find a way to run it from the command line, try and find a way to use the same commands inside the IDE, there is usually a "working directory" you can set or something like that.
Hope that helps.
Yup I'm using KDE I will try to run from the command line and see what happens.

rjhcomputers, yup I'm running from the console window, double clicking, how do I check the dir tree is setup right.

nmi, yup that is my file structure, thanks for the path checking command, my file handling is sound well it works good with windows any way.

Thanks for all the input people I'll try all lines when I get home from work.

Thanks

Traiger
I just got the game to work via command line using

[paul@localhost paul]$ cd Pong
[paul@localhost Pong]$ ./Pong

The game still wont work unless the media folder is on /home/paul
How would I go about getting the game to work from the KDE?

Thanks for everyones input.

Traiger
Quote: Original post by traiger
I just got the game to work via command line using

[paul@localhost paul]$ cd Pong
[paul@localhost Pong]$ ./Pong

The game still wont work unless the media folder is on /home/paul
How would I go about getting the game to work from the KDE?


First - To get it to work from KDE I BELIEVE you would have to make a shortcut to it with the "Working Directory" set to ~/Pong (/home/paul/Pong).

Second - The media issue can be resolved by the following:

1) Make sure the path is like this:
~/Pong
~/Pong/media

2) When calling files from the media dir, it is a good practice IMHO to open the files up either of these ways (both are basically the same):

"./media/filename" or "media/filename"

HTH.

Richard

Advertisement
Thanks for the input RJH I will try making a shortcut with the working directory set to the correct folder and see what happens.

It would appear that there isnt and never was a problem with the folder structure or my file handling code just a problem with my zero knowledge of linux and expecting KDE/Linux to work exactly like Windows (ie really really easy).

Another question though guys. I'm having problems compiling another game with GCC.

I keep getting undefined function messages on compilation with key words such as new and delete. Looks like the compiler is getting its C and C++ confused am I right? How do I stop it?

This topic is closed to new replies.

Advertisement