boost 的另一个“ld:未找到架构 x86_64 的符号”问题,这次是 mgiza

2024-03-26

我很抱歉问了这样一个常见的问题;我找不到任何可行的或足够清晰的解决方案供我实施。我只是想安装mgiza https://github.com/moses-smt/mgiza。这是安装文件:

cmake .
make
make install

If you want to install to a custom location, add the following flag when you run cmake:
-DCMAKE_INSTALL_PREFIX=/path/to/custom/location

NOTE: Boost Version 1.48 has problem with the code, you can use either 1.46 or 1.50+. Unfortunately 1.48 is shipped with Ubuntu 12.04 LTS, you can either download and compile libboost 1.50+ from their website, or just do this:
sudo apt-get install libboost1.46-all-dev

看起来很容易,对吧?正在输入cmake .工作没有任何明显的问题。很遗憾,make使用 boost 会遇到这个可怕的错误(“未定义的符号......”)。

1 warning generated.
Linking CXX executable ../bin/d4norm
Undefined symbols for architecture x86_64:
  "std::string::_Rep::_M_destroy(std::allocator<char> const&)", referenced from:
      boost::system::(anonymous namespace)::generic_error_category::message(int) const in libboost_system-mt.a(error_code.o)
  "std::string::_Rep::_S_empty_rep_storage", referenced from:
      boost::system::(anonymous namespace)::generic_error_category::message(int) const in libboost_system-mt.a(error_code.o)
  "std::string::assign(char const*, unsigned long)", referenced from:
      boost::system::(anonymous namespace)::generic_error_category::message(int) const in libboost_system-mt.a(error_code.o)
  "std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)", referenced from:
      boost::system::(anonymous namespace)::generic_error_category::message(int) const in libboost_system-mt.a(error_code.o)
  "std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&)", referenced from:
      boost::system::(anonymous namespace)::generic_error_category::message(int) const in libboost_system-mt.a(error_code.o)
  "std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()", referenced from:
      boost::system::(anonymous namespace)::generic_error_category::message(int) const in libboost_system-mt.a(error_code.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

根据其他问题,这是Mavericks的问题,因为它使用clang来编译c++代码,暗示该库是libc++,而不是libstdc++。为了完整起见,并让其他人可以重现我的错误,我使用 OS X 10.9.5、Xcode 6.1,我的 boost 版本是 1.56(boost 是通过自制程序安装的)。

现在,必须有some在那里解决,对吗?让我们来看看其中的一些:

  1. 应用 -m32 标志 https://stackoverflow.com/questions/9272566/gcc-ld-symbols-not-found-for-architecture-x86-64:不适用,因为 Makefile 里面没有任何“g++”,它也明确告诉我不要 编辑它,因为它是“Cmake”生成的文件。
  2. 未在头文件中定义某些内容 https://stackoverflow.com/questions/21966887/undefined-symbols-for-architecture-x86-64-xcode-5-issues:不适用,因为代码应该准备好编译。
  3. 将 -stdlib=libstdc++ 添加到链接器 https://stackoverflow.com/questions/19637164/c-linking-error-after-upgrading-to-mac-os-x-10-9-xcode-5-0-1:我不知道如何将其添加到make命令?我试着做make -stdlib=libstdc++虽然这似乎避免了上述错误,但它引入了一些额外的错误:make: *** [all] Error 2(不确定那是什么意思)。
  4. 链接到正确的 boost 库 https://stackoverflow.com/questions/21590507/boost-xcode-c-command-line-undefined-symbols-for-architecture-x86-64:那里有一条评论说“你只需要链接到正确的升压库......关于如何做到这一点有大量的问答”。不幸的是,我认为评论者链接的任何问题都不能解决我的问题。
  5. 将 Qt 与 boost 链接起来 https://stackoverflow.com/questions/25343335/boost-in-qt-installation-and-symbols-not-found-for-architectures-x86-64:我认为这不适用,因为我没有使用 Qt,而且我不知道在哪里放入LIBS += [...] boost line.
  6. 链接丢失的文件 https://stackoverflow.com/questions/21297447/ld-symbols-not-found-for-architecture-x86-64:这个问题似乎更多是关于运行时的链接g++但我使用的 Makefile 没有g++其中任何地方。
  7. 使用 g++ 与 gcc https://stackoverflow.com/questions/23496692/how-can-i-fix-g-undefined-symbols-for-architecture-x86-64-error:我不知道如何更改我使用的其中哪一个,因为我正在使用cmake and make...
  8. 更改链接命令 https://stackoverflow.com/questions/20202715/ld-symbols-not-found-for-architecture-x86-64-libusb:同样,我不知道如何更改编译cmake/make to gcc。 (注意:从现在开始,我将忽略大多数通过向 gcc 或 g++ 添加某些内容来回答的问题。)
  9. 更改标准 C++ 库 https://stackoverflow.com/questions/19821041/g-ld-symbols-not-found-for-architecture-x86-64:解决方案涉及进入 Xcode 并更改其中的库。我认为这不是正确的方法,无论如何,如果我更改 Xcode 中的设置,我可能会搞砸一些东西(我也没有使用 Xcode 的 GUI 的经验)。
  10. 在 Xcode 中链接库 https://stackoverflow.com/questions/13332807/cundefined-symbols-for-architecture-x86-64-mac-and-boost-library:我认为这与此列表中的#9 类似。这里的答案还建议使用homebrew而不是macports来安装boost,但是我之前已经说过我使用homebrew来安装boost。
  11. 使用 clang 编译 https://trac.macports.org/ticket/41588:类似的问题,但是如何让 cmake 或 make 使用 clang 进行编译?
  12. 来自(流行的)比特币问题 https://github.com/bitcoin/bitcoin/issues/3228: Now this看起来很有趣!很多人都遇到了我的错误。不幸的是,似乎没有达成共识或简单的解决方案。还有一些我不知道实施的解决方案。例如,“imbolo”的一种解决方案是使用 cxxflag 标志来编译 boost,但这是什么意思?

所以我对如何正确安装 mgiza 有点不知所措......我的意思是,mgiza 给我的全部意义cmake and make是这样我don't必须担心编译事情的混乱细节,对吗?不过,这不仅仅是一个 mgiza 问题,因为我在尝试执行此操作时遇到了这个问题make别处。我了解 (C)Makefile 的高级思想,但不了解低级细节。


针对评论者的一些担忧:处理此问题的最佳方法是尝试尽可能地清理您的系统并从头开始该过程。

另外,自从这篇文章发布以来,OS X 10.10 Yosemite 已经发布,这可能已经解决了这个问题(IIRC 这个问题主要是由于 10.9 和 clang/gcc 编译器的更改)。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

boost 的另一个“ld:未找到架构 x86_64 的符号”问题,这次是 mgiza 的相关文章

  • 通过增加索引之和来生成排序组合的有效方法

    对于启发式算法 我需要一个接一个地评估特定集合的组合 直到达到停止标准 由于它们很多 目前我正在使用以下内存高效迭代器块生成它们 受到 python 的启发 itertools combinations http docs python o
  • 在 VS2017 下使用 Conan 和 CMake 项目进行依赖管理

    我正在尝试使用 CMake 与 VS2017 集成为 C 设置一个开发环境 以便在 Linux x64 下进行编译 为了更好地管理依赖关系 我选择使用 Conan 但我对这个软件还很陌生 我想知道让 VS2017 识别项目依赖关系的最佳方法
  • System.IO.IOException:由于意外>数据包格式,握手失败?

    有谁知道这意味着什么 System Net WebException 底层连接已关闭 发送时发生意外错误 gt System IO IOException 由于意外 握手失败 数据包格式 在 System Net Security SslS
  • 从 C 结构生成 C# 结构

    我有几十个 C 结构 我需要在 C 中使用它们 典型的 C 结构如下所示 typedef struct UM EVENT ULONG32 Id ULONG32 Orgin ULONG32 OperationType ULONG32 Size
  • 如何创建用于 QML 的通用对象模型?

    我想知道是否有任何宏或方法如何将 Qt 模型注册为 QObject 的属性 例如 我有AnimalModel http doc qt io qt 5 qtquick modelviewsdata cppmodels html qabstra
  • mprotect 之后 malloc 导致分段错误

    在使用 mprotect 保护内存区域后第一次调用 malloc 时 我遇到分段错误 这是执行内存分配和保护的代码片段 define PAGESIZE 4096 void paalloc int size Allocates and ali
  • 如何使用MySqlCommand和prepare语句进行多行插入?(#C)

    Mysql 给出了如何使用准备语句和 NET 插入行的示例 http dev mysql com doc refman 5 5 en connector net programming prepared html http dev mysq
  • 两种类型的回发事件

    1 我发现了两篇文章 每篇文章对两种类型的回发事件的分类都略有不同 一位资源说两种类型的回发事件是Changed事件 其中控件实现 IPostbackDataHandler 当数据在回发之间更改时触发 然后Raised事件 其中控件实现 I
  • 2D morton 码编码/解码 64 位

    如何将给定 x y 的莫顿代码 z 顺序 编码 解码为 32 位无符号整数 生成 64 位莫顿代码 反之亦然 我确实有 xy2d 和 d2xy 但仅适用于 16 位宽的坐标 产生 32 位莫顿数 在网上查了很多 但没有找到 请帮忙 如果您可
  • libxml2 xmlChar * 到 std::wstring

    libxml2似乎将所有字符串存储在 UTF 8 中 如xmlChar xmlChar This is a basic byte in an UTF 8 encoded string It s unsigned allowing to pi
  • 分配器感知容器和propagate_on_container_swap

    The std allocator traits模板定义了一些常量 例如propagate on container copy move assign让其他容器知道它们是否应该在复制或移动操作期间复制第二个容器的分配器 我们还有propag
  • C++11 动态线程池

    最近 我一直在尝试寻找一个用于线程并发任务的库 理想情况下 是一个在线程上调用函数的简单接口 任何时候都有 n 个线程 有些线程比其他线程完成得更快 并且到达的时间不同 首先我尝试了 Rx 它在 C 中非常棒 我还研究了 Blocks 和
  • tabcontrol selectedindex 更改事件未被触发 C#

    嘿伙计们 我有一个很小的问题 请参阅下面的代码 this is main load private void Form1 Load object sender EventArgs e tabAddRemoveOperator Selecte
  • ASP.NET JQuery AJAX POST 返回数据,但在 401 响应内

    我的应用程序中有一个网页 需要调用我设置的 Web 服务来返回对象列表 这个调用是这样设置的 document ready function var response ajax type POST contentType applicati
  • 0-1背包算法

    以下 0 1 背包问题是否可解 浮动 正值和 浮动 权重 可以是正数或负数 背包的 浮动 容量 gt 0 我平均有 这是一个相对简单的二进制程序 我建议用蛮力进行修剪 如果任何时候你超过了允许的重量 你不需要尝试其他物品的组合 你可以丢弃整
  • 使用 cmake add_definitions 的文件路径

    我正在尝试替换硬编码预处理器 define MY FILE PATH usr local myfile 在 cmake 中使用 add definitions add definitions DMY FILE PATH MY FILE PA
  • 如何引用解决方案之外的项目?

    我有一个 Visual Studio C 解决方案 其中包含一些项目 其中一个项目需要引用另一个不属于解决方案的项目 一开始我引用了dll
  • 在 C++17 中使用 成员的链接错误

    我在 Ubuntu 16 04 上使用 gcc 7 2 并且需要使用 C 17 中的新文件系统库 尽管确实有一个名为experimental filesystem的库 但我无法使用它的任何成员 例如 当我尝试编译此文件时 include
  • C语言声明数组没有初始大小

    编写一个程序来操纵温度详细信息 如下所示 输入要计算的天数 主功能 输入摄氏度温度 输入功能 将温度从摄氏度转换为华氏度 独立功能 查找华氏度的平均温度 我怎样才能在没有数组初始大小的情况下制作这个程序 include
  • 类中不允许使用不完整类型,但类模板中允许使用不完整类型

    以下为无效代码 struct foo struct bar bar x error field x has incomplete type struct bar int value 42 int main return foo x valu

随机推荐