I having trouble configuring distcc to compile C++ files. I did a standard small "Hello, World" program in C++ and am trying to get distcc to compile it locally (before I get fancy with a larger project), but I am getting "undefined reference" errors.
My program, called "hello.cpp":
#include <iostream>
int main(){
std::cout << "Hello World in c++" << std::endl;
return 0;
}
My command:
$ distcc hello.cpp
Terminal output:
/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>
Other information:
This program compiles just fine with g++ and C++. A similar program written in C using printf
works with distcc.
Output of $ 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)
Add -lstdc++
to your linker command line (that is, add libstdc++
to your linked libraries explicitly, which normally g++
would do for you).
While you're at it, try icecc
as well. I personally prefer it.