Mac OS X libcurl dylib compatibility version - macos

My application builds and runs fine on 10.6. I have Base SDK set to 10.6 and Mac OS X Deployment Target set to 10.5.
My application uses the system libcurl.dylib — instead of adding the dylib to the project, I just add -lcurl to the linker flags in build settings. (Though I have tried it both ways.)
When I launch the application on 10.5.8, I get the following error
Dyld Error Message: Library not loaded: /usr/lib/libcurl.4.dylib
Referenced from: /Applications/My Application.app/Contents/MacOS/MyApplication
Reason: Incompatible library version:
MyApplication requires version 6.0.0 or
later, but libcurl.4.dylib provides
version 5.0.0
Sure enough, if I otool -L the application's binary, I get the following for libcurl:
/usr/lib/libcurl.4.dylib (compatibility version 6.0.0, current version 6.1.0)
Is there any way around this, or should I just statically link my own libcurl build?

Have you tried setting the Base SDK to 10.5 as well?
$ otool -L /Developer/SDKs/MacOSX10.6.sdk/usr/lib/libcurl.4.dylib
/Developer/SDKs/MacOSX10.6.sdk/usr/lib/libcurl.4.dylib:
/usr/lib/libcurl.4.dylib (compatibility version 6.0.0, current version 6.1.0)
...]
$ otool -L /Developer/SDKs/MacOSX10.5.sdk/usr/lib/libcurl.4.dylib
/Developer/SDKs/MacOSX10.5.sdk/usr/lib/libcurl.4.dylib:
/usr/lib/libcurl.4.dylib (compatibility version 5.0.0, current version 5.0.0)
[...]

Related

Why are my system libraries and frameworks not visible in macOS Monterey?

I was checking some dependencies with otool -L on a dylib I just built, and got the following system dependencies:
/System/Library/Frameworks/Accelerate.framework/Versions/A/Accelerate (compatibility version 1.0.0, current version 4.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1311.0.0)
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1853.0.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1200.3.0)
The library is working fine on my system (macOS 12.0.1 on a macbook air m1) but to my great surprise when I tried to check those 4 libraries, they seems to be absent from my system.
/usr/lib does not contain libc++.1.dylib and libSystem.B.dylib, and /System/Library/Frameworks seems to contain mostly empty structures for Accelerate and CoreFoundation frameworks, without the libraries themselves. And yet my dylib is perfectly working, which I cannot explain.
When I check an older system such as macOS 10.14 I can see those 4 libraries and frameworks where expected.
Did something change recently in macOS that somehow hides those system libraries or silently route them elsewhere ? How/where can I see them ?
The reason is explained here: https://developer.apple.com/forums/thread/655588
Since Big Sur, it somehow all became virtual. I still don't understand how it works though, but it works...

Setting up LLDB debugger in Qt 5.4 on Mac OS X Darwin Kernel Version 14.3.0

I have installed Qt 5.4 on MacOSX Darwin Kernel Version 14.3.0 and
am trying to setup LLDB Debugger as GDB has been depurated from MacOSX (as i didn't found it as default).
When i am trying to setting up debugger option in Build & Run kit in Qt Creator following below steps mentioned in Qt Documentation :
Select Tools > Options > Build & Run > Kits.
Select an automatically created kit in the list, and then select
Clone to create a copy of the kit.
In the Debugger field, select an LLDB Engine.
If an LLDB Engine is not listed, select Manage to add
it in Tools > Options > Build & Run > Debuggers.
For more information, see Adding Debuggers. To use the debugger,
add the kit in the Build Settings of the project.
I am setting the Debugger as "/usr/bin/lldb" in the Build&Run Kit.
After following all the steps correctly as mentioned various forums when i try to set the breakpoint and run the Qt project in Debug mode it is not hitting the breakpoint.It running as "Run" option Not working like "DEBUG" Mode.
I have one small question or maybe asking for suggestion regarding following error which i resolved but i don't know whether its correct way to do that.
When trying to run an executable I've been sent in Mac OS X, I get the following error
dyld: Library not loaded: libLocalIPC.1.dylib
Referenced from: /Users/"Directory my executable is in"
Reason: image not found.
I fixed this issue with setting Environment DYLD_LIBRARY_PATH under Project Settings/Run Environment with the library path which points to debut version of library.So for Building my Application in Release i have to again set the Library Path with Release Library Path.So this solution is not correct.
Another Solution i tried before that was with using otool -L #executable_Path/XXX.exe and checking the path of dylib and changing it with,install_name tool of Xcode but it didn't worked also.
Example:
MacOS xxx$ otool -L check abc
libLocalIPC.1.dylib (compatibility version 1.0.0, current version 1.0.0)
libxxx.1.dylib (compatibility version 1.0.0, current version 1.0.0)
libqyyy.1.dylib (compatibility version 1.0.0, current version 1.0.0)
libzzz.1.dylib (compatibility version 1.0.0, current version 1.0.0)
/Users/spandey/Qt/5.4/clang_64/lib/QtWebEngineWidgets.framework/Versions/5/QtWebEngineWidgets (compatibility version 5.4.0, current version 5.4.1)
/Users/spandey/Qt/5.4/clang_64/lib/QtWebEngine.framework/Versions/5/QtWebEngine (compatibility version 5.4.0, current version 5.4.1)
/Users/spandey/Qt/5.4/clang_64/lib/QtQuick.framework/Versions/5/QtQuick (compatibility version 5.4.0, current version 5.4.1)
/Users/spandey/Qt/5.4/clang_64/lib/QtGui.framework/Versions/5/QtGui (compatibility version 5.4.0, current version 5.4.1)
After this i set the path to libs libxxx.1.dylib,libyyy.1.dylib & libzzz.1.dylib and again run the otool -L abc
Results :Administrators-Mac-Pro:MacOS spandey$ otool -L abc
abc:
/Users/spandey/Desktop/Perforce/launcher/xxx/libxxx.1.dylib (compatibility version 1.0.0, current version 1.0.0)
/Users/spandey/Desktop/Perforce/launcher/ThirdParty/yyy/lib_osx/libqyyy.1.dylib (compatibility version 1.0.0, current version 1.0.0)
/Users/spandey/Desktop/Perforce/launcher/ThirdParty/zzz/debug_osx/libzzz.1.dylib (compatibility version 1.0.0, current version 1.0.0)
/Users/spandey/Qt/5.4/clang_64/lib/QtWebEngineWidgets.framework/Versions/5/QtWebEngineWidgets (compatibility version 5.4.0, current version 5.4.1
MacOS xxx$ ./abc
dyld: Library not loaded: libzzz.1.dylib
Referenced from:
/Users/spandey/Desktop/Perforce/launcher/xxx/libxxx.1.dylib
Reason: image not found
Trace/BPT trap: 5
Please can some one help me in both the issues as i am trying this from last 3 days with no success.

QuickLook PlugIn is "damaged/missing resources". Why?

SETUP:
OS X 10.8.2
Xcode4.5.2 (4G2008a)
Document-based Cocoa Application with a QuickLook PlugIn
PROBLEM:
I'm trying to add a QuickLook plugin to my Document-based OS X application, but the QL PlugIn will not launch.
My QuickLook PlugIn needs to embed and link to two Frameworks that I've created myself (Called IDEKit and TDAppKit). I've read this SO post about linking Frameworks in QuickLook PlugIns, and followed the instructions there (I set the DYLIB_INSTALL_NAME_BASE of my two Frameworks to #loader_path/../Frameworks).
Here's some relevant information about my QuickLook PlugIn after it is built:
% otool -L /Users/itod/Library/Developer/Xcode/DerivedData/Shapes-bqzarhutlkqukverhbjatfvaextg/Build/Products/Debug/Shapes.app/Contents/Library/QuickLook/ShapesQuickLook.qlgenerator/Contents/MacOS/ShapesQuickLook
/Users/itod/Library/Developer/Xcode/DerivedData/Shapes-bqzarhutlkqukverhbjatfvaextg/Build/Products/Debug/Shapes.app/Contents/Library/QuickLook/ShapesQuickLook.qlgenerator/Contents/MacOS/ShapesQuickLook:
/usr/lib/libcrypto.0.9.8.dylib (compatibility version 0.9.8, current version 47.0.0)
#loader_path/../Frameworks/IDEKit.framework/Versions/A/IDEKit (compatibility version 1.0.0, current version 1.0.0)
#loader_path/../Frameworks/TDAppKit.framework/Versions/A/TDAppKit (compatibility version 1.0.0, current version 1.0.0)
/System/Library/Frameworks/QuickLook.framework/Versions/A/QuickLook (compatibility version 1.0.0, current version 555.4.0)
/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0)
/System/Library/Frameworks/Security.framework/Versions/A/Security (compatibility version 1.0.0, current version 55179.0.2)
/System/Library/Frameworks/QuartzCore.framework/Versions/A/QuartzCore (compatibility version 1.2.0, current version 1.8.0)
/System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 19.0.0)
/System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices (compatibility version 1.0.0, current version 45.0.0)
/System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices (compatibility version 1.0.0, current version 57.0.0)
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 744.1.0)
/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 945.11.0)
/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)
/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 1187.33.0)
The linked/embedded Frameworks are in place:
% file /Users/itod/Library/Developer/Xcode/DerivedData/Shapes-bqzarhutlkqukverhbjatfvaextg/Build/Products/Debug/Shapes.app/Contents/Library/QuickLook/ShapesQuickLook.qlgenerator/Contents/MacOS/ShapesQuickLook
/Users/itod/Library/Developer/Xcode/DerivedData/Shapes-bqzarhutlkqukverhbjatfvaextg/Build/Products/Debug/Shapes.app/Contents/Library/QuickLook/ShapesQuickLook.qlgenerator/Contents/MacOS/ShapesQuickLook: Mach-O universal binary with 2 architectures
/Users/itod/Library/Developer/Xcode/DerivedData/Shapes-bqzarhutlkqukverhbjatfvaextg/Build/Products/Debug/Shapes.app/Contents/Library/QuickLook/ShapesQuickLook.qlgenerator/Contents/MacOS/ShapesQuickLook (for architecture x86_64): Mach-O 64-bit bundle x86_64
/Users/itod/Library/Developer/Xcode/DerivedData/Shapes-bqzarhutlkqukverhbjatfvaextg/Build/Products/Debug/Shapes.app/Contents/Library/QuickLook/ShapesQuickLook.qlgenerator/Contents/MacOS/ShapesQuickLook (for architecture i386): Mach-O bundle i386
% file /Users/itod/Library/Developer/Xcode/DerivedData/Shapes-bqzarhutlkqukverhbjatfvaextg/Build/Products/Debug/Shapes.app/Contents/Library/QuickLook/ShapesQuickLook.qlgenerator/Contents/Frameworks/IDEKit.framework/IDEKit
/Users/itod/Library/Developer/Xcode/DerivedData/Shapes-bqzarhutlkqukverhbjatfvaextg/Build/Products/Debug/Shapes.app/Contents/Library/QuickLook/ShapesQuickLook.qlgenerator/Contents/Frameworks/IDEKit.framework/IDEKit: Mach-O universal binary with 2 architectures
/Users/itod/Library/Developer/Xcode/DerivedData/Shapes-bqzarhutlkqukverhbjatfvaextg/Build/Products/Debug/Shapes.app/Contents/Library/QuickLook/ShapesQuickLook.qlgenerator/Contents/Frameworks/IDEKit.framework/IDEKit (for architecture x86_64): Mach-O 64-bit dynamically linked shared library x86_64
/Users/itod/Library/Developer/Xcode/DerivedData/Shapes-bqzarhutlkqukverhbjatfvaextg/Build/Products/Debug/Shapes.app/Contents/Library/QuickLook/ShapesQuickLook.qlgenerator/Contents/Frameworks/IDEKit.framework/IDEKit (for architecture i386): Mach-O dynamically linked shared library i386
% file /Users/itod/Library/Developer/Xcode/DerivedData/Shapes-bqzarhutlkqukverhbjatfvaextg/Build/Products/Debug/Shapes.app/Contents/Library/QuickLook/ShapesQuickLook.qlgenerator/Contents/Frameworks/TDAppKit.framework/TDAppKit
/Users/itod/Library/Developer/Xcode/DerivedData/Shapes-bqzarhutlkqukverhbjatfvaextg/Build/Products/Debug/Shapes.app/Contents/Library/QuickLook/ShapesQuickLook.qlgenerator/Contents/Frameworks/TDAppKit.framework/TDAppKit: Mach-O universal binary with 2 architectures
/Users/itod/Library/Developer/Xcode/DerivedData/Shapes-bqzarhutlkqukverhbjatfvaextg/Build/Products/Debug/Shapes.app/Contents/Library/QuickLook/ShapesQuickLook.qlgenerator/Contents/Frameworks/TDAppKit.framework/TDAppKit (for architecture x86_64): Mach-O 64-bit dynamically linked shared library x86_64
/Users/itod/Library/Developer/Xcode/DerivedData/Shapes-bqzarhutlkqukverhbjatfvaextg/Build/Products/Debug/Shapes.app/Contents/Library/QuickLook/ShapesQuickLook.qlgenerator/Contents/Frameworks/TDAppKit.framework/TDAppKit (for architecture i386): Mach-O dynamically linked shared library i386
However, when I try to launch my QuickLook PlugIn using qlmanage and a test document, I get the following error:
dyld: DYLD_ environment variables being ignored because main executable (/System/Library/Frameworks/QuickLook.framework/Versions/A/Resources/quicklookd.app/Contents/MacOS/qlmanage) is code signed with entitlements
Testing Quick Look preview with files:
/Users/itod/Desktop/test.shapes
[ERROR] Can't load plug-in at file://localhost/Users/itod/Library/Developer/Xcode/DerivedData/Shapes-bqzarhutlkqukverhbjatfvaextg/Build/Products/Debug/Shapes.app/Contents/Library/QuickLook/ShapesQuickLook.qlgenerator/: The bundle “ShapesQuickLook” couldn’t be loaded because it is damaged or missing necessary resources.
Note the:
The bundle “ShapesQuickLook” couldn’t be loaded because it is damaged or missing necessary resources.
I'm not certain that this issue is caused by a problem with embedded Frameworks (but I think it probably is).
What might I be missing? How can I get my QuickLook PlugIn to launch?
OP here. I found the solution in this blog post about Dylibs, Install Names, and rpaths.
Specifically, the advice under the #rpath section worked for me.
So in my embedded frameworks, I set the DYLIB_INSTALL_NAME_BASE to be #rpath/.
Then I have an App and a QL PlugIn which each embed the frameworks:
In my Application target's build settings, I added the following Other Linker Flags: -rpath #executable_path/../Frameworks/.
And in my QuickLook Plugin target's build settings I added the following Other Linker Flags: -rpath #loader_path/../Frameworks/.
That solved the issue. Now the app and the QL PlugIn work correctly.

dyld not loaded Reason: image not found libopencv_core.2.4.dylib

I'm still quite new to Objective C and Xcode, but I just finished a small app that uses the openCV libopencv_core.2.4.2.dylib.
When I went to open the final built app on another machine, OS X threw me this error:
Dyld Error Message: Library not loaded: */libopencv_core.2.4.dylib
Referenced from: /Users/USER/Desktop/my
app.app/Contents/MacOS/my app
Reason: image not found
Why is my app looking for 2.4 instead of 2.4.2 here?
What I already checked:
I added a new build phase -> so that libopencv_core.2.4.2.dylib is copied to the app package (via "Copy Bundle Resources" in Xcode) - libopencv_core.2.4.2.dylib now lies in my app.app/Resources
What did I miss? Do I have so set some more library search paths or similar?
What I also did:
install_name_tool -id "#executable_path/../Frameworks/libopencv_core.2.4.2.dylib" libopencv_core.2.4.2.dylib
Copying the dylib to the Frameworks directory doesn't work either:
Library not loaded: #executable_path/../Frameworks/libopencv_core.2.4.2.dylib
Don't know what to do now - the dylib is in the Frameworks directory of my app...
Using otool -L on the binary gives me:
/System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 19.0.0)
#loader_path/../Frameworks/libopencv_core.2.4.2.dylib (compatibility version 2.4.0, current version 2.4.2)
#loader_path/../Frameworks/libopencv_highgui.2.4.2.dylib (compatibility version 2.4.0, current version 2.4.2)
#loader_path/../Frameworks/libopencv_imgproc.2.4.2.dylib (compatibility version 2.4.0, current version 2.4.2)
/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 945.11.0)
/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 56.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 744.1.0)
/System/Library/Frameworks/CoreData.framework/Versions/A/CoreData (compatibility version 1.0.0, current version 407.7.0)
/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 1187.33.0)
I had the same problem. i keep all .dylib in system root directory usr/lib it working fine. At the run time .o file not get .dylib file path then it gives an error.
I found a better solution: recompiling openCV in Xcode and set the #executable_path/../Frameworks in the build settings, for every .dylib you compile - now the .dylibs themselves always "know where they are".
Since other answers are not clear enough;
Assume your dylib files are located in /usr/local/opt/opencv3/lib
sudo ln -s /usr/local/opt/opencv3/lib/*.dylib /usr/local/lib
will solve this problem. Be aware that /usr/lib is protected by system in MacOS, thus you should use /usr/local/lib.

dylib #executable_path path issue in a plug-in bundle

I am developing a plug-in bundle, say MyPlugIn.bundle for an application, say BigApp.app. This bundle requires a dylib, say MyPlugIn.bundle/Contents/Resources/library.dylib. I have relocated paths for library.dylib, as I would have done for a simple application bundle:
$ otool -L MyPlugIn.bundle/Contents/MacOS/MyPlugIn
MyPlugIn.bundle/Contents/MacOS/MyPlugIn:
#executable_path/../Resources/library.dylib (compatibility version 0.0.0, current version 0.0.0)
[...]
$ otool -L MyPlugIn.bundle/Contents/Resources/library.dylib
MyPlugIn.bundle/Contents/Resources/library.dylib:
#executable_path/../Resources/library.dylib (compatibility version 0.0.0, current version 0.0.0)
[...]
But BigApp.app fails to load this bundle, and Mac OS X's Console.app logs what follows:
19/01/10 15:42:59 BigApp[51516] Error loading /Library/Application Support/BigApp/Plug-Ins/MyPlugIn.bundle/Contents/MacOS/MyPlugIn: dlopen(/Library/Application Support/BigApp/Plug-Ins/MyPlugIn.bundle/Contents/MacOS/MyPlugIn, 262): Library not loaded: #executable_path/../Resources/library.dylib
Referenced from: /Library/Application Support/BigApp/Plug-Ins/MyPlugIn.bundle/Contents/MacOS/MyPlugIn
Reason: image not found
It seems that #executable_path is not replaced by the MyPlugIn.bundle executable path but by the BigApp.app executable path.
Any workaround to that, without absolute path and so that it will work on Mac OS X 10.4 (Tiger)? Thanks.
From the web and other SO questions: use #loader_path/.. instead of #executable_path/... See:
http://developer.apple.com/mac/library/documentation/Darwin/Reference/ManPages/man1/dyld.1.html
http://lapcatsoftware.com/blog/2007/08/11/embedding-frameworks-in-loadable-bundles/
How to distribute a Mac OS X with dependent libraries?
Installing IB plugin

Resources