getopt_long problem

J

jenea

HI!
I write a little test program.
In witch I use getopt_long function...
I included unstd.h , optget.h , stdio.h and stdlib.h
when i try to link the program with gcc -o result main.o
( within a makefile , i.e I run make)
it says

tmp/ccGfK1gp.o(.eh_frame+0x11): undefined reference to
`__gxx_personality_v0'
collect2: ld returned 1 exit status
make: *** [run] Error 1

As result it doesn't generate binary file :(
When I remove call of getopt_long functions the problem disapears...
Realy strange!...
Any ideas ?
10x in advance .
 
R

Roger Leigh

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

jenea said:
I write a little test program.
In witch I use getopt_long function...
I included unstd.h , optget.h , stdio.h and stdlib.h
when i try to link the program with gcc -o result main.o

tmp/ccGfK1gp.o(.eh_frame+0x11): undefined reference to
`__gxx_personality_v0'
collect2: ld returned 1 exit status
make: *** [run] Error 1

When I remove call of getopt_long functions the problem disapears...

$ nm -D -C /usr/lib/libstdc++.so.6 | grep __gxx_personality_v0
000a0e70 T __gxx_personality_v0

You are writing C++, not C, and so you need to use g++ rather than gcc
to link.

getopt_long is a red herring; you need to check if you are
unintentionally using C++ features in your program. Assuming you are
writing C, since this is a C group, you need to remove the C++
features from your code and then linking should work fine.


Regards,
Roger

- --
Roger Leigh
Printing on GNU/Linux? http://gimp-print.sourceforge.net/
Debian GNU/Linux http://www.debian.org/
GPG Public Key: 0x25BFB848. Please sign and encrypt your mail.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.8 <http://mailcrypt.sourceforge.net/>

iD8DBQFCH3kKVcFcaSW/uEgRAmxhAKDwUQyJod9XpQqV0I0fZUwGHk4NtACeMxm8
yYMzxBelw1S4vRmhFYzoU9Y=
=82rr
-----END PGP SIGNATURE-----
 
J

jacob navia

jenea said:
HI!
I write a little test program.
In witch I use getopt_long function...
I included unstd.h , optget.h , stdio.h and stdlib.h
when i try to link the program with gcc -o result main.o
( within a makefile , i.e I run make)
it says

tmp/ccGfK1gp.o(.eh_frame+0x11): undefined reference to
`__gxx_personality_v0'
collect2: ld returned 1 exit status
make: *** [run] Error 1

As result it doesn't generate binary file :(
When I remove call of getopt_long functions the problem disapears...
Realy strange!...
Any ideas ?
10x in advance .

The same message appeared in a similar thread just a few
hours ago: (Subject: GCC linker throws weird error message)
>I am compiling with GCC 3.2, and it works well enough. However,
>sometimes when I try to link libraries, the linker throws
>"NOTAD.o(.eh_frame+0x11):NOTAD.C: undefined reference to
>`__gxx_personality_v0'". This never happened until about 3 days ago.


The solution is:
> because your filename is in UPPER CASE gcc is treating it as a C++
> source. rename extension to lower case (.c instead of .C) and it
> should work.

Posted by Rex.

Truly a *clear* error message:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Error 3
undefined reference to `__gxx_personality_v0' 7
compile problem 4
iostream error. 23
building 32-bit on 64-bit system 10
Qsort() messing with my entire Code 0
Real pain with SegFoult 19
Errors with enums 4

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top