-1

When compiling with Makefile, I got error

/tmp/ccQ0q0g5.o:(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status

It seems that the some .so or .a files missing, but how can I know which one is missing from such an error report?

Makefile:

CFLAGS = -Iinclude/
CFLAGS += -m32 
LDFLAGS = -Llib -llits -lrt -lpthread -Wl,-R,'lib'
server:server.cc
    gcc -o server $(CFLAGS) $(LDFLAGS) server.cc
user4016367
  • 431
  • 2
  • 9
  • 22
  • Aren't your questions already answered in the duplicates? Do better research before asking questions here next time! – πάντα ῥεῖ Mar 03 '15 at 11:37
  • @πάνταῥεῖ How do I suppose to know `ccQ0q0g5.o` is something relevant to the C++ runtime library, if you paste `ccQ0q0g5.o` in google, in get nothing. – user4016367 Mar 03 '15 at 11:50
  • The duplicate answer was easy to find, just googling the important parts of your question title: ["undefined reference to `__gxx_personality_v0'"](https://www.google.de/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=%22undefined%20reference%20to%20%60__gxx_personality_v0%27%22) So what? You probably want to improve your google fu, before attending to SO. – πάντα ῥεῖ Mar 03 '15 at 12:04

1 Answers1

11

You're compiling C++, but you're not linking to the C++ runtime library.

Use g++ to link C++ programs, not gcc.

(Or manually add -lstdc++ to the linker command).

Jonathan Wakely
  • 166,810
  • 27
  • 341
  • 521