g ++编译错误(架构x86_64的未定义符号)

时间:2015-11-04 23:15:45

标签: c++

当我用g ++ - 4.9

编译代码时
g++ main.cpp base_server.cpp base_server.hpp threaded_server.cpp threaded_server.hpp

我收到错误:

Undefined symbols for architecture x86_64:
  "BaseServer::~BaseServer()", referenced from:
      ThreadedServer::~ThreadedServer() in ccQVIp8S.o
      ThreadedServer::~ThreadedServer() in ccQVIp8S.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
make: *** [all] Error 1

当我用clang ++编译时,没有任何错误和警告。如何用g ++编译它?

base_server.hpp:https://gist.github.com/yutkin/ccecf7d6132ab63db3bd

base_server.cpp:https://gist.github.com/yutkin/833bf593cf1775b3cb21

threaded_server.hpp:https://gist.github.com/yutkin/61ef0a91f1e1c811334b

threaded_server.cpp:https://gist.github.com/yutkin/62821e6791565a54edac

OS X 10.11.1

1 个答案:

答案 0 :(得分:0)

BaseServer::~BaseServer()inline。没有inline,一切正常。