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'

Peleus 03-09-2003 02:45 AM

Never mind, dark your a life saver. thanks so much for helping me out through all this.

I sorted out the problem by doing everything through the terminal rather then login on the terminal and trying to finish it in the GUI.

Now to figure out how to uninstall 1.0.1 and make 1.2.1 defult web browser *shudders*

Dark_Helmet 03-09-2003 02:57 AM

So, it's installed then? Great! I had a whole spiel about permissions lined up and ready to go... :)

Installing software from source code is usually done as root. That said, most people will install it from the command line like:
su -
<password>
./configure
make
make install
exit

Well, that's how I do it anyway...

Peleus 03-09-2003 03:17 AM

How uabout uninstalling? For instance I now have both mozilla 1.0.1 and 1.2.1 installed.

I am worried about the fact if I remove 1.0.1 (default browser) it will leave all the programs with nothing rather then changing to 1.2.1

kayhan 03-09-2003 09:36 AM

You should also be root when you run the java installer. That is, try
Code:

su -
mkdir /home/mozilla/javawhatever
./javainstall


kayhan 03-09-2003 09:37 AM

Whoops! You already figured that out! Guess I should have read to the end of the thread before replying. :-)

Dark_Helmet 03-09-2003 11:03 AM

Uninstalling is trickier, especially when you install a new version on top of an older version. What distribution are you using? Red Hat? Mandrake? It will influence how you go about doing this.

Peleus 03-09-2003 02:32 PM

Redhat 8.0

Dark_Helmet 03-09-2003 03:45 PM

If you want to keep mozilla 1.0.1, don't do this!

Ok, start up your package manager:
1) From the menu bar, select System Settings -> Packages
2) It'll ask for root's password
3) Under the Application group, select "details" for Graphical Internet
4) Scroll down and uncheck everything regarding mozilla
5) Click Update
6) Click Quit

Now, you need to go and reinstall mozilla 1.2.1. Go to the command line, "su" to root, and run through the make, make install steps again. Then you should be able to kick off mozilla like normal.

---

As for having it become the "default" browser, I haven't really looked into that myself. I would guess you need to snoop around in the file association stuff:

menu bar -> preferences -> file types and programs

That's only a guess though...

lynch 03-09-2003 05:05 PM

I dont know about "default browser" like in windows.But you can have Mozilla start automatically ,depending on what you use to connect.Both kinternet and kppp will start Mozilla whenever you connect if you tell it to.
In kinternet you right click the icon,go to settings and choose "execute script"and type mozilla.
In kppp you have a setting where you enter the command mozilla.
lynch

Peleus 03-10-2003 01:51 AM

Well lol, now we got that solved time for another question.......

(You know you love it)

I can't install any .xpi *Mozilla browser install file* for add on's because it says I don't have write access. I tried logging into su - but it didn't work.

http://optimoz.mozdev.org/gestures/installation.html#

thats the file I am trying to install.

Any ideas? Thanks for all your help so far though.

Dark_Helmet 03-10-2003 01:56 AM

Typing "su -" at a terminal doesn't give you root access everywhere; it gives you root access in that terminal. So, if you were to launch an application from the menu, then you would be launching it as a regular user. When programs are started, they inherit the permissions of the user that started them. In this case, the Gnome environment still sees you as a regular user, and give Mozilla those permissions. Now, if you were to start mozilla from the command line AFTER issuing "su -", then mozilla would be started with root permissions. So, that's what you need to do. From the command line, type "mozilla", download and install the plugin, exit mozilla, and then exit from su on the command line.

Make sense?

Peleus 03-10-2003 02:22 AM

Crystal, thanks for that.

on another note now it says its installed, reboot browser to continue, load it up but it isn't installed :(

Oh well had this problem before I will figure it out eventually.

Thanks for that.


All times are GMT -5. The time now is 06:40 AM.