OSX What does "error: cannot convert 'const std::__cxx11::basic_string<char>" mean?

2.7k views Asked by At

I am compiling a friend's code on my machine, and I keep getting hit with this error:

 $ mpic++ dummy_file_name.cpp

 dummy_file_name.cpp: In member function 'bool dummy_name1::dummy_name2::python_convert(const StringMultiArray&, PyObject**)':
 dummy_file_name.cpp:430:55:error: cannot convert 'const std::__cxx11::basic_string<char>' to 'const char*' for argument '1' to 'PyObject* PyString_FromString(const char*)'
     PyList_SetItem(*dst, i, PyString_FromString(src[i]));

What does this mean? How can I diagnose or treat this issue? I am using the mpic++ compiler. I have tried googling this error but I have not found any fruitful information.

Here is how I built my environment:

brew reinstall gcc --without-multilib
export HOMEBREW_CC=gcc-5
export HOMEBREW_CXX=g++-5
brew install openmpi --build-form-source
brew install llvm --with-clang
1

There are 1 answers

5
Jeffery Thomas On BEST ANSWER

It's saying it can't convert const std::__cxx11::basic_string<char> AKA const std::string to const char*. This is a proper error for the compiler to report. As stated above you could fix this by using c_str(), but that would be an awful hack, and maybe violate some component's open source license.


As to why you are getting this error, it may be a mixup with the standard standard c++ libraries. You appear to be using gcc for openmpi and llvm for the link step which is very odd. In addition, you are forcing c++11 for gcc, but not for llvm.

Where did you get these build instructions? You may want to lookup an updated set of instructions.