Thread: Compile in cpp option
hello,
i'm trying compile c++ program in ubuntu. reading "the linux development book". says there gcc options such as:
-x c (lowercase c) c language selection
-x c++ c++ file
-x objective-c objective c
-x assembler assembler file
-x f77 fortran file
-x java java language file
getting errors using "gcc testcpp.cpp -x c++ -o test" , or "gcc testcpp.cpp -o test".
/tmp/ccyt4gjm.o.eh_frame+0x12): undefined reference `__gxx_personality_v0'
collect2: ld returned 1 exit status
guess these options don't apply ubuntu?? there better reference book ubuntu programming?
to compile c++ it's preferable explicitly invoke g++ rather gcc
if wanted compile c++ gcc @ minimum need specify stdc++ library:code:g++ testcpp.cpp -o test
afaik -x option used tell compiler language source file contains - redundant if using .cpp suffix. example if had c++ source file called test.txt then:code:gcc testcpp.cpp -o test -lstdc++
you can check manual page command line optionscode:/documents/forums$ gcc test.txt -o test -lstdc++ test.txt: file not recognized: file format not recognized collect2: ld returned 1 exit status /documents/forums$ /documents/forums$ gcc -x c++ test.txt -o test -lstdc++ /documents/forums$ /documents/forums$ ./test hello world! /documents/forums$
code:man gcc
Forum The Ubuntu Forum Community Ubuntu Official Flavours Support New to Ubuntu [ubuntu] Compile in cpp option
Ubuntu
Comments
Post a Comment