Qt 5.15.2, Mac OSX and PostgreSql
-
Hi, I have a strange problem with Qt and PostgreSql on Mac OSX.
My portable app connects to PostgreSql server. The app has got in "Contents/Frameworks" folder the PostgreSql lib.
On Mac OSX High Sierra, Catalina and Big Sur everitying works well. In Mac OSX Monterey I have the error "driver not loaded".
If the app works on High Sierra, Catalina and Big Sur it that means that the package in weell made.
Why the app does not work in Monterey?Did anyone got problems with Qt - sql plugins - PostgreSql and different MacOS versions?
-
Hi,
Are all the machines you are using to test that runningon the same processor architecture ?
-
From an educated guess, the former has an Intel based Mac while the latter has likely an ARM based machine. Check that the PostgreSQL librairies you are shipping also contains both architecture.
Yes, I do.
-
In order to have my app working with PostgreSQL I have included in "Contents/Frameworks/" folder the PosgreSQL files "libpq.dylib, libpq.5.dylib, libpq.5.6.dylib" and I have run the command
install_name_tool -change /Applications/Postgres.app/Contents/Versions/9.6/lib/libpq.5.dylib @rpath/libpq.5.dylib Handyman.app/Contents/PlugIns/sqldrivers/libqsqlpsql.dylib
and the app works in High Sierra, Catalina e Big Sur (based on Intel cpu).
- So, in order to have my app working on Monterey (probably arm based) which library have I do add?
- Can I use the same app package or have I to bring app a specified app package for amr?
- Why my app works in Monterey (probably arm) except the PostgreSQL connection?
-
Hi, best way I think to get your app to work both on Intel and Arm Macs is to build a Universal app that have binary code for both Intel and Arm in the same .exe file.
This is for example how Qt Creator and the other executable files in the Qt distribution is built. You can check with the file command like this:
file ~/Qt/Qt\ Creator.app/Contents/MacOS/Qt\ Creator
and you should see both flavors listed.
If you installed PostgreSql via Homebrew I suspect that package is not universally built. I.e. same problem that many in this forum encounter when building MySql. This is because Homebrew has a stated policy of not distributing universal binaries :-(
You can request a universal build with the
set(CMAKE_OSX_ARCHITECTURES x86_64 arm64)
command in CMakeLists.txt or
-DCMAKE_OSX_ARCHITECTURES="x86_64 arm64"
in Terminal.