Unable to build simpleMPI on Yosemite

Hi, I’m trying to build the simpleMPI sample from CUDA-7.0 on Yosemite. I have OpenMPI 1.8.4, XCode 6.2, and clang 6.0 installed. Output below. Any help would be appreciated.

Greg

/usr/local/mpi/bin/mpicxx -I…/…/common/inc -fno-inline -arch x86_64 -stdlib=libstdc++ -o simpleMPI_mpi.o -c simpleMPI.cpp
/Developer/NVIDIA/CUDA-7.0/bin/nvcc -ccbin clang++ -I…/…/common/inc -m64 -Xcompiler -fno-inline -Xcompiler -arch -Xcompiler x86_64 -gencode arch=compute_20,code=sm_20 -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35 -gencode arch=compute_37,code=sm_37 -gencode arch=compute_50,code=sm_50 -gencode arch=compute_52,code=sm_52 -gencode arch=compute_52,code=compute_52 -o simpleMPI.o -c simpleMPI.cu
/usr/local/mpi/bin/mpicxx -Xlinker -rpath -Xlinker /Developer/NVIDIA/CUDA-7.0/lib -stdlib=libstdc++ -o simpleMPI simpleMPI_mpi.o simpleMPI.o -L/Developer/NVIDIA/CUDA-7.0/lib -lcudart
Undefined symbols for architecture x86_64:
“std::__1::locale::use_facet(std::__1::locale::id&) const”, referenced from:
std::__1::basic_ostream<char, std::__1::char_traits >& std::__1::endl<char, std::__1::char_traits >(std::__1::basic_ostream<char, std::__1::char_traits >&) in simpleMPI.o
std::__1::basic_ostream<char, std::__1::char_traits >& std::__1::__put_character_sequence<char, std::__1::char_traits >(std::__1::basic_ostream<char, std::__1::char_traits >&, char const*, unsigned long) in simpleMPI.o
“std::__1::ios_base::getloc() const”, referenced from:
std::__1::basic_ostream<char, std::__1::char_traits >& std::__1::endl<char, std::__1::char_traits >(std::__1::basic_ostream<char, std::__1::char_traits >&) in simpleMPI.o
std::__1::basic_ostream<char, std::__1::char_traits >& std::__1::__put_character_sequence<char, std::__1::char_traits >(std::__1::basic_ostream<char, std::__1::char_traits >&, char const*, unsigned long) in simpleMPI.o
“std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >::__init(unsigned long, char)”, referenced from:
std::__1::ostreambuf_iterator<char, std::__1::char_traits > std::__1::__pad_and_output<char, std::__1::char_traits >(std::__1::ostreambuf_iterator<char, std::__1::char_traits >, char const*, char const*, char const*, std::__1::ios_base&, char) in simpleMPI.o
“std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >::~basic_string()”, referenced from:
std::__1::ostreambuf_iterator<char, std::__1::char_traits > std::__1::__pad_and_output<char, std::__1::char_traits >(std::__1::ostreambuf_iterator<char, std::__1::char_traits >, char const*, char const*, char const*, std::__1::ios_base&, char) in simpleMPI.o
“std::__1::basic_ostream<char, std::__1::char_traits >::put(char)”, referenced from:
std::__1::basic_ostream<char, std::__1::char_traits >& std::__1::endl<char, std::__1::char_traits >(std::__1::basic_ostream<char, std::__1::char_traits >&) in simpleMPI.o
“std::__1::basic_ostream<char, std::__1::char_traits >::flush()”, referenced from:
std::__1::basic_ostream<char, std::__1::char_traits >& std::__1::endl<char, std::__1::char_traits >(std::__1::basic_ostream<char, std::__1::char_traits >&) in simpleMPI.o
“std::__1::basic_ostream<char, std::__1::char_traits >::sentry::sentry(std::__1::basic_ostream<char, std::__1::char_traits >&)”, referenced from:
std::__1::basic_ostream<char, std::__1::char_traits >& std::__1::__put_character_sequence<char, std::__1::char_traits >(std::__1::basic_ostream<char, std::__1::char_traits >&, char const*, unsigned long) in simpleMPI.o
“std::__1::basic_ostream<char, std::__1::char_traits >::sentry::~sentry()”, referenced from:
std::__1::basic_ostream<char, std::__1::char_traits >& std::__1::__put_character_sequence<char, std::__1::char_traits >(std::__1::basic_ostream<char, std::__1::char_traits >&, char const*, unsigned long) in simpleMPI.o
“std::__1::basic_ostream<char, std::__1::char_traits >::operator<<(int)”, referenced from:
_computeGPU in simpleMPI.o
“std::__1::cerr”, referenced from:
_computeGPU in simpleMPI.o
“std::__1::ctype::id”, referenced from:
std::__1::basic_ostream<char, std::__1::char_traits >& std::__1::endl<char, std::__1::char_traits >(std::__1::basic_ostream<char, std::__1::char_traits >&) in simpleMPI.o
std::__1::basic_ostream<char, std::__1::char_traits >& std::__1::__put_character_sequence<char, std::__1::char_traits >(std::__1::basic_ostream<char, std::__1::char_traits >&, char const*, unsigned long) in simpleMPI.o
“std::__1::locale::~locale()”, referenced from:
std::__1::basic_ostream<char, std::__1::char_traits >& std::__1::endl<char, std::__1::char_traits >(std::__1::basic_ostream<char, std::__1::char_traits >&) in simpleMPI.o
std::__1::basic_ostream<char, std::__1::char_traits >& std::__1::__put_character_sequence<char, std::__1::char_traits >(std::__1::basic_ostream<char, std::__1::char_traits >&, char const*, unsigned long) in simpleMPI.o
“std::__1::ios_base::__set_badbit_and_consider_rethrow()”, referenced from:
std::__1::basic_ostream<char, std::__1::char_traits >& std::__1::__put_character_sequence<char, std::__1::char_traits >(std::__1::basic_ostream<char, std::__1::char_traits >&, char const*, unsigned long) in simpleMPI.o
“std::__1::ios_base::clear(unsigned int)”, referenced from:
std::__1::basic_ostream<char, std::__1::char_traits >& std::__1::__put_character_sequence<char, std::__1::char_traits >(std::__1::basic_ostream<char, std::__1::char_traits >&, char const*, unsigned long) in simpleMPI.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [simpleMPI] Error 1

Hey jarrah,

I’ve had similar compile issues in my code before and had something to with clang (maybe in this case mpicxx) and nvcc using different c++ standard libraries. Although from the output above if looks as though they should be using the same one (libstdc++).

Maybe if you add the -v option into the sample’s Makefile it could shed some more light on the issue.

So jarrah,

I have Mavericks and get the same compile issues on my machine. It is definitely stdlib and you can get around it by changing the stdlib used by mpicxx.

All I did to get the compilation to work was to change the “stdlib=libstdc++” flags on lines 223 and 224 to “-lc++”.

Of course this changes the stdlib used by mpicxx to match the default library used by nvcc (which is probably what clang uses in this case). If you were so inclined you could just as easily change the stdlib used by nvcc.

Hope that helps

Chris :-)

That fixed the problem. Thanks!