Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/136.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
具有C++未定义引用的DistCC < >配置DistCC编译C++文件有困难。我在C++中做了一个标准的小程序,在尝试一个更大的项目之前,我试图让DistCC在本地编译它,但是我得到了未定义的引用错误。_C++_G++_Undefined Reference_Distcc - Fatal编程技术网

具有C++未定义引用的DistCC < >配置DistCC编译C++文件有困难。我在C++中做了一个标准的小程序,在尝试一个更大的项目之前,我试图让DistCC在本地编译它,但是我得到了未定义的引用错误。

具有C++未定义引用的DistCC < >配置DistCC编译C++文件有困难。我在C++中做了一个标准的小程序,在尝试一个更大的项目之前,我试图让DistCC在本地编译它,但是我得到了未定义的引用错误。,c++,g++,undefined-reference,distcc,C++,G++,Undefined Reference,Distcc,我的程序名为hello.cpp: #include <iostream> int main(){ std::cout << "Hello World in c++" << std::endl; return 0; } 终端输出: /tmp/cc5rZwhV.o: In function `main': <br> hello.cpp:(.text+0xa): undefined reference to `std::cout' <b

我的程序名为hello.cpp:

#include <iostream>

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

/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>
将-lstdc++添加到链接器命令行,也就是说,将libstdc++显式添加到链接库中,这通常是g++为您所做的


当你这么做的时候,也可以试试icecc。我个人更喜欢它。

也许-lstdc++标志能帮上忙?
/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>
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)