4

I'd like to use the Boost library in my C++ code, so I've inputted the right include search path and the right library search path, then I added all the Boost library files in Xcode. When I build my code the compiler says that the build is successful. However, once I run the code, the console tells this:

Console:

dyld: Symbol not found: _PyBaseObject_Type
  Referenced from: /usr/local/lib/libboost_python27.dylib
  Expected in: flat namespace
 in /usr/local/lib/libboost_python27.dylib
Program ended with exit code: 9

My code:

#include <iostream>
#include <boost/any.hpp>

int main()
{
    std::cout << std::endl;
    return 0;
}

Where is my mistake? Please help.

  • Boost is not library, it is quite huge set of libraries. Usage of boost::any feels pointless since any was added to C++ by C++17 as std::any. So just include and use std::any. – Öö Tiib Dec 29 '19 at 14:18
  • 1
    @ÖöTiib `any` is just an example. The errors raise with any library. –  Dec 29 '19 at 14:25
  • If it is with every library then it is apparently issue with how you install libraries or incorporate these into your projects. Read https://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix for common causes of that. – Öö Tiib Dec 29 '19 at 14:30
  • I'm having the same problem. Did you solve this? – Zack Lee Jan 04 '20 at 04:33
  • @ZackLee yeah, but I don't so like the solution. I just installed Boost via homebrew. –  Jan 04 '20 at 16:48

1 Answers1

0

This error occurs when you don't add a package to your project the right way. The problem has resolved in my example by installing Boost via Homebrew. Installing the package the right way means that if you install it manually (e.g. downloading it from GitHub), you should install it on the right path. But I suggest always installing C++ packages via Homebrew.