Running the program on OSX fails
Posted by: Igor Korot
Date: October 10, 2023 08:25PM

Hi, ALL,

I built libmysqlclient from sources on my Apple laptop. Everything built fine.

Then I built my program that will be using this on the same laptop. The build succeeded. I'm using the Xcode to build my program

In the end of the build it runs following command:

    cp -f ~/dbhandler/dbhandler/mysql-server/BuildOSX/libmysql/libmysqlclient.dylib "$TARGET_BUILD_DIR/$TARGET_NAME.app/Contents/Frameworks/libmysqlclient.dylib"
    
    install_name_tool -id "@rpath/Frameworks/libmysqlclient.dylib" "$TARGET_BUILD_DIR/$TARGET_NAME.app/Contents/Frameworks/libmysqlclient.dylib"
    
    cp ~/dbhandler/dbhandler/Build/Products/Debug/liblibmysql.dylib "$TARGET_BUILD_DIR/$TARGET_NAME.app/Contents/Frameworks/liblibmysql.dylib"
    
    install_name_tool -id '@rpath/Frameworks/liblibmysql.dylib' "$TARGET_BUILD_DIR/$TARGET_NAME.app/Contents/Frameworks/liblibmysql.dylib"
    
    install_name_tool -change "/Users/igorkorot/dbhandler/dbhandler/mysql-server/buildOSX/libmysql/libmysqlclient.21.dylib" @executable_path/../Frameworks/libmysqlclient.dylib "$TARGET_BUILD_DIR/$TARGET_NAME.app/Contents/Frameworks/liblibmysql.dylib"

    install_name_tool -change "/usr/local/lib/liblibmysql.dylib" @executable_path/../Frameworks/liblibmysql.dylib "$TARGET_BUILD_DIR/$TARGET_NAME.app/Contents/Frameworks/liblibdbloader.dylib"

so that the library can be used from inside the Bundle.

When verifying, I have the following:

    Igors-MacBook-Air:Frameworks igorkorot$ otool -L liblibmysql.dylib 
    liblibmysql.dylib:
    	@rpath/Frameworks/liblibmysql.dylib (compatibility version 1.0.0, current version 1.0.0)
    	@executable_path/../Frameworks/libmysqlclient.dylib (compatibility version 21.0.0, current version 21.0.0)
    	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 400.9.0)
    	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.50.4)
    Igors-MacBook-Air:Frameworks igorkorot$ otool -L libmysqlclient.dylib 
    libmysqlclient.dylib:
    	@rpath/Frameworks/libmysqlclient.dylib (compatibility version 21.0.0, current version 21.0.0)
    	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 400.9.0)
    	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.50.4)
    Igors-MacBook-Air:Frameworks igorkorot$ pwd
    /Users/igorkorot/dbhandler/dbhandler/Build/Products/Debug/dbhandler.app/Contents/Frameworks
    Igors-MacBook-Air:Frameworks igorkorot$

As far as I understand the "otool" output - everything is linked to the place inside the Bundle.

However when I tried to run my application (from Terminal with "open dbhandler.app"), I get the following error:

Quote

Failed to load shared library liblibdbloader.dylib
dlopen(liblibdbloader.dylib, 2). Library not loaded: /usr/local/lib/liblibmysql.dylib.
Referenced from
Reason: image not found

The dbloader.dylib library had been re-linked to the libmysql that was copied to the new place (and otool seems to confirm that):

Igors-MacBook-Air:Frameworks igorkorot$ otool -L liblibdbloader.dylib 
liblibdbloader.dylib:
	@rpath/Framework/liblibdbloader.dylib (compatibility version 1.0.0, current version 1.0.0)
	/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0)
	/System/Library/Frameworks/Carbon.framework/Versions/A/Carbon (compatibility version 2.0.0, current version 158.0.0)
	/System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 22.0.0)
	/System/Library/Frameworks/AudioToolbox.framework/Versions/A/AudioToolbox (compatibility version 1.0.0, current version 492.0.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.50.4)
	/System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0)
	@executable_path/../Frameworks/libwx_osx_cocoau_xrc-3.2.dylib (compatibility version 1.0.0, current version 1.0.0)
	@executable_path/../Frameworks/libwx_osx_cocoau_html-3.2.dylib (compatibility version 1.0.0, current version 1.0.0)
	@executable_path/../Frameworks/libwx_osx_cocoau_qa-3.2.dylib (compatibility version 1.0.0, current version 1.0.0)
	@executable_path/../Frameworks/libwx_osx_cocoau_adv-3.2.dylib (compatibility version 1.0.0, current version 1.0.0)
	@executable_path/../Frameworks/libwx_osx_cocoau_core-3.2.dylib (compatibility version 1.0.0, current version 1.0.0)
	@executable_path/../Frameworks/libwx_baseu_xml-3.2.dylib (compatibility version 1.0.0, current version 1.0.0)
	@executable_path/../Frameworks/libwx_baseu_net-3.2.dylib (compatibility version 1.0.0, current version 1.0.0)
	@executable_path/../Frameworks/libwx_baseu-3.2.dylib (compatibility version 1.0.0, current version 1.0.0)
	/Library/Frameworks/iODBC.framework/Versions/3.52/iODBC (compatibility version 1.0.0, current version 3.52.14)
	@executable_path/../Frameworks/liblibmysql.dylib (compatibility version 1.0.0, current version 1.0.0)
	@executable_path/../Frameworks/liblibpostgres.dylib (compatibility version 1.0.0, current version 1.0.0)
	@executable_path/../Frameworks/liblibodbc.dylib (compatibility version 1.0.0, current version 1.0.0)
	@executable_path/../Frameworks/liblibsqlite.dylib (compatibility version 1.0.0, current version 1.0.0)
	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 400.9.0)
Igors-MacBook-Air:Frameworks igorkorot$

So what am I missing? Could someone look at that?

I'm not sure what else do I need to do in order to have successful run...

Thank you in advance.

Options: ReplyQuote


Subject
Views
Written By
Posted
Running the program on OSX fails
379
October 10, 2023 08:25PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.