c++ - 找不到 -ljson11 的库,但找到 -lsqlite 3

标签 c++ xcode static-libraries ld djinni

我正在尝试实现 this tutorial另外我想包括 json11 C++ 库。

我对两者都遵循了相同的过程,从以下位置下载了 repo: https://github.com/libmx3/mx3 ,将它们添加到我项目的/deps/文件夹中,然后运行 ​​GYP 为两者生成 .xcodeproj 文件。

然后我创建一个 C++ 项目,将这两个项目添加到工作区中,并在构建阶段->将二进制文件与库链接下添加库。

当我点击运行时,构建失败并显示 ld: library not found for -ljson11

我已经尝试重新生成它们并将它们添加到主 xcodeproj 中。并进入目标依赖项。 我仔细检查了图书馆项目,它们是相同的。我还添加了在库搜索路径中编译 .a 文件的文件夹,但这都没有什么区别。如果我删除项目编译的 json11 依赖项,但我不明白为什么找到 sqlite3 并且没有抛出任何错误,但相同的 json11 项目将无法运行。

我可以在 Debug-build 文件夹中看到 .a 文件,如果我单独构建它们没有错误。

这是完整的构建日志

Ld /Users/myuser/Library/Developer/Xcode/DerivedData/DjinniTest-eqaqzcfyskdxupbqpdngkdmoidtq/Build/Products/Debug/DjinniTest normal x86_64
cd /Users/myuser/Documents/Dev/djinni_test/cpp_project
export MACOSX_DEPLOYMENT_TARGET=10.11
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++
-arch x86_64
-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk
-L/Users/myuser/Library/Developer/Xcode/DerivedData/DjinniTest-eqaqzcfyskdxupbqpdngkdmoidtq/Build/Products/Debug
-L/Users/myuser/Library/Developer/Xcode/DerivedData/DjinniTest-eqaqzcfyskdxupbqpdngkdmoidtq/Build/Products/Debug/..
-F/Users/myuser/Library/Developer/Xcode/DerivedData/DjinniTest-eqaqzcfyskdxupbqpdngkdmoidtq/Build/Products/Debug
-filelist /Users/myuser/Library/Developer/Xcode/DerivedData/DjinniTest-eqaqzcfyskdxupbqpdngkdmoidtq/Build/Intermediates/DjinniTest.build/Debug/DjinniTest.build/Objects-normal/x86_64/DjinniTest.LinkFileList
-mmacosx-version-min=10.11
-stdlib=libc++
-ljson11
-lsqlite3
-Xlinker
-dependency_info
-Xlinker /Users/myuser/Library/Developer/Xcode/DerivedData/DjinniTest-eqaqzcfyskdxupbqpdngkdmoidtq/Build/Intermediates/DjinniTest.build/Debug/DjinniTest.build/Objects-normal/x86_64/DjinniTest_dependency_info.dat
-o /Users/myuser/Library/Developer/Xcode/DerivedData/DjinniTest-eqaqzcfyskdxupbqpdngkdmoidtq/Build/Products/Debug/DjinniTest

ld: library not found for
 -ljson11
clang: error: linker command failed with exit code 1 (use -v to see invocation)

编辑: 即使我将编译后的文件添加到项目中,使它们变黑,它仍然提示找不到 ljson11 库。也许库的编译方式有问题?

最佳答案

这两个库都发出警告,在支持的平台中找不到“macosx”。当我将它添加到 json11 项目设置中时,构建已编译并且两个警告都消失了。

SQlite3 仍然只有 iOS(iphone,iphonesimulator) 但它编译得很好。我想知道有什么区别。

关于c++ - 找不到 -ljson11 的库,但找到 -lsqlite 3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34200373/

相关文章:

c++ - 重载模板运算符*

ios - MailChimp中的电子邮件,名称和自定义属性(快速3)

xcode - 在 iOS Cocoa 静态库项目中使用 Objective-C 代码,在 iOS 应用程序项目中使用 Swift 代码

ios - 如何合并为 armv7 和 i386 构建的两个 .a 文件?

c++ - 最佳实践 - 合并多个翻译单元中的重复文本文字

c++我可以声明类成员并在构造函数中初始化它吗

iphone - 如何在 Xcode 4 上处理 Info.plist 的 "Clear File History"?

ios - 更改项目名称后,找不到版本设置

assembly - 为什么 CMake 在构建静态库时会忽略程序集文件?

c++ - 如何遍历 multimap 并打印按键分组的值?