gpt4 book ai didi

android - NDK 链接库与 cmake

转载 作者:行者123 更新时间:2023-11-28 04:34:02 25 4
gpt4 key购买 nike

我有一个进行 opengl (es 2.0) 渲染的 c++ 库,我想在 android 上使用它。将库与 target_link_libraries(mylib log GLESv2) 链接时,我收到以下错误:

ld: error: cannot open crtbegin_so.o: No such file or directory
ld: error: cannot open crtend_so.o: No such file or directory
ld: error: cannot find -llog
ld: error: cannot find -lGLESv2
ld: error: cannot find -lm
ld: error: cannot find -lstdc++
ld: error: cannot find -lm
ld: error: cannot find -ldl
ld: error: cannot find -lc
ld: error: cannot find -ldl

如果我手动提供来自 android ndk 的特定目录,它就可以工作。在 cmake 中,这看起来类似于:

link_directories( ${ANDROID_NDK}/platforms/${ANDROID_API}/arch-${ANDROID_ABI}/usr/lib )

我想知道这是否是解决错误的正确方法。在这个简单的example不需要 link_directories 的附加定义。我的图书馆有什么不同?

最佳答案

原因很简单。我在我的 cmake 文件中覆盖了编译器标志:

SET(CMAKE_CXX_FLAGS "-foo" )

当我把它改成

SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -foo" )

链接问题消失了。

关于android - NDK 链接库与 cmake,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52046168/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com