I have been stuck on this issue for a couple of days now. I have searched on the OpenNI forums as well as here, and I have tried fixes that worked for others but I am still getting linker errors.
I'll start from the beginning: I installed OpenNI 2.0 for OSX using the command line ./install. everything went good. It created the environment variables:
export OPENNI2_INCLUDE=/Users/Robert/Documents/Kinect/OpenNI-2.0.0/Include
export OPENNI2_REDIST=/Users/Robert/Documents/Kinect/OpenNI-2.0.0/Redist
I went into xCode and follows the instructions Here http://cicconet.wordpress.com/2011/03/24/openni-and-xcode-4/
to get xcode working with OpenNI SDK
I added /usr/include/ni to the “Header Search Paths” and added libOpenNI.dylib to the framework folder as well as putting it in the project's directory.
Xcode intellasence has all of the OpenNI methods and I do not get any errors when writing the code.
The code I use is:
#include <OpenNI.h>
using namespace openni;
int main(int argc, const char * argv[])
{
OpenNI::initialize();
return 0;
}
the errors I am getting are:
Undefined symbols for architecture x86_64:
"_oniInitialize", referenced from:
openni::OpenNI::initialize() 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)
Am I forgetting to include something somewhere?
Related
I wrote a program on my Mac (Intel) in Visual Studio Code (with a g++ compiler) and constantly whatever library I connected (except for the standard ones, I installed others through brew) gives the same error.
Below is an example of my program that gives this error. About function.hpp and func F, don't pay attention. It doesn't give out errors. I'm writing this for fun, and it's a shame to show the code, because there's an ugly OOP.
Please help me fix it, because I will not be able to advance further in studying without libraries. I am a beginner, so I may not understand a lot, and therefore if I get as few complicated things as possible.
Comments on the similarity: "You can't write OOP normally, but you want to use libraries, go study further" or "Write your own if you are not satisfied that these give errors" or some general advice "everything is simple here: Learn the architecture of x86_64 rewrite your OS then write your compiler and so on" please do not write, I'm looking for specific help and practical advice.
#include <iostream>
#include <SFML/Graphics.hpp>
#include "function.hpp"
using namespace std;
int main(int argc, char const *argv[])
{
double k[] = {1.0,2.0,3.0};
func F = func(k, (long)3);
F.ShowF_x();
while (!sf::Keyboard::isKeyPressed(sf::Keyboard::Escape))
{
cout << "Press Esc and find out if it works" << endl;
}
return 0;
}
C++
macOS
x86-64
Undefined symbols for architecture x86_64:
"sf::Keyboard::isKeyPressed(sf::Keyboard::Key)", referenced from:
_main in main-61ac6e.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 guess you are using the wrong version of SFML.
Make sure you are using this version for MacOS. On the SFML Download page make sure you are going for the MacOS/clang version.
Secondly. Check that your Visual Studio settings are set to the correct version that SFML uses for MacOS. That means C++11! By default C++14 is used in Visual Studio I think.
You can also try to compile it using your terminal. I was able to compile it with the following command:
g++ test.cpp -I/Users/name/Downloads/cpptest -L/Users/name/Downloads/cpptest/lib -l sfml-graphics -l sfml-window
Folder content:
cpptest
├── SFML -> Folder with SFML headers
├── lib -> SFML lib folder
└── test.cpp -> your code
Edit: I saw in one of your comments in this question that in your property files the cppstandard is set to C++17. Make sure your Visual Studio settings are set to use C++11.
Im trying to build a simple project with c++ and mysql (mysql-connector-c++).
And after few hours of work i managed to solve a problem with linking the boost lib and the mysql-connector-c++ lib with my project in Xcode.
Solve it by adding those paths to my Xcode project:
(in headers and library search paths, on project build settings)
headers and library search paths
Now when i try to make a simple connection to my database using mysql example as follow :
void DataBase::connectToDataBase() {
driver = get_driver_instance();
setConectionProperties();
try {
connection = driver->connect(*properties);
connection->setSchema(DATABASE);
}catch (SQLException &e) {
cout << e.what();
}
this->~DataBase();
exit(1);
}
My complete code
I get the following error:
Undefined symbols for architecture x86_64:
"_get_driver_instance", referenced from:
DataBase::connectToDataBase() in DataBase.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Full error log with linker command line
I don't have much understanding in linker errors, and in how to fix them.
I googled this problem and saw that is a very common one, but didn't manage to understand or fix it.
If you have any suggestion i will be happy to hear.
Some necessary details:
Im working on a MacBook Air High Sierra version 10.13.6
Installed 'boost' and 'mysql-connector-c++' via Homebrew.
Im using Xcode Version 10.1
if some details are missing please let me know and ill add them right away.
Thank you in advance!
The solution for my problem was :
adding to the 'Other Linker Flags' the flag : "-lmysqlcppconn"
('Other Linker Flags' can be found in 'Linking' in project Build Settings)
The solution
Many thanks for #nivpeled
I am just trying to compile C++ code without using IDE, however I encountered the following error:
Undefined symbols for architecture x86_64:
"_main", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
What I was testing is just a simple hello world program:
#include <iostream>
using namespace std;
int main ()
{
cout << "Hello World! ";
cout << "I'm a C++ program";
}
Both g++ and clang++ do not work with the same error. Compiling can be done successfully within a directory that is generated by CLion though. I guess maybe it is because the IDE could configure everything about compiler by itself? Is there something wrong with any path setting with my C++ compilers? Anyone can help on this? Thank you so much.
I figured it out...
It turned out that I forgot to save the .cpp file before compile in Visual Studio Code...I should have turned on the autosave.
What a stupid mistake...
I'm trying to write cross-system display management for a nodejs module. I've been successful on windows, but now I'm stuck on osx (linux is next).
I just can't get this short bit of code to work. I'm compiling with "make osx" and that works fine, as long as I don't use CGGetActiveDisplayList.
https://developer.apple.com/documentation/coregraphics/1454603-cggetactivedisplaylist
As far as I have researched, I am including the correct header file, but I am doubting this more, but can't find/see any other info.
If I comment out the CGGetActiveDisplayList code, CGDirectDisplayID still gets accepted, so I am assuming it's not completely wrong. It's probably quite simple, but I've been stuck for a few hours and it's pretty frustrating.
I've tried with osx.m (objective_c) and get the same error.
The file is "osx.cc"
#ifdef __APPLE__
#include <ApplicationServices/ApplicationServices.h>
int main(int argc, const char * argv[]){
printf("\nHello!\n\n");
CGDirectDisplayID displays[32];
uint32_t count;//sizeof(displays)/sizeof(displays[0])
if (CGGetActiveDisplayList(32, displays, &count) != kCGErrorSuccess)
{
printf("failed to get display list");
exit(EXIT_FAILURE);
}
}
#endif
thanks for your time!
edit:
make osx
c++ osx.cc -o osx
Undefined symbols for architecture x86_64:
"_CGGetActiveDisplayList", referenced from:
_main in osx-b7fd55.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: *** [osx] Error 1
It is not enough to import/include header files, you have to add Core Graphics framework to the linker. The framework name is shown in the manual you referenced. Please look at the answer to the similar question Undefined symbols for architecture x86_64 in Objective-C
Select the project file from the project navigator on the left side of the project window in xcode.
Select the target for where you want to add frameworks in the project settings editor.
Select the “Build Phases” tab, and click the small triangle next to “Link Binary With Libraries” to view all of the frameworks in your application.
To Add frameworks, click the “+” below the list of frameworks.
Select desired frameworks.
I recently upgraded to Xcode 5.0 and I am having problems with my command line C++ projects. Judging from answers on various forums, the problem lies with either my framework, or Xcode 5.0 not clearing out my "Library Search Paths" build setting.
When I do try clear out my library search path I find that it is empty. I have pasted my error below.
Undefined symbols for architecture x86_64:
"queueExam<int>::queueExam(int)", referenced from:
_main in examMain.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
There can be two possibilities.
1. Either your constructor name queueExam::queueExam(int) has an error, i mean some spelling error.(As it says that the symbol is not defined)
2. Your program has compiled, but there is a problem while combining the .cpp files which you have created. (Linker Error)
So i suggest that you check on this.
If none of this work, try creating a new project and just copy paste the whole code into the new one.(This solves linker problems many times).