dyld:懒符号绑定失败:未找到符号:__ ZN5boost11this_thread5hiden11sleep_untilERK8timespec(有... 6hidden11sleep_untilERK8timespec)

时间:2017-06-04 10:04:12

标签: c++ dyld

尝试使用OMPL 1.1.0库。我正在使用这个示例代码(与运行时发生的问题无关):

#include <ompl/base/Goal.h>
#include <ompl/base/goals/GoalState.h>
#include <ompl/base/goals/GoalStates.h>
#include <ompl/base/ProjectionEvaluator.h>
#include <ompl/base/StateSpace.h>
#include <ompl/geometric/PathSimplifier.h>
#include <ompl/base/samplers/UniformValidStateSampler.h>

#include <ompl/base/spaces/RealVectorStateSpace.h>
#include <ompl/base/spaces/SE2StateSpace.h>
#include <ompl/base/spaces/SE3StateSpace.h>

#include <ompl/geometric/SimpleSetup.h>
#include <ompl/geometric/planners/rrt/RRT.h>

#include <boost/make_shared.hpp>
#include <boost/shared_ptr.hpp>

#include <iostream>

namespace ob = ompl::base;
namespace og = ompl::geometric;

bool isStateValid(const ob::State *state)
{
    return true;
}

int main(int /*argc*/, char ** /*argv*/)
{
    std::cout << "OMPL version: " << OMPL_VERSION << std::endl;
    boost::shared_ptr<ob::SE3StateSpace> space(boost::make_shared<ob::SE3StateSpace>());
    ob::RealVectorBounds bounds(3);
    bounds.setLow(-1);
    bounds.setHigh(1);
    space->setBounds(bounds);
    og::SimpleSetup ss(space);
    //ss.setStateValidityChecker([](const ob::State *state) { return isStateValid(state); });
    ob::ScopedState<> start(space);
    start.random();
    ob::ScopedState<> goal(space);
    goal.random();
    ss.setStartAndGoalStates(start, goal);
    ss.setup();
    ss.print();
    ob::PlannerStatus solved = ss.solve(1.0);
    if(solved)
    {
        std::cout << "Found solution:" << std::endl;
        ss.simplifySolution();
        ss.getSolutionPath().print(std::cout);
    }
    else
        std::cout << "No solution found" << std::endl;
    return 0;
}

和以下makefile:

CXXFLAGS=-I/usr/local/Cellar/ompl/1.1.0/include -I/usr/local/Cellar/boost/1.64.0_1/include
LDLIBS=-lc++ -L/usr/local/Cellar/boost/1.64.0_1/lib/ -lboost_thread-mt -lboost_filesystem -lboost_system -lompl
ompltest: ompltest.o

当我运行我得到的可执行文件时:

dyld: lazy symbol binding failed: Symbol not found: __ZN5boost11this_thread5hiden11sleep_untilERK8timespec
  Referenced from: /usr/local/opt/ompl/lib/libompl.11.dylib
  Expected in: /usr/local/opt/boost/lib/libboost_thread-mt.dylib

dyld: Symbol not found: __ZN5boost11this_thread5hiden11sleep_untilERK8timespec
  Referenced from: /usr/local/opt/ompl/lib/libompl.11.dylib
  Expected in: /usr/local/opt/boost/lib/libboost_thread-mt.dylib

Abort trap: 6

我在boost共享库中查找缺少的符号,我发现:

$ nm -gU /usr/local/opt/boost/lib/libboost_thread-mt.dylib | grep sleep_until.*timespec
0000000000004130 T __ZN5boost11this_thread21no_interruption_point6hidden11sleep_untilERK8timespec
0000000000004390 T __ZN5boost11this_thread6hidden11sleep_untilERK8timespec

有__ZN5boost11this_thread 6hidden 11sleep_untilERK8timespec而不是__ZN5boost11this_thread 5hiden 11sleep_untilERK8timespec。 那是什么?一个错字?还是打算? 关键是我不能使用这个我甚至不能自己构建的库(通过自制软件安装)

编辑:未编码的符号名称:

$ nm -jgU /usr/local/opt/boost/lib/libboost_thread-mt.dylib | grep sleep_until.*timespec | c++filt
boost::this_thread::no_interruption_point::hidden::sleep_until(timespec const&)
boost::this_thread::hidden::sleep_until(timespec const&)
$ echo __ZN5boost11this_thread5hiden11sleep_untilERK8timespec | c++filt
boost::this_thread::hiden::sleep_until(timespec const&)

1 个答案:

答案 0 :(得分:0)

正如John Zwinck所建议的

echo __ZN5boost11this_thread5hiden11sleep_untilERK8timespec |c++filt boost::this_thread::hiden::sleep_until(timespec const&) echo __ZN5boost11this_thread6hidden11sleep_untilERK8timespec |c++filt boost::this_thread::hidden::sleep_until(timespec const&) 也许您的/usr/local/opt/ompl/lib/libompl.11.dylib是使用不同版本的boost库构建的,然后是您当前的1.64? 使用什么增强库来构建OMPL?