LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   gcc (https://www.linuxquestions.org/questions/linux-newbie-8/gcc-48915/)

Peleus 03-08-2003 07:48 PM

gcc
 
When I go into RH 8.0 Terminal I start off in my home folder (Of course). I then type in gcc to run the program but I get this....

gcc: No input files

Someone suggested I type it in like this...

gcc main.c -o programname

but I get the following message for that...

gcc: main.c : No such file or directory
gcc: no input files

I tried going into /usr/bin where gcc is and typed in gcc but I still get the no input file message. Please help :(

Dark_Helmet 03-08-2003 07:52 PM

gcc is a compiler. You give it a list of files of source code written in C (typically), then it crunches on them for a bit, and finally spits out an executable file. gcc, by itself, will not do anything.

Are you trying to install some software? What is it you're trying to do?

Peleus 03-08-2003 07:56 PM

Ok well sorry I feel like an idiot but this is basically it.

I am trying to write a program in c++. What would be the best user friendly graphical interface for writing it. I thought gcc was that program, guess not :D

Also what is g++ in that case.

Dark_Helmet 03-08-2003 08:06 PM

No need to apologize. I've asked worse in my day, I guarantee it... :)

Well...... I don't know of many graphical environments like you'd see in the windows world. If you go to Freshmeat you might be able to find something.

gcc is the standard compiler for C code.
g++ is the compiler for C++ code.

So, assuming you had a source file named myprog.cpp, and wanted to test it, you'd issue a command similar to what you were suggested earlier:

g++ myprog.cpp -o my_program

That would create an executable named my_program provided there were no syntax errors or the like.

I believe vim and emacs (very popular editors) should have a way to "hook" into a c compiler. Both also have ways to colorize text based on syntax. I've never spent thte time to figure it all out though. They might do what you need, but for big programs, you'll need to read up on make and creating Makefiles.

Dark_Helmet 03-08-2003 08:38 PM

It just so happens there's a thread in the programming forum where someone asked if there was a good editor with syntax highlighting for C and C++. Either one of the editors mentioned there will do the trick for you out-of-the-box or one of the folks reading the thread ought to be able to help customize the editor you choose. Anyway, here's the link:

http://www.linuxquestions.org/questi...threadid=48036

I also found this on freshmeat:
Anjuta

Peleus 03-08-2003 08:57 PM

Thanks to everyone so much for replying, its great, I will definately try out some of those things.

Peleus 03-08-2003 11:57 PM

Well I downloaded Anjuta, its great.

I have also done my little program and have created an output I think it is of artillery.o

How do I run this file? In normal terminal I just type in artillery.o but it comes up with bash : artillery.o : command not found

How can I run programs from the terminal? (in that current folder)

Dark_Helmet 03-09-2003 12:18 AM

Do you know what command line Ajunta used to compile the program? The reason I ask is this: g++ and gcc can output two different kinds of files. There are object files and executable files. Object files are sort of like middle-men; they aren't text source code but they aren't executables either. Look at Anjuta's options and see if you can find something along the lines of a "Compiler Command line" setting (or something similar) and post it here.

As for your problem with bash, that has something to do with your PATH environment variable. When you type a command, linux looks in a certain set of directories for the executable. Typically, the current directory is not included. So, to run a program in your current directory, you have to tell the shell explicitly. You do that by typing:
./my_program

The "./" tells it to look in the current directory.

You can try that on your file and see if it runs. If it does, then you're good to go. If not, then it's an object file like I mentioned earlier.

Peleus 03-09-2003 12:26 AM

Thank you VERY much. It worked :D I finally feel like I am at least getting a little bit on top of linux (in terms of programming a little). ./ worked if you didn't guess.

Thankyou very much again I really appreciate it :D

Dark_Helmet 03-09-2003 12:31 AM

No problem. I'm glad it's working for you. Next thing you know, you'll be hacking on the kernel... :D

Peleus 03-09-2003 12:33 AM

and re-installing the os (again).

Current complete formats and re-installs stands at 3.

Dark_Helmet 03-09-2003 12:39 AM

It'll slow down... I did the same thing. I downloaded a bunch of distributions. Tried this, trashed that, installed another distro... repeat... repeat... you get the idea. Then you get to the point where things start making sense. Then everything is right with the world... until you discover LFS. Curiosity forces you to try, and it opens up a whole new set of challenges... interesting though...

Peleus 03-09-2003 01:25 AM

Well to be perfectly honest I feel bad about posting this but anyway.

How can I start up with root access. I have all the passwords etc etc but I am trying to create a folder in /usr/home for mozilla, the default directory for install. It says I have to start up in root but I don't know how. I tried change root password to give me an oppotunity to type in the root password and now I have the little keys in the bottom right but I still can't make a new folder, anyone?

Dark_Helmet 03-09-2003 02:35 AM

From a command line, type "su -". It will then ask you for a password. Specifically, it wants root's password. When you type it in, you'll be logged in as root. Then create the directories you need with mkdir. For instance: "mkdir /usr/home/mozilla" or whatever directories you need. When you're done, type "exit" at the command line. You'll then return to being a regular user.

I don't know of any way to gain root priviledges through the file manager windows without logging on as root. I would advise against that though. It's a good idea to be only when you absolutely must be. The su command lets you become root temporarily, reducing the risk of making a catastrophic mistake from a bad command.

Peleus 03-09-2003 02:41 AM

Looks like I have to log in as root. This is because I type it in, create the directory and it all goes well. However the installer says when I try and install 'please choose somewhere else because you don't have permission'


All times are GMT -5. The time now is 11:59 PM.