如何将Find_library的结果添加到Cmakelist?

发布于 2025-01-22 05:54:34 字数 496 浏览 2 评论 0原文

正在阅读以下内容:

https://discuss.cocos2d-x.org/t/xcode-12-2-2--erorors-when-when-ios-simulator-with-cocos2d-x-4-0/52203/22 < /a>

我对Cmake的了解不多,

find_library(libiconv NAMES libiconv)
find_library(libz NAMES libz)

我相信以上行会发现一些丢失的库,但是要使事情正常工作,我需要将结果添加到库列表中。

如何添加结果?

Was reading this:

https://discuss.cocos2d-x.org/t/xcode-12-2-errors-when-ios-simulator-with-cocos2d-x-4-0/52203/22

I don't know much about CMake

find_library(libiconv NAMES libiconv)
find_library(libz NAMES libz)

I believe the above lines will find some missing libraries, but to get things to work, I need to add the result to the library list.

How do I add the result ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

千仐 2025-01-29 05:54:34

find_library填充您将其作为第一个参数传递的变量,并使用找到的库路径(如果有)。因此,您在target_link_libraries命令中使用此变量。这样就是这样:

find_library(ICONV_LIB NAMES libiconv)
target_link_libraries(YourTarget ${ICONV_LIB})

另外,您应该先熟悉Cmake,因为您显然不知道自己在做什么。两者 zlib &amp; iconv

find_package(ZLIB REQUIRED)
find_package(Iconv REQUIRED)
target_link_libraries(YourTarget Iconv::Iconv ZLIB::ZLIB)

find_library populates the variable which you pass as the first argument with the found library path, if any. So you use this variable in target_link_libraries command. It would be something like this:

find_library(ICONV_LIB NAMES libiconv)
target_link_libraries(YourTarget ${ICONV_LIB})

Also you should get familiar with CMake first because you clearly don't know what you are doing. Both zlib & iconv have find modules so what you really want to do is this:

find_package(ZLIB REQUIRED)
find_package(Iconv REQUIRED)
target_link_libraries(YourTarget Iconv::Iconv ZLIB::ZLIB)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文