Jump to content
  • Advertisement
Sign in to follow this  
Questionmark02

programming in linux

This topic is 4983 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
What about naming it test.c ?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
g++ -o out test

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Take a look at the man-page for gcc ("man gcc"). There is a -x command-line option that allows you to specify the source language. So, in your example, "gcc -x c test" would compile test as a C file.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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. :)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!