Advertisement

GCC and linux

Started by October 19, 2000 09:19 PM
8 comments, last by Tsu 23 years, 11 months ago
I''m used to using the windows based djgpp, and compiling it to an executable (.exe), and then just double clicking on it to run it in windows, but since i went over to linux, this doesn''t exactly work... i''m just a beginer when it comes to linux, and am not sure linux even knows what an exe is... i compile my program: gcc idno.c -o idno.exe and then go to run it, and it doesnt do anything. the only way i can run it is right click, open with (or whatever it says) and then check ''run in console'', and then it almost runs it (it closes the console, but i can fix that by telling the program to wait, i''m just testing this with a hello word program...). so then my question is: 1. what extension to i compile it to? or 2. what is the command to compile it in linux / unix or 3. how do i tell linux (mandrake / redhat) to automatically load up exe''s in the console... -Tsu
It sounds more like you''re having more of a window manager problem than a true linux problem. If you mention which window manager you''re using it might help. However, I''d have to say it''s far easier if you''re using gcc, to just open a terminal window and use the command line. Especially if using a shell that has the up arrow implemented as a history.

You can compile your executable to any extension. However, the convention for executable binaries in *nix is no extension.

Advertisement
Hey, SiCrane is back!

As SiCrane said, an executable can have any extension, as long as it has the execute bit set in the permissions. gcc does this automatically. When you've compiled a program:

gcc idno.c -o idno

You run it like so:

./idno

(I'm assuming you're using a bash shell, which you probably are).

Edited by - Muzzafarath on October 20, 2000 2:02:58 PM
I'm reminded of the day my daughter came in, looked over my shoulder at some Perl 4 code, and said, "What is that, swearing?" - Larry Wall
oops, i guess it would''ve helped if i mentioned what softare i''m using... i''m using KDE on linux mandrake 7, and yes i use the bash shell. thanks for the help guys...
For all you Linux newbie developers, i want to recommend a couple books, if you''re into the dead-tree kinda learning...



  • A Practical Guide To Linux by Mark G. Sobell. This one''s out of print, but i think a newer version is still floating around... Go to your favorite book retailer and look up Sobell.

    This is a great guide to using Linux in the UNIX tradition (rather than just pretending it''s Windows). You''ll learn a great deal about the GNU tools and it has a WONDERFUL reference in the back. I only wish the man pages were that helpful.
  • Programming with GNU Software by Loukides & Oram (published by O''Reilly). Not a guide to Linux, but actually just a guide to developing with GNU tools. Good for if you''re just starting to get comfortable with Linux, but want to know how to develop with the traditional tools. Very good starting material, though it doesn''t cover anything in-depth, it''s probably enough depth for most needs. The one exception is that it leaves out CVS, covering RCS, instead, but if you want CVS info...
  • Open Source Development with CVS by Karl Fogel. Half of this one''s on the web, and it''s the half that deals with CVS, so unless you really want some reading on managing an open source project, just get the web version. It''s good stuff.



Hope this helped.


-benc
The CVS book can be found here btw.
I'm reminded of the day my daughter came in, looked over my shoulder at some Perl 4 code, and said, "What is that, swearing?" - Larry Wall
Advertisement
Just a little correction here.

as Muzzafarath said, you compile like so:

gcc idno.c -o idno

and you run, if you''re logged in as root by doing:

./idno

and if you''re logged in as a normal user, you would do:

idno

and it will run.



Cyberdrek
Headhunter Soft
DLC Multimedia
[Cyberdrek | ]
Actually, it won't for me (and probably for other people as well). The distribution you're using (probably) set up ./ to be in your PATH if you're a "normal" user, but not for root. SuSE 6.4 didn't do that for me.

Edited by - Muzzafarath on October 21, 2000 8:43:55 AM
I'm reminded of the day my daughter came in, looked over my shoulder at some Perl 4 code, and said, "What is that, swearing?" - Larry Wall
same in slackware 7.0.
no matter what user you are, you gotta run it as ./idno

saai

p.s. for the newbies.. dont use root whenever possible
i accidentally deleted all my init scripts once cause I
was using root all the time
It''s also good practice to run programs as ./progname. Otherwise if a program with the same name exists in the path before the current working directory, it could be run first depending on the search order. There was one instance of a prankster on a unversity unix cluster putting a program called "a.out" in the /bin directory, that did nothing but core dump. Consequently all the students who were trying to do their first programming assignment spent a *very* long time trying to debug their programs.

This topic is closed to new replies.

Advertisement