LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-16-2006, 01:22 PM   #1
BurningBreeze
LQ Newbie
 
Registered: Jan 2006
Posts: 3

Rep: Reputation: 0
Unhappy "Hello, World!" compiling problems


I have compiled a "hello, world" program before in Linux. I cant remember the command line and now i am having problems, i'm using slackware 10.1 and knoppix 3.8 and in both when i try am compile:

/* ------ hello.C ------- */
#include<stdio.h>
int main(void) {
printf("Hello, world!\n\n");
return 0;
}
/* ------- End --------- */

under the command:
gcc hello.C -o hello

i get the following error
/tmp/ccAp71uc.o(.eh_frame+0x11): undefined reference to'__gxx_personality_v0'
collect2: ld returned 1 exit status

Any suggestions?
Thank you, BurningBreeze.
 
Old 01-16-2006, 01:38 PM   #2
jtshaw
Senior Member
 
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892
Blog Entries: 1

Rep: Reputation: 67
The problem is the uppercase C in the file extension.

gcc automatically assumes that .C, .cpp, .cxx, .cc, ect. are C++ files. If you attempt to compile a C++ file using gcc without linking to -lstdc++ it will not work.

Either of these will work
gcc -lstdc++ -o test test.C
g++ -o test test.C
or rename test.C to test.c and use
gcc -o test test.c

Also, in the future please use the code blocks.

Code:
#include<stdio.h>

int main(void) {
    printf("Hello, world!\n\n");
    return 0;
}
 
Old 01-16-2006, 01:39 PM   #3
dombrowsky
Member
 
Registered: Dec 2005
Location: New York
Distribution: Debian/GNU
Posts: 235

Rep: Reputation: 31
try running it with a lowercase 'c'. I think that gcc automatically interprets the *.C as c plus plus, and your c++ libs might be broken (it happens). But if "gcc hello.c" fails, then your compiler is broken.
 
Old 01-16-2006, 01:48 PM   #4
BurningBreeze
LQ Newbie
 
Registered: Jan 2006
Posts: 3

Original Poster
Rep: Reputation: 0
No errors came up after i renamed the file. but when i type 'hello' at the Konsole it doesen't run. so i typed 'gdb hello' and then in gdb 'run' and it ran. why wont the Konsole run it?
 
Old 01-16-2006, 02:32 PM   #5
jtshaw
Senior Member
 
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892
Blog Entries: 1

Rep: Reputation: 67
Try ". hello" or "./hello". Most likely the current directory just isn't in your system path.
 
Old 01-16-2006, 03:48 PM   #6
BurningBreeze
LQ Newbie
 
Registered: Jan 2006
Posts: 3

Original Poster
Rep: Reputation: 0
'./hello' worked! thanks dude! I obviously worked with a different distro when i was previously compiling in linux.
 
Old 01-16-2006, 05:04 PM   #7
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,575

Rep: Reputation: 181Reputation: 181
Moved: This thread is more suitable in Programming and has been moved accordingly to help your thread/question get the exposure it deserves.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
running "hello world" in ARM Integrator Board ayeong Linux - Newbie 4 09-12-2006 03:01 AM
LXer: "Bring Open Source To the World Of BPM" LXer Syndicated Linux News 0 12-12-2005 07:01 AM
Problems with "make check" while compiling Glibc in Chapter 6.11 Spuckdung Linux From Scratch 2 02-13-2005 06:12 AM
When "function pointer" meets "template"... I can't get rid of this compiling er cyu021 Linux - Software 3 12-17-2004 08:52 PM
Compiling KDE 3.2.0 - "Can't open perl script "/dcopidlng/kalyptus" linuxgamer09483 Linux - Software 3 04-09-2004 09:25 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:41 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration