Trying to access the file path to the resources folder in a Mac .app bundle using Qt. Here's my code:
CFURLRef appUrlRef;
appUrlRef = CFBundleCopyResourceURL(CFBundleGetMainBundle(), CFSTR("AFE-MP-512"),NULL,NULL);
CFStringRef filePathRef = CFURLCopyPath(appUrlRef);
qDebug() << filePathRef;
// Release references
CFRelease(filePathRef);
CFRelease(appUrlRef);
The only thing I have is a pushbutton on the form to run the code. Getting the following error when trying to compile:
Undefined symbols for architecture x86_64:
"_CFBundleCopyResourceURL", referenced from:
MainWindow::on_pushButton_clicked() in mainwindow.o
"_CFBundleGetMainBundle", referenced from:
MainWindow::on_pushButton_clicked() in mainwindow.o
"_CFRelease", referenced from:
MainWindow::on_pushButton_clicked() in mainwindow.o
"_CFURLCopyPath", referenced from:
MainWindow::on_pushButton_clicked() in mainwindow.o
"___CFConstantStringClassReference", referenced from:
CFString in mainwindow.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [ProgramLaunch.app/Contents/MacOS/ProgramLaunch] Error 1
13:18:21: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project ProgramLaunch (kit: Desktop Qt 5.3 clang 64bit)
When executing step "Make"
I have the following includes in mainwaindow.h
#include <QtCore>
#include <CoreFoundation/CFURL.h>
#include <CoreFoundation/CFBundle.h>
Any ideas what could be going wrong? Thanks
You need to link with the CoreFoundation framework. You can add the following to your qmake project: