1

I have two projects

  1. the first project is compiled with clang
  2. the second project is compiled with gcc and uses code from the first project

The second project fails with an undefined reference error to a function with type traits:

CMakeFiles/RobotAPICore.dir/remoterobot/RobotStateObserver.cpp.o: In function      
`RobotStateObserver::udpatePoseDatafields(std::map<std::string, IceInternal::Handle<FramedPoseBase>, std::less<std::string>, std::allocator<std::pair<std::string const, 
IceInternal::Handle<FramedPoseBase> > > > const&)':
/home/user/RobotAPI/source/RobotAPI/libraries/core/remoterobot/RobotStateObserver.cpp:149: 
undefined reference to `Variant::Variant<float>(float const&, boost::disable_if_c<boost::is_base_of<VariantDataClass, float>::value||boost::is_pointer<float>::value, void>::type*)'

If I compile both projects with the same compiler, everything works fine.

Any ideas?

thanks!

veio
  • 507
  • 4
  • 16
  • When compiling with clang++, do you use -stdlib=libstdc++ (should be compatible with g++) or -stdlib=libc++ (not compatible)? Which versions of clang/gcc? – Marc Glisse Mar 20 '17 at 09:56

1 Answers1

1

Yeah, you can't do that.

Don't mix toolchains.

Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055
  • So, if I want to ship my code compiled with clang, nobody can use it with gcc? And the other way around it just works by chance? How do you know with which toolchain a installed library was compiled with? – veio Mar 19 '17 at 12:35
  • 1
    IMO this depends on the type of data your project exposes. C has a standardised binary interface (ABI), whereas c++ does not (see http://stackoverflow.com/questions/7492180/c-abi-issues-list). Also see http://stackoverflow.com/questions/11682748/is-clang-abi-same-as-g – Ser Jothan Chanes Mar 19 '17 at 12:51
  • @SerJothanChanes: Yeah, that's right. FYI the question is tagged C++, so.. – Lightness Races in Orbit Mar 20 '17 at 00:12