I am using Lear's implementation of the Gist descriptor for a project which can be found here: http://lear.inrialpes.fr/software.
I am writing an application in c++ and I want to use this library. I am having issues though with the makefile and linking in general.
These commands give me no errors:
g++ -c standalone_image.c -o standalone_image.o
g++ -c gist.c -o gist.o
However, this line
g++ compute_gist.c `pkg-config --cflags --libs opencv`
gives me the following error
Undefined symbols for architecture x86_64:
"color_gist_scaletab(color_image_t*, int, int, int const*)", referenced from:
_main in ccMFYbAU.o
"color_image_delete(color_image_t*)", referenced from:
_main in ccMFYbAU.o
"color_image_new(int, int)", referenced from:
load_ppm(char const*)in ccMFYbAU.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
I have the Mosaic c++ code in a different directory. I also tried to compile gist and standalone_image seperately, copy into the mosaic directory, and compile the Mosaic code.
Which gives me the following error:
Undefined symbols for architecture x86_64:
"color_gist_scaletab(color_image_t*, int, int, int const*)", referenced from:
_main in main.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make: *** [mosaic] Error 1
I really want to use this library in my project, but I can't figure out a way to incorporate it in my c++.
Any help is GREATLY appreciated! Thanks!
Edit: I am using Mac Lion with:
gcc + g++ version: i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.1.00)
The lear library also uses the FFTW3 library that should work with C and C++.
The problem was that I needed the extern around the gist include, but the linking that was done in the Makefile was also wrong. It works now. :)
Related
I just installed OpenMP by running
$ brew install gcc
Than I ran my code using
$ gcc-10 -o task -fopenmp task.c
However I got the error message:
Undefined symbols for architecture x86_64:
"_main", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
My code is:
#include <omp.h>
Can someone help me?
I solved this problem replacing gcc with g++
I installed opencv by brew, I tried to reinstall for several times and it didn't help. I have googled for a lot of time but didn't find a valid way to solve this.
I copied a valid opencv from my friend's mac, but the imwrite function is still not found on my mac
Please help.
bash: g++ $(pkg-config --cflags --libs opencv) BoxFilter.cc -o BoxFilter
In file included from /usr/local/Cellar/opencv/3.3.0_3/include/opencv2/core.hpp:54:0,
from /usr/local/Cellar/opencv/3.3.0_3/include/opencv2/opencv.hpp:52,
from BoxFilter.cc:2:
/usr/local/Cellar/opencv/3.3.0_3/include/opencv2/core/base.hpp:354:35: warning: unknown option after '#pragma GCC diagnostic' kind [-Wpragmas]
# pragma GCC diagnostic ignored "-Winvalid-noreturn"
^
Undefined symbols for architecture x86_64:
"cv::imwrite(cv::String const&, cv::_InputArray const&, std::vector<int, std::allocator<int> > const&)",referenced from:
_main in ccO7bsE6.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
I have a program that i am trying to compile from my project directory and haven't been able to wrap my head around the following error
My compilation command
g++ grades.cpp -o grades
I see the following error
Undefined symbols for architecture x86_64:
"tbb::task_scheduler_init::initialize(int, unsigned long)", referenced from:
tbb::task_scheduler_init::task_scheduler_init(int, unsigned long) in grades-9c8d1a.o
"tbb::task_scheduler_init::terminate()", referenced from:
tbb::task_scheduler_init::~task_scheduler_init() in grades-9c8d1a.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 not sure how to debug this error.
You need to link against the tbb library you are tying to use,
g++ grades.cpp -o grades -ltbb
So, I've been trying to start using Python.h for a little project I want to work on that seems pretty /simple/. But before I start I want to try to learn how to use Python.h.
So I found this little example online.
#include "Python/Python.h"
int main(int argc, char** argv)
{
Py_Initialize();
PyRun_SimpleString("print 'Test'");
PyRun_SimpleString("print str(3 + 5)");
Py_Exit(0);
}
Seems pretty straight forward. When i first used
gcc test.cpp
to compile, i got some undefined symbols. I quickly found out I should use
-lpython2.7
then I found out I could also use
-L/Library/Frameworks/Python.framework/Versions/2.7/lib/
that didn't work (I made sure that /Library/Frameworks/Python/Versions/2.7/lib/ existed)
I'm stuck, what do I do?
I get
Undefined symbols:
"_Py_Initialize", referenced from:
_main in ccoUOSlc.o
"_PyRun_SimpleStringFlags", referenced from:
_main in ccoUOSlc.o
_main in ccoUOSlc.o
"___gxx_personality_v0", referenced from:
_main in ccoUOSlc.o
CIE in ccoUOSlc.o
"_Py_Exit", referenced from:
_main in ccoUOSlc.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
EDIT:
I just tried using the -Framework argument, and tried adding after the -L the -l python2.7 argument, and I now get
Undefined symbols:
"___gxx_personality_v0", referenced from:
_main in ccfvtJ4j.o
CIE in ccfvtJ4j.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
Now what?
If you are using an Python framework installation on OS X as it appears you are based on the paths, you can use the -framework argument to the Apple compiler drivers:
cc test.cpp -framework Python
Alternatively, you can explicitly specify the directory path and library name:
cc test.cpp -L /Library/Frameworks/Python.framework/Versions/2.7/lib/ -l python2.7
Update: With the configuration you report in the comments (Xcode 3.2.6, gcc-4.2), it appears you need to explicitly invoke the c++ variant of gcc. Either:
g++ test.cpp -framework Python
or
c++ test.cpp -framework Python
should work.
When trying to compile the following file in xcode:
http://openkinect.org/wiki/C%2B%2BOpenCvExample
I get these errors:
Ld build/Debug/KinectOpenCV normal x86_64
cd "/Users/Scott/Dropbox/Project/KinectOpenCV/KinectOpenCV"
setenv MACOSX_DEPLOYMENT_TARGET 10.7
/Developer/usr/bin/clang++ -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.7.sdk "-L/Users/Scott/Dropbox/Project/KinectOpenCV/KinectOpenCV/build/Debug" "-F/Users/Scott/Dropbox/Project/KinectOpenCV/KinectOpenCV/build/Debug" -filelist "/Users/Scott/Dropbox/Project/KinectOpenCV/KinectOpenCV/build/KinectOpenCV.build/Debug/KinectOpenCV.build/Objects-normal/x86_64/KinectOpenCV.LinkFileList" -mmacosx-version-min=10.7 -lopencv_core.2.3.2 -lopencv_highgui.2.3.2 -lfreenect.0.0.1 -framework GLUT -framework OpenGL -o "/Users/Scott/Dropbox/Project/KinectOpenCV/KinectOpenCV/build/Debug/KinectOpenCV"
Undefined symbols for architecture x86_64:
"_freenect_find_video_mode", referenced from:
freenect_threadfunc(void*) in main.o
"_freenect_set_video_mode", referenced from:
freenect_threadfunc(void*) in main.o
"_freenect_find_depth_mode", referenced from:
freenect_threadfunc(void*) in main.o
"_freenect_set_depth_mode", referenced from:
freenect_threadfunc(void*) in main.o
"_freenect_select_subdevices", 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've been trying everything I can think off to resolve the issue but no joy. I've tried compiling for specific architectures (32 bit or 64), I've tried relinking all the libraries and other such measures like starting a new project and importing everything again.
Sounds like you need to rebuild libfreenect.
I'd suggest following the directions on this tutorial and once you have everything re-installed, run that nm test again and see if the symbols finally appear.
If they don't, grep through the library source and see if they are defined and simply conditionalized out for some reason.