简体   繁体   中英

Trying to using .dylib with Xcode project

I am trying to use a 3rd party .dylib (simple C API) in my Mac OS Xcode Project (Not iOS). I either get "library not found for -...dylib" or "Undefined symbol: ...."

Xcode 10.3 (10G8) running on iMac with Mojave 10.14.6

I've found several articles relating to this problem and tried lots of options including: • Drag the .dylib into my project. Then went to project - target - build phases and verified that the .dylib was present under Link Binary with Libraries. I then include the supplied .h file into my project and attempt to call one of the C functions from the lib, but I always get "Undefined symbol: " during the link process.

• After this I tried going to my build settings and adding the .dylib to "Other Linker Flags" (eg -libname). I also added its location to "Library Search Paths" (eg "$(SRCROOT)/Libraries/") - the library is in a folder called 'Libraries' which is located in same the directory as my Xcode project. This changes the link error message to "library not found for -...dylib"

According to the 3rd party who developed the .dylib it "comes as a shared library with a simple C API. is available for 32 and 64-bits architectures on Windows (DLL) and Linux (DSO)."

The library file is actually named, by them, as .dylib

My project builds as 64bit intel for Mac OS 10.14

Problem solved. Turned out the function, while present in the header file, is NOT actually in the binary. So pretty much Xcode was telling me the facts, I just didn't believe it. Note to self: don't second guess the linker.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM