Running the program on OSX failed

Hi, ALL,

I'm writing a program that should operate with different DBMSes...

I'm using Xcode and test it under OSX High Sierra 10.13.6.

The compilation of my code succeeds however, when I tried to run it from Terminal, I got following:

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

At the end of the compilation I'm running a script which contains following lines:

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"

Trying to verify the linkage I have:

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$ 

I don't understand why the linker still trying to load the library from the /usr/local/lib. The library is not referencing anything from /usr/local/lib.

Can someone explain what is going on?

Running the program on OSX failed
 
 
Q