Search code examples
c++xcodestatic-librarieslddjinni

Library not found for -ljson11 but -lsqlite 3 is found


I'm trying to implement this tutorial with the addition that I want to include the json11 C++ library.

I followed the same process for both, downloaded the repo from: https://github.com/libmx3/mx3, added them to the /deps/ folder of my project, and ran GYP to generate the .xcodeproj files for both.

Then I create a C++ project, add both the projects into the workspace, and add the libraries under Build Phases->Link binaries with libraries.

When I hit run the build fails with ld: library not found for -ljson11

I have tried regenerating them and adding them into the main xcodeproj. and into the Target Dependencies. I have double-checked the library projects and they are identical. I have also added the folders where the .a files are compiled in Library Search paths but none of this makes a difference. If I remove the json11 dependency the project compiles, but I can't understand why the sqlite3 is found and throws no errors but the identical json11 project won't work.

I can see the .a files in the Debug-build folder and there are no errors if I build them separately.

Heres the full build log

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)

Edit: even if I add the compiled files into the project so that they turn black, it still complains that the ljson11 library is not found. Maybe there's something wrong with the way the library is compiled?


Solution

  • Both the libraries gave warning that "macosx" was not found in the supported platforms. When I added it into the json11 project settings, the build compiled and both the warnings disappeared.

    SQlite3 still only has iOS(iphone,iphonesimulator) but it compiles fine. I wonder what the difference is.