I am trying to use notifications in a Qt application on Mac.
Here is part of my class
#include <Cocoa/Cocoa.h>
#include <QtMacExtras/QtMac>
#include <objc/objc.h>
#include <QString>
#include <QPixmap>
void QgsMacNative::showDesktopNotification( const QString &summary,
const QString &body,
const QgsNative::NotificationSettings &settings )
{
NSUserNotification *notification = [[NSUserNotification alloc] init];
notification.title = summary.toNSString();
notification.informativeText = body.toNSString();
notification.soundName = NSUserNotificationDefaultSoundName; //Will play a default sound
notification.contentImage = QtMac::toNSImage( QPixmap::fromImage( settings.image ) );
[[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification: notification];
[notification autorelease];
}
Here is the error message I get:
Undefined symbols for architecture x86_64:
"QtMac::toNSImage(QPixmap const&)", referenced from:
QgsMacNative::showDesktopNotification(QString const&, QString const&, QgsNative::NotificationSettings const&) in qgsmacnative.mm.o
ld: symbol(s) not found for architecture x86_64
Any idea what's going on?
Finally found it.
In CMakeLists.txt, I had
FIND_PACKAGE(Qt5MacExtras)
but was missing
TARGET_LINK_LIBRARIES(qgis_native Qt5::MacExtras)
In my case, I was missing QT += entries in my .pro file.
Example:
QT += widgets core gui
Should have been:
QT += widgets core macextras gui
Related
I am setting up dev env for Vulkan on OS X,via MoltenVK wrapper. I use Xcode IDE.
I downloaded VulkanSDK from lunarG website.
Configured the includes.
Added (copied) libvulkan.1.1.121.dylib ,libvulkan.1.dylib into the project
,then added those into Build Phases -> Link Binary With Libraries of the target.
The sample code is:
#include <vulkan/vulkan.h>
#include <GLFW/glfw3.h>
#include <stdlib.h>
#include <stdio.h>
VkInstance instance;
void createInstance() {
VkApplicationInfo appInfo = {};
appInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
appInfo.pApplicationName = "Hello Triangle";
appInfo.applicationVersion = VK_MAKE_VERSION(1, 1, 0);
appInfo.pEngineName = "No Engine";
appInfo.engineVersion = VK_MAKE_VERSION(1, 1, 0);
appInfo.apiVersion = VK_API_VERSION_1_1;
VkInstanceCreateInfo createInfo = {};
createInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
createInfo.pApplicationInfo = &appInfo;
uint32_t glfwExtensionCount = 0;
const char** glfwExtensions;
glfwExtensions = glfwGetRequiredInstanceExtensions(&glfwExtensionCount);
createInfo.enabledExtensionCount = glfwExtensionCount;
createInfo.ppEnabledExtensionNames = glfwExtensions;
createInfo.enabledLayerCount = 0;
if (vkCreateInstance(&createInfo, nullptr, &instance) != VK_SUCCESS)
{
printf("failed to create instance!");
}
}
int main(int argc, const char * argv[]) {
createInstance();
return 0;
}
I receive no linker errors.
When I launch the app, I keep getting:
dyld: Library not loaded: #rpath/libvulkan.1.dylib Referenced from:
/Users/xxxxx/Library/Developer/Xcode/DerivedData/VulkanApp-aybsxkpxiqbshfebkfpcwaoiuige/Build/Products/Debug/VulkanApp
Reason: image not found
Then Xcode presents me with the following disassembly:
My hardware setup is:
MacBook Pro. macOS 10.14.6
Two GPUs:
Radeon Pro 555
Intel HD Graphics 630
I got the same issue and the solution for me was to clear the content of Subpath in Xcode -> Targets -> Build Phases -> Copy files.
include "mainwindow.h"
include "ui_mainwindow.h"
include <opencv2/opencv.hpp>
using namespace cv;
using namespace std;
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
cv::Mat inputImage = cv::imread("/home/chaiein/VR/1.jpg");
cv::imshow("Display Image", inputImage);
}
MainWindow::~MainWindow()
{
delete ui;
}
Error
/home/chaiein/VR/linePose/mainwindow.cpp:11: error: undefined reference to `cv::imread(std::__cxx11::basic_string, std::allocator > const&, int)'
My linepose.pro file as the following content
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = linePose
TEMPLATE = app
INCLUDEPATH += /usr/local/include/opencv /opt/ros/kinetic/share/OpenCV-
3.2.0-dev
LIBS += -L/usr/local/lib -lopencv_core -lopencv_imgcodecs -lopencv_highgui
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui
I have searched in many links but this problem seems to have different solution please help me!!
I am trying to run my code using the library pocketsphinx. Even though I have used the .lib files for the library it still isn't working. My code:
#include "stdafx.h"
#include <pocketsphinx.h>
#define MODELDIR "c:/sphinx/model"
int main(int argc, char *argv[])
{
ps_decoder_t *ps = NULL;
cmd_ln_t *config = NULL;
config = cmd_ln_init(NULL, ps_args(), TRUE,
"-hmm", MODELDIR "/en-us/en-us",
"-lm", MODELDIR "/en-us/en-us.lm.bin",
"-dict", MODELDIR "/en-us/cmudict-en-us.dict",
NULL);
return 0;
}
Errors:
Error LNK2019 unresolved external symbol _cmd_ln_init referenced in function _main
Error LNK2019 unresolved external symbol _ps_args referenced in function _main
I have the following code:
#include <cstdlib>
#include <cstdio>
#include <atomic>
enum ATYPE { Undefined = 0, typeA, typeB, typeC };
template<ATYPE TYPE = Undefined>
struct Object
{
Object() { counter++; }
static std::atomic<int> counter;
};
//template<ATYPE TYPE>
//std::atomic<int> Object<TYPE>::counter = 0;
template<ATYPE TYPE>
void test()
{
printf("in test\n");
Object<TYPE> o;
}
int main(int argc, char **argv)
{
test<typeA>();
printf("%d\n", Object<typeA>::counter.load());
return 0;
}
and when I compile it with the following command line:
clang++ -o test -std=c++11 -stdlib=libc++ test.cpp
I got the following error:
Undefined symbols for architecture x86_64:
"Object<(ATYPE)1>::counter", referenced from:
_main in testray-D4iTOH.o
Object<(ATYPE)1>::Object() in testray-D4iTOH.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I have no idea if what I am trying to do is technically possible. As the code hopefully shows, I am trying to create a static instance of the atomic class (BTW, I have no idea how to initialize this variable either. How do you intialize a static std::atomic<>?). What I am trying to do is count the number of instances of the class Object created while running the program, for each possible type (typeA, B, C, etc.).
That's the mechanism I came up with but maybe (beside the problem I have which I would like to fix if possible) someone could advice a better solution? It would be much appreciated.
Thank you so much.
As pointed by Dave in the comment, the static variable needs to be declared somewhere:
include
#include <cstdio>
#include <atomic>
enum ATYPE { Undefined = 0, typeA, typeB, typeC };
template<ATYPE TYPE = Undefined>
struct Object
{
Object() { counter++; }
static std::atomic<int> counter;
};
template<ATYPE TYPE>
std::atomic<int> Object<TYPE>::counter(0);
template<ATYPE TYPE>
void test()
{
printf("in test\n");
Object<TYPE> o;
}
int main(int argc, char **argv)
{
test<typeA>();
printf("%d\n", Object<typeA>::counter.load());
return 0;
}
It compiles fine.
I trying to mount the volume programmatically with code I found here
I getting this error while compiling it.
Ld /Users/alex/Library/Developer/Xcode/DerivedData/SambaTestApp-bthesiirajzqwebkatfdkbgalpwc/Build/Products/Debug/SambaTestApp normal x86_64
cd "/Users/alex/Documents/Xcode Projects/SambaTestApp"
setenv MACOSX_DEPLOYMENT_TARGET 10.7
/Developer/usr/bin/clang -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.7.sdk -L/Users/alex/Library/Developer/Xcode/DerivedData/SambaTestApp-bthesiirajzqwebkatfdkbgalpwc/Build/Products/Debug -F/Users/alex/Library/Developer/Xcode/DerivedData/SambaTestApp-bthesiirajzqwebkatfdkbgalpwc/Build/Products/Debug -filelist /Users/alex/Library/Developer/Xcode/DerivedData/SambaTestApp-bthesiirajzqwebkatfdkbgalpwc/Build/Intermediates/SambaTestApp.build/Debug/SambaTestApp.build/Objects-normal/x86_64/SambaTestApp.LinkFileList -mmacosx-version-min=10.7 -fobjc-arc -framework Foundation -o /Users/alex/Library/Developer/Xcode/DerivedData/SambaTestApp-bthesiirajzqwebkatfdkbgalpwc/Build/Products/Debug/SambaTestApp
Undefined symbols for architecture x86_64:
"_FSMountServerVolumeSync", referenced from:
_main in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
and my code is:
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[])
{
#autoreleasepool {
NSString * user = #"user";
NSString * password = #"pass";
NSURL * url = [NSURL URLWithString: #"smb://lemon"];
NSURL * mountDir = [NSURL URLWithString: #"/review"];
OptionBits flags = 0;
OSStatus err = FSMountServerVolumeSync (
(__bridge CFURLRef) url,
(__bridge CFURLRef) mountDir,
(__bridge CFStringRef) user,
(__bridge CFStringRef) password,
NULL,
flags);
if(err != noErr)
NSLog( #"some kind of error in FSMountServerVolumeSync - %d", err );
}
return 0;
}
You need to link against the CoreServices framework.