"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. |
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> |
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.
|
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?
|
Try ". hello" or "./hello". Most likely the current directory just isn't in your system path.
|
'./hello' worked! thanks dude! I obviously worked with a different distro when i was previously compiling in linux.
|
Moved: This thread is more suitable in Programming and has been moved accordingly to help your thread/question get the exposure it deserves.
|
All times are GMT -5. The time now is 05:53 PM. |