I had been trying to get OpenNI work on my Mac OS X 10.7. I installed the latest unstable binaries of OpenNI, NITE and Sensor from openni.org. The (precompiled) sample examples from OpenNI work fine but as soon as I write something of my own, it starts to fail.
For example, see below:
Undefined symbols for architecture x86_64:
"_xnForceShutdown", referenced from:
xn::Context::SetHandle(XnContext*) in sample.o
"_xnContextUnregisterFromShutdown", referenced from:
xn::Context::SetHandle(XnContext*) in sample.o
"_xnContextRelease", referenced from:
xn::Context::SetHandle(XnContext*) in sample.o
"_xnContextAddRef", referenced from:
xn::Context::SetHandle(XnContext*) in sample.o
"_xnContextRegisterForShutdown", referenced from:
xn::Context::SetHandle(XnContext*) in sample.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make: * [AsusCamera] Error 1
My code is as follows:
#include "XnOpenNI.h"
#include "XnCppWrapper.h"
using namespace xn;
extern "C" int printf(const char *, ...);
int main() {
Context context;
printf("hello world\n");
context.Release();
return 1;
};
Please help me. I already tried re-installing the libs several times.
I've just compiled your code on OSX (albeit 10.6.8) using Qt Creator and Xcode and it works.
The undefined symbols usually means you haven't linked to the library(dylib) the header files reference, so link libOpenNI.dylib to your project.
In Qt Creator I have this setup:
QT += core
QT -= gui
TARGET = niTest
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
INCLUDEPATH += /usr/include/ni/
LIBS += /usr/lib/libOpenNI.dylib
In XCode I've dragged libOpenNI.dylib onto the project and ticked the "Copy items into desintation group's folder (if needed)", had /usr/include/ni/ path added to the header search path. Note that depending on what feature you end up using in OpenNI/NITE, you will need to link to other libraries as well (e.g. libnimCodecs,libXnCore,etc.)
Related
I read through many questions of the same nature, but didn't find something specific to what I needed.
I am compiling a project on Snow Leopard (10.6.8) and Qt 5.3.2.
In my program's main method I check if it's on mac and bring up a cocoa-based window, otherwise creating the standard QApplication and MainWindow configuration. I have an .mm objective-c class that contains the window code and when include its corresponding header file, it gives me this error:
Undefined symbols for architecture x86_64:
"QMacApplication::QMacApplication()", 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)
I am using modified code from QT's official github repo for qtmacextras, putting the cocoa window code into its own library which I can import and use in other applications. See https://code.qt.io/cgit/qt/qtmacextras.git/tree/examples/macextras/macfunctions?h=5.14, although I'm using the 5.3.2 compatible commit.
Why am I getting this error?
This error can come from a missing framework as other questions have pointed out.
But the reason for this particular error was that I was missing some lines in my project pro file.
I was using OBJECTIVE_SOURCES to include my .mm file, but I was not including OBJECTIVE_HEADERS with my header file -- even though it didn't contain any objective-c code and I already specified it in the HEADERS directive.
Here's a concise version of my .pro file:
TARGET = QMacApplication
TEMPLATE = lib
QT += widgets core macextras
QT_PRIVATE += gui-private core-private
QMAKE_CXXFLAGS_GNUCXX11 = -std=c++98
CONFIG -= c++11
load(qt_build_config)
ios {
LIBS_PRIVATE += -framework UIKit
} else {
LIBS_PRIVATE += -framework AppKit
}
SOURCES += \
window.cpp
HEADERS += qmacapplication.h\
qmacapplication_global.h \
window.h
OBJECTIVE_SOURCES += qmacapplication.mm
OBJECTIVE_HEADERS += qmacapplication.h
It compiles when I remove qmacapplication.h from the HEADERS directive, but it seems safe to leave it in as well.
This is using xcode 4.2 if it matters.
I have following build env:
host: OSX 10.12 Sierra
XCode 9.2
Qt 5.10.1 for iOS
QtCreator 4.7.0
firebase 5.2
and try to build my application from QtCreator for iOS with the firebase support, but it fails with following linking errors:
Undefined symbols for architecture arm64:
"_OBJC_CLASS_$_FIRMessaging", referenced from:
objc-class-ref in firebase_messaging(messaging_231c52c311096cfce13e67fa91eb9ac5.o)
"_OBJC_CLASS_$_FIRApp", referenced from:
objc-class-ref in firebase(app_ios_814e1620d4f88024cea4bade26623a67.o)
"_OBJC_CLASS_$_FIROptions", referenced from:
objc-class-ref in firebase(app_ios_814e1620d4f88024cea4bade26623a67.o) ld: symbol(s) not
found for architecture arm64 clang: error: linker command failed with
exit code 1 (use -v to see invocation)
I have simplified my project to following code:
== main.cpp ==
#include <QCoreApplication>
#include <firebase/app.h>
#include <firebase/messaging.h>
#include <firebase/util.h>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
::firebase::App *fapp = ::firebase::App::Create();
Q_UNUSED(fapp);
return a.exec();
}
and a project file is:
QT -= gui
CONFIG += c++11 console
CONFIG -= app_bundle
# Check for GOOGLE_FIREBASE_SDK environment variable.
ENV_GOOGLE_FIREBASE_SDK = $$(GOOGLE_FIREBASE_SDK)
# Or define GOOGLE_FIREBASE_SDK path here.
GOOGLE_FIREBASE_SDK =
isEmpty(ENV_GOOGLE_FIREBASE_SDK) {
isEmpty(GOOGLE_FIREBASE_SDK) {
message("GOOGLE_FIREBASE_SDK" environment variable not detected!)
}
}
INCLUDEPATH += $$(GOOGLE_FIREBASE_SDK)
INCLUDEPATH += $$(GOOGLE_FIREBASE_SDK)/include
SOURCES += \
main.cpp
FCM_LIBS_PATH = $$(GOOGLE_FIREBASE_SDK)/frameworks/ios/universal
message("FCM_LIBS_PATH = $$FCM_LIBS_PATH")
LIBS += -F$$FCM_LIBS_PATH \
-framework firebase_messaging \
-framework firebase \
-framework Foundation \
-framework UserNotifications \
-framework UIKit \
-framework CoreGraphics
The firebase SDK contains different frameworks directories for different architectures :
~/firebase_cpp_sdk/frameworks/ios/universal
~/firebase_cpp_sdk/frameworks/ios/amd64
~/firebase_cpp_sdk/frameworks/ios/i386
~/firebase_cpp_sdk/frameworks/ios/x86_64
~/firebase_cpp_sdk/frameworks/ios/armv7
As I see that error related to 'arm64' architecture, so, I have changed the project file LIBS to use 'arm64' instead of 'universal', but this does not help.
Also I tried to build the project from the XCode, using qmake's generated xcode.project file, but there are same error.
I looked on stackoverflow a similar issues, but that workarounds does not help:
I tried to remove the /Users/admin/Library/Developer/Xcode/DerivedData directory.
I tried to play with the XCode options "Build Settings -> Build Active Architecture Only -> yes|no"
I looked a code from the following projects:
qtcloudmessaging: https://github.com/qt/qtcloudmessaging
QtFirebase: https://github.com/Larpon/QtFirebase
But I don't understand why this linker error happens.. Maybe is it a qmake bug?
The error means the project lacks Firebase pod.
firebase_cpp_sdk alone is not enough, in addition, it requires Firebase Core library.
In order add Firebase lib, you should migrate to use cocoapods.
In the project's source root, run
pod init
a new file Podfile would be then generated.
Open the file, add the following line to the target
pod 'Firebase/Analytics'
and save the file.
After running
pod update
successfully, open the .xcworkspace and build as usual.
I am very new with using GNU. I am trying to start using the boost filesystem library, and I keep getting these errors. I am trying to get the current working directory, by using boost::filesystem.
My code:
boost::filesystem::path full_path( boost::filesystem::detail::current_path() );
cout << "Current path is : " << full_path << endl;
My command:
g++ -I boost_1_58_0 main.cpp -o example
Result:
Undefined symbols for architecture x86_64:
"boost::filesystem::detail::current_path(boost::system::error_code*)", referenced from:
_main in main-1c56eb.o
"boost::system::system_category()", referenced from:
___cxx_global_var_init2 in main-1c56eb.o
"boost::system::generic_category()", referenced from:
___cxx_global_var_init in main-1c56eb.o
___cxx_global_var_init1 in main-1c56eb.o
ld: symbol(s) not found for architecture x86_64
Can someone please explain what the error is asking for? What did I do wrong?
boost.filesystem is not a header-only library. You have to link to the library using -L and -l flags. (And make sure the library is already properly built). You need to link to both boost_system and boost_filesystem libraries.
The command line could look like:
g++ -Iboost_1_58_0 -Lboost_1_58_0/lib/ -lboost-filesystem -lboost_system main.cpp -o example
(replace the -L argument with the path where the libboost-filesystem.so file resides)
Then, before you are able run the executable, you have to let the loader know where to look for the libraries. You shell be able do that using the following command:
export DYLD_LIBRARY_PATH=/path/to/boost/bib:$DYLD_LIBRARY_PATH
To make it automatic, I would recommend using a build system like cmake instead of just a command line.
How can I include Lua in my project in Xcode?
I have installed Lua via the instructions on the website (curl, extract, make macosx install, etc).
I can reference lua
extern "C" {
#include "lua.h"
#include "lualib.h"
#include "lauxlib.h"
}
But when I go to use it, I get an error (even writing something as simple as the following)
lua_State *L = luaL_newstate();
lua_close(L);
It tells me :
Undefined symbols for architecture x86_64:
"_luaL_newstate", referenced from:
_main in main.o
"_lua_close", 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)
Any advice would be much appreciated. If you need further information, let me know and I can edit it in. Thanks!
EDIT:
Added the -llua flag (SFML included the /usr/local/lib and include). Now getting "ignoring file /usr/local/lib/liblua.a, file was built for archive which is not the architecture being linked (i386): /usr/local/lib/liblua.a"
EDIT2:
I changed Base SDK to Latest OS X (OS X 10.9) and Build Active Architecture Only to "Yes" and now it will compile.
In Xcode, select < ProjectName > with blue icon on top of the left pane (where all the sources are), then in main window select a target under Targets. In Build Settings tab, select All instead of Basic and set following parameters:
Other Linker Flags = -llua
Header Search Paths = /usr/local/include
Library Search Paths = /usr/local/lib
Assuming Lua headers were installed in /usr/local/include, and liblua.a in /usr/local/lib.
You may also use search field to find them.
I have a very simple class, which I will send as Object via TCP using Asio by boost. I found many examples on the Internet, but when I compile my code I get a Link Failure.
#include <boost/archive/text_oarchive.hpp>
void async_write(){
std::ostringstream archive_stream;
boost::archive::text_oarchive archive(archive_stream); // here it fails
//....
}
I downloaded boost via macports.
My Qt project file:
INCLUDEPATH += /opt/local/include
LIBS += -L/opt/local/lib
LIBS += -lboost_system-mt -lboost_filesystem-mt -lboost_serialization-mt
Failure:
Undefined symbols for architecture x86_64:
"boost::archive::text_oarchive_impl::save(std::string const&)", referenced from:
void boost::archive::save_access::save_primitive(boost::archive::text_oarchive&, std::string const&) in tcpsession.o
"boost::archive::text_oarchive_impl::text_oarchive_impl(std::ostream&, unsigned int)", referenced from:
boost::archive::text_oarchive::text_oarchive(std::ostream&, unsigned int) in tcpsession.o
"boost::archive::basic_text_oprimitive::~basic_text_oprimitive()", referenced from:
boost::archive::text_oarchive_impl::~text_oarchive_impl() in tcpsession.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: * [tcpserver] Error 1
Any help is appreciated.
The standard reply would be "re-run qmake". It's even simpler to just delete the entire shadow build directory. One level up from the source of your project, there will be build-... folders. Delete all of them, and build again.
The simplest way to see whether your project file (the file with LIBS += lines) is current, add something to it that's invalid (like a typo in the library name). If it still "builds" without showing the error directly aimed at your typo (a missing library), then you know that your build is not based on the current project file, and you should re-run qmake or delete the shadow build folder so that everything will be recreated there.