LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat
User Name
Password
Red Hat This forum is for the discussion of Red Hat Linux.

Notices


Reply
  Search this Thread
Old 08-06-2004, 08:22 AM   #1
madh@ter
LQ Newbie
 
Registered: Aug 2004
Distribution: Redhat 9.0 & Knoppix STD
Posts: 7

Rep: Reputation: 0
Question Young studant in need of assistance with c compiling using gcc


Hello,

I recently purchased redhat 9.0 Professional Workstation one of the reasons beeing is that its open source and includes a graphical interface. Ive been told that another advantage of linux is that it is very easy to compile c using the command line. However not for me . When I startup using failsafe Im presented with the command line all good and well... I entered the following command and was given this response:

[username@localhost username] dir

file.c

[username@localhost username] gcc -o examplename file.c
gcc: file.c : No such file or directory



As you can see the c file is in the current directory, maybe Im using the wrong parameters???

The version of gcc im using is 3.2 with enhancements

Have I overlooked something? your assistance would be very much helpful

Thank you.
 
Old 08-06-2004, 09:38 AM   #2
rjlee
Senior Member
 
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,994

Rep: Reputation: 76
I don't recommend that you try compiling in failsafe as it tends not to set up various environment parameters etc. that you might need.

You can press Ctrl+Alt+F1 to get to a text console while running normally (usually F1 through F6 are text consoles and F7 is graphical). Alternatively, you can give “3” at the boot prompt (or run “/sbin/telinit 3” while running) to move into a text console. Or, you can use a terminal emulator like aterm, xterm or konsole to get a text prompt inside a graphical login session.

The command you are using is right, and should work provided that you have GCC installed, it is on your $PATH, and it can find your C libraries (I think that's controlled by $LDPATH, but I may be wrong).

Hope that's of some help,

— Robert J. Lee
 
Old 08-06-2004, 10:01 AM   #3
madh@ter
LQ Newbie
 
Registered: Aug 2004
Distribution: Redhat 9.0 & Knoppix STD
Posts: 7

Original Poster
Rep: Reputation: 0
Thanks for the suggestion rjlee, the crtl+alt+f1 worked fine, however when I tried that same command, I got the same response! and as for whether gcc is installed or not, surely I would get "command not recognised" instead. The c file was writen within the windows environment using notepad then transfered to Linux could this have anything to do with the problem. I am completly clueless and would appriciate any idea. Thanks.
 
Old 08-09-2004, 03:12 PM   #4
rjlee
Senior Member
 
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,994

Rep: Reputation: 76
It looks like you have a gcc executable on your path, but it can't find something else that it needs.

Make sure that test.c exists and is a regular file (
Code:
 ls -l file.c
the first character should be a hyphen)

Now try and preprocess the file
Code:
cpp test.c
This should spew out a whole lot of C-esque stuff (your preprocessed program).

Now try and compile it without linking
Code:
gcc -c test.c
Now try and link it
Code:
gcc test.o -o test
At what stage does it fail? If you can't preprocess, you probably don't have libc-devel (the C library header files) installed properly. Otherwise, you don't have cpp (the c preprocessor) installed; this probably means you have a messed-up gcc installation.

If it won't link then you're missing part of libc itself. Possibly you only installed the static libraries; try again with the -static flag.

Another test you can do is to run
Code:
ldd `which /usr/bin/gcc`
to see if your gcc executable has any unmet library dependencies you need to install. (Note that ` is a backtick, not an apostrophie. To the left of the 1 key and above Tab on most keyboards).
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Compiling using gcc Damitha Mandriva 1 12-17-2004 05:11 AM
Kernel compiling: gcc-3.3 is 586, should be gcc-3.3 386 Erik Plaggenmar Linux - Software 0 10-01-2004 11:38 AM
Various Compiling Errors (GCC compiling Openal, GUIlib, xmms-wma) gregorya Linux - Software 2 08-27-2004 05:03 AM
Young one saying hello! sbarn LinuxQuestions.org Member Intro 3 11-16-2003 06:34 PM
Internships for a young Penguin santiagodelgado Linux - General 3 12-19-2001 12:27 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat

All times are GMT -5. The time now is 09:39 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration