Distcc with C ++ undefined reference

时间:2015-12-20 13:17:30

标签: c++ g++ undefined-reference distcc

我在配置distcc以编译C ++文件时遇到问题。我在C ++中做了一个标准的小"Hello, World" program,并且我试图让distcc在本地编译它(在我对一个更大的项目感兴趣之前),但是我得到了#34;未定义的引用"错误。

我的程序,名为" hello.cpp":

#include <iostream>

int main(){
  std::cout << "Hello World in c++" << std::endl;
  return 0;
}

我的命令:

$ distcc hello.cpp

终端输出:

/tmp/cc5rZwhV.o: In function `main': <br>
hello.cpp:(.text+0xa): undefined reference to `std::cout' <br>
hello.cpp:(.text+0xf): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)' <br>
hello.cpp:(.text+0x14): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)' <br>
hello.cpp:(.text+0x1c): undefined reference to `std::ostream::operator<<(std::ostream& (*)(std::ostream&))' <br>
/tmp/cc5rZwhV.o: In function `__static_initialization_and_destruction_0(int, int)': <br>
hello.cpp:(.text+0x4a): undefined reference to `std::ios_base::Init::Init()' <br>
hello.cpp:(.text+0x59): undefined reference to `std::ios_base::Init::~Init()' <br>
collect2: error: ld returned 1 exit status <br>
distcc[21053] ERROR: compile hello.cpp on localhost failed <br>

其他信息:

这个程序用g ++和C ++编译得很好。使用printf用C编写的类似程序与distcc一起使用。

$ distcc --version的输出:

distcc 3.2rc1 x86_64-unknown-linux-gnu
  (protocols 1, 2 and 3) (default port 3632)
  built Jul  7 2014 13:18:34
....(copyright stuff)

1 个答案:

答案 0 :(得分:3)

-lstdc++添加到链接器命令行(即,明确地将libstdc++添加到链接库,通常g++将为您执行此操作。

虽然您正在尝试,但也请尝试icecc。我个人更喜欢它。