🔒 Locked
programming in linux
Advertisement
Original Post
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?
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...
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...
Quote:
Original post by Anonymous Poster
g++ -o out test
this one doesnt work. still unrecognized file format.
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!
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!
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. :)
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. :)
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.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement