You can stop reading now if you are trying to build GPSBabel from the latest code on the GitHub repository. This issue has been already fixed on it.
;tl;dr
You need to set EXTRA_LDFLAGS
to build GPSBabel 1.5.3 on Mac OS X. Please adjust the /Library/Qt
in the path accordingly.
export EXTRA_LDFLAGS="-Xlinker -rpath -Xlinker /Library/Qt/5.6/clang_64/lib"
Intro
GPSBabel is a command line tool to manage GPS data: downloading data from GPS devices, converting data format. An executable package is available for Mac OS X, but I needed to build it from source to work on some issues on the latest version (1.5.3 currently).
Versions
I used the following versions to build GPSBabel 1.5.3.
- Mac OS X 10.10
- Xcode 7.2
- GPSBabel 1.5.3
- Qt 5.6
Setup
GPSBabel 1.5 requires Qt to be built. You can download it from Qt site. I installed it under /Library/Qt
directory, and added it to the PATH
.
export PATH=${PATH}:/Library/Qt/5.6/clang_64/bin/
Build
It could be compiled simply as follows:
./configure && make
But the binary doesn't run. It failed with the following error. The dyld
couldn't resolve the @rpath
at runtime.
./gpsbabel
dyld: Library not loaded: @rpath/QtCore.framework/Versions/5/QtCore
Referenced from: /Users/miz/Downloads/gpsbabel/./gpsbabel
Reason: image not found
Trace/BPT trap: 5
In order to fix the error, the EXTRA_LDFLAGS
needs to be set. It specifies the run-path search path for ld
.
make clean
# or simply
rm gpsbabel
export EXTRA_LDFLAGS="-Xlinker -rpath -Xlinker /Library/Qt/5.6/clang_64/lib"
make
Then, it works :)
./gpsbabel
GPSBabel Version 1.5.3. http://www.gpsbabel.org
...
Tips
You can check the dyld
name expansion at runtime if you set DYLD_PRINT_RPATHS
.
export DYLD_PRINT_RPATHS=1
./gpsbabel
RPATH successful expansion of @rpath/QtCore.framework/Versions/5/QtCore to: /Library/Qt/5.6/clang_64/lib/QtCore.framework/Versions/5/QtCore
GPSBabel Version 1.5.3. http://www.gpsbabel.org
...
For more detail about the run-path, please refer to Run-Path Dependent Libraries.