Skip to main content
gamedev.net
🔒 Locked

programming in linux

Started by Questionmark02 Nov 24, 2004 at 9:23 AM 10 replies 1.9k views
Original Post
Questionmark02
Questionmark02
hey, i just recently moved to linux, so i'm no hardcore-user. however, i can't get a simple "hello world"-programm going... i was wondering if any of you guys could nudge me in the right direction... i don't know how to compile! i created a file named "test", a simple ascii-text: int main() { return 0; } that, of course, wont do nothing but should be enough of a program to compile. "gcc test" in the terminal however will tell me that the file format is not recognised. what am i supposed to do?
Questionmark02
Questionmark02
hm. seems to work...
just didn't think it would be *that* simple. ;)
i also thought that linux (and thus, it's programs as well) dont care if there is a .txt oder something at the end of a file name.
ah well.

embarrasing...
Questionmark02
Questionmark02
Quote:
Original post by Anonymous Poster
g++ -o out test

this one doesnt work. still unrecognized file format.
Kwizatz
Kwizatz
try renaming test to test.c then:

gcc test.c -o test

then run test with:

./test

GCC recognices source files by their extension, running the apropiate compiler (C,C++,fortran,java,ada,objc) and linker (ld) as needed.

because whether a file can be executed or not is not infered by its extension but rather as an attribute flag, executable files do not require an extension, datafiles most of the time do.

Cheers!
owl
owl
OP: In the near future you'll probably want to install some development enviroment for XFree (linux's graphical UI) to handle larger projects than helloworlds.

If you're a Visual Studio user, try "MinGW Studio" which is a clone of the first and doesn't needs you to write makefiles.
[size="2"]I like the Walrus best.
Questionmark02
Questionmark02
i've got anjuta now up and running. still need to get used to it a little, i guess, but it seems fine so far.
it just seemed wrong to start programming in linux without getting a simple file compiled by hand first. ;)
i'm still setting everything up on this system really. but it seems everything's stable now and i've got all i need, so i guess i should move on now and get some programming done.
thanks for all the great replies, by the way. :)
flangazor
flangazor
I disagree, owl. I think that IDE's distract. I guess they might be useful if the beginner isn't a shell or elisp hacker so he can't home brew his tools when he needs them.
supagu
supagu
i also installed anjuta seems to work although i had to fudge the includes to get it working with multiple c++ files.

i would like to know how to make Makefile's though, but there seem no good tuts on the topic. Any links fellas?

or recommended books
igni ferroque
igni ferroque
You should use extensions for files. I'm almost positive that the C specification even requires the .c extension for code files. IDE's are overrated. You can also use make filename.o or make filename to automagically run the compiler (I think this is GNU make only). The next step, of course, is learning makefile syntax. It's really easy.
Free Mac Mini (I know, I'm a tool)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.