带有 C++ 未定义引用的 Distcc
Distcc with C++ undefined reference
我在配置 distcc 以编译 C++ 文件时遇到问题。我在 C++ 中做了一个标准的小 "Hello, World" program 并试图让 distcc 在本地编译它(在我喜欢一个更大的项目之前),但是我得到 "undefined reference" 错误。
我的程序,名为 "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)
将 -lstdc++
添加到您的链接器命令行(即,将 libstdc++
显式添加到您的链接库,通常 g++
会为您完成)。
当你在做的时候,也试试 icecc
。我个人比较喜欢。
我在配置 distcc 以编译 C++ 文件时遇到问题。我在 C++ 中做了一个标准的小 "Hello, World" program 并试图让 distcc 在本地编译它(在我喜欢一个更大的项目之前),但是我得到 "undefined reference" 错误。
我的程序,名为 "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)
将 -lstdc++
添加到您的链接器命令行(即,将 libstdc++
显式添加到您的链接库,通常 g++
会为您完成)。
当你在做的时候,也试试 icecc
。我个人比较喜欢。