• <small id='CLgby'></small><noframes id='CLgby'>

      • <bdo id='CLgby'></bdo><ul id='CLgby'></ul>
      <tfoot id='CLgby'></tfoot>

      1. <legend id='CLgby'><style id='CLgby'><dir id='CLgby'><q id='CLgby'></q></dir></style></legend>
      2. <i id='CLgby'><tr id='CLgby'><dt id='CLgby'><q id='CLgby'><span id='CLgby'><b id='CLgby'><form id='CLgby'><ins id='CLgby'></ins><ul id='CLgby'></ul><sub id='CLgby'></sub></form><legend id='CLgby'></legend><bdo id='CLgby'><pre id='CLgby'><center id='CLgby'></center></pre></bdo></b><th id='CLgby'></th></span></q></dt></tr></i><div id='CLgby'><tfoot id='CLgby'></tfoot><dl id='CLgby'><fieldset id='CLgby'></fieldset></dl></div>

        自 Mojave 以来,链接在自制软件的 cmake 中不起作用

        Linking not working in homebrew#39;s cmake since Mojave(自 Mojave 以来,链接在自制软件的 cmake 中不起作用)

        • <bdo id='NjJqN'></bdo><ul id='NjJqN'></ul>
            <i id='NjJqN'><tr id='NjJqN'><dt id='NjJqN'><q id='NjJqN'><span id='NjJqN'><b id='NjJqN'><form id='NjJqN'><ins id='NjJqN'></ins><ul id='NjJqN'></ul><sub id='NjJqN'></sub></form><legend id='NjJqN'></legend><bdo id='NjJqN'><pre id='NjJqN'><center id='NjJqN'></center></pre></bdo></b><th id='NjJqN'></th></span></q></dt></tr></i><div id='NjJqN'><tfoot id='NjJqN'></tfoot><dl id='NjJqN'><fieldset id='NjJqN'></fieldset></dl></div>
                <tbody id='NjJqN'></tbody>

                1. <tfoot id='NjJqN'></tfoot><legend id='NjJqN'><style id='NjJqN'><dir id='NjJqN'><q id='NjJqN'></q></dir></style></legend>

                  <small id='NjJqN'></small><noframes id='NjJqN'>

                  本文介绍了自 Mojave 以来,链接在自制软件的 cmake 中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我现在已经在两台计算机上重现了这个症状,cmake 似乎不再查看 /usr/local/lib(或者更准确地说,$(brew --prefix)/lib) 用于自将我的机器升级到 macOS Mojave 以来 Homebrew 提供的库.

                  I've reproduced this symptom on two computers now, cmake seems to no longer look in /usr/local/lib (or more properly, $(brew --prefix)/lib) for Homebrew-provided libraries since upgrading my machine to macOS Mojave.

                  尽管有一些方法可以绕过这个(例如,使用 EXECUTE_PROCESS 搜索 homebrew 前缀;将结果添加到 LINK_LIBRARIES(...) 命令)没有一个是理想的.Mojave 发生了什么改变来打破这种行为?

                  Although there are ways to circumvent this (e.g. search for homebrew prefix using EXECUTE_PROCESS; add the result to LINK_LIBRARIES(...) command) none are ideal. What changed in Mojave to break this behavior?

                  临时解决方法是将以下内容添加到 CMakeLists.txt:

                  The temporary workaround is to add the following to CMakeLists.txt:

                  # WARNING: Don't hard-code this path
                  LINK_DIRECTORIES(/usr/local/lib)
                  

                  我已经尝试过 brew doctor 并更新了所有自制软件包但无济于事.

                  I've already tried brew doctor and updated all homebrew packages to no avail.

                  cmake (make) 显示的具体错误是:

                  The specific error that cmake (make) shows is:

                  ld: library not found for -l<somelib>
                  

                  我在 Homebrew 论坛上问过这个问题 和 Apple 开发者论坛.

                  I've asked the question on the Homebrew forums and the Apple developer forums.

                  推荐答案

                  我已将此与 VERBOSE=1 make 日志中的以下更改隔离...

                  I've isolated this to the following change in the VERBOSE=1 make logs...

                  • High Sierra (<=10.13) 及以下版本使用 -isysroot 命令.
                  • Mojave (>=10.14) 确实使用 -isysroot 命令.
                  • High Sierra (<=10.13) and below did NOT use the -isysroot command.
                  • Mojave (>=10.14) DOES use the -isysroot command.

                  来自 gnu.org:

                  -isysroot

                  此选项类似于 --sysroot 选项,但仅适用于头文件(除了 Darwin 目标,它同时适用于头文件和库).有关详细信息,请参阅 --sysroot 选项.

                  -isysroot <dir> This option is like the --sysroot option, but applies only to header files (except for Darwin targets, where it applies to both header files and libraries). See the --sysroot option for more information.

                  因此,此标志仅在 Apple 上专门破坏了 lib 搜索路径.这导致编译永远不会在标准 ld 位置查找,这可以通过键入 ld -v dummy 来查看.

                  So this flag specifically clobbers the lib search path only on Apple. This results in the compilation never looking in the standard ld locations, which can be seen by typing ld -v dummy.

                  Library search paths:
                      /usr/lib
                      /usr/local/lib
                  

                  cmake 为什么要这样做?我的想法是修复新 Mojave SDK 引入的 /usr/local/include 问题行为.

                  Why does cmake do this? My thought is it was to fix the /usr/local/include issues introduced with the new Mojave SDK behavior.

                  不幸的是,我找不到 cmake 编译标志来添加默认库搜索路径.现在我找到的唯一解决方案是将以下内容添加到我的项目中:

                  Unfortunately, I can't find a cmake compile flag to add the default library search paths back in. For now the only solution I've found is to add the following to my project:

                  IF(APPLE)
                      # Fix linking on 10.14+. See https://stackoverflow.com/questions/54068035
                      LINK_DIRECTORIES(/usr/local/lib)
                  ENDIF()
                  

                  我不确定这是否是需要上游 cmake 补丁的行为.如果有更好的解决方案,请提供.

                  I'm not sure if this is a behavior that warrants an upstream cmake patch. If there is a better solution, please provide it.

                  这篇关于自 Mojave 以来,链接在自制软件的 cmake 中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  What is inside .lib file of Static library, Statically linked dynamic library and dynamically linked dynamic library?(静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么?)
                  How do I load a C DLL from the SXS in Python?(如何从 Python 中的 SXS 加载 C DLL?)
                  Can Cython code be compiled to a dll so C++ application can call it?(Cython 代码可以编译成 dll 以便 C++ 应用程序可以调用它吗?)
                  Delay Loading DLLs(延迟加载 DLL)
                  Throwing C++ exceptions across DLL boundaries(跨 DLL 边界抛出 C++ 异常)
                  Loading a dll from a dll?(从 dll 加载 dll?)

                      <bdo id='mhX3G'></bdo><ul id='mhX3G'></ul>

                        <tbody id='mhX3G'></tbody>

                      <legend id='mhX3G'><style id='mhX3G'><dir id='mhX3G'><q id='mhX3G'></q></dir></style></legend>

                          <small id='mhX3G'></small><noframes id='mhX3G'>

                          1. <tfoot id='mhX3G'></tfoot>
                            <i id='mhX3G'><tr id='mhX3G'><dt id='mhX3G'><q id='mhX3G'><span id='mhX3G'><b id='mhX3G'><form id='mhX3G'><ins id='mhX3G'></ins><ul id='mhX3G'></ul><sub id='mhX3G'></sub></form><legend id='mhX3G'></legend><bdo id='mhX3G'><pre id='mhX3G'><center id='mhX3G'></center></pre></bdo></b><th id='mhX3G'></th></span></q></dt></tr></i><div id='mhX3G'><tfoot id='mhX3G'></tfoot><dl id='mhX3G'><fieldset id='mhX3G'></fieldset></dl></div>