I tried to run the following example sketch for the SimlpeBlobTracker:
https://github.com/spmallick/learnopencv/blob/master/BlobDetector/blob.cpp
However, when I try to run the program,
./track
it breaks and returns:
OpenCV Error: The function/feature is not implemented () in
detectAndCompute, file
/home/sixtimesseven/Desktop/opencv/opencv/modules/features2d/src/feature2d.cpp,
line 144
terminate called after throwing an instance of 'cv::Exception'
what(): /home/sixtimesseven/Desktop/opencv/opencv/modules/features2d/src/feature2d.cpp:144:
error: (-213) in function detectAndCompute
I am compiling with a makefile:
CFLAGS = `pkg-config --cflags opencv`
LIBS = `pkg-config --libs opencv`
track : track.cpp
g++ $(CFLAGS) -o track track.cpp $(LIBS)
And I am running Ubuntu 16 and OpenCV 2.4.
I am not an expert on this topic, but I did come across this, which suggests that it might be something related to how you're declaring a certain object.
Related
Recently I start a Django project in order to some image processing purposes. for some performance reasons, I wrote a function in c++ and test it independently. Now I want to call that c++ function in my python code. but when I compile it with this instruction:
g++ a.cpp `pkg-config --cflags --libs opencv` -shared -o program.so
this error occurred:
/usr/bin/ld: /tmp/ccvIlzBz.o: relocation R_X86_64_PC32 against symbol `_ZNK2cv7MatSizeclEv' can not be used when making a shared object; recompile with -fPIC
according to this error, if ّ replace -shared with -fPIC flag, it compiles but at my python code, this error occurred:
cannot open shared object file:
which means that it is not compiled correctly.
finally I build the c++ program with this instruction:
g++ a.cpp `pkg-config --cflags --libs opencv` -shared -fPIC -lm -o program.so
but when I execute my python code and call a function(sample_func) in that c++ code, it's give this error :
../program.so: undefined symbol: sample_func
how I can fix this problem?
I have an app which uses Gtkmm for UI and I can compile it with a command line (saved in a script), and have read/tried to use a Makefile for it. See below:
SRCDIR = src
BINDIR = bin
OBJECTS = $(SRCDIR)/Dependency_1.o $(SRCDIR)/Dependencies_2.o $(SRCDIR)/Dependencies_N.o $(SRCDIR)/Gtkmm_Definitions.o App_Gtkmm.o
GTKFLAGS = `pkg-config --cflags gtkmm-3.0`
LIBS = `pkg-config --libs gtkmm-3.0`
CXX = g++
CXXFLAGS = -Wall -pthread -mms-bitfields
debug: EXEC = App_Gtkmm_debug
debug: $(OBJECTS)
$(CXX) $(CXXFLAGS) $(GTKFLAGS) -o $(BINDIR)/$(EXEC) $(OBJECTS) $(LIBS)
clean:
rm $(SRCDIR)/*.o $(BINDIR)/App_Gtkmm*
There is another target which I omitted for simplicity. The file structure is: Dependencies_X have class definitions which are just standard C++; Gtkmm_Definitions.hpp/.cpp have the Gtkmm-related declarations and definitions (gtkmm.h is included here) and App_Gtkmm.cpp is the main program.
When running "make debug", it will compile just part of the sources in the 1st pass and stop with some errors, that are gone when I run a 2nd time. This already seems a problem. Then it will stop when trying to compile Gtkmm_Definitions, saying it can't find gtkmm.h.
In file included from src/Gtkmm_Definitions.cpp:1:0:
src/Gtkmm_Definitions.hpp:1:10: fatal error: gtkmm.h: No such file or directory
#include <gtkmm.h>
^~~~~~~~~
compilation terminated.
make: *** [<builtin>: src/Gtkmm_Definitions.o] Error 1
However, this command line compiles without any problem:
g++ -Wall -pthread -mms-bitfields src/Dependencies_1.cpp src/Dependencies_N.cpp src/Gtkmm_Definitions.cpp App_Gtkmm.cpp -o bin/App_Gtkmm_debug `
pkg-config --cflags gtkmm-3.0 --libs gtkmm-3.0
Can you guys spot anything wrong in this Makefile? I have already tried a great deal of variables change of order, concatenation and online advices here and there.
For reference: i am currently on Manjaro (Arch Linux) and am using the GNU g++ compiler. I want to create a program for JACK (Jack Audio Connection Kit) and am now trying to use their API provided here. I have Jack2 installed, but also tried it with Jack2-dbus. I found something in the AUR called jackcpp, but that didn't help neither.
To get to my problem: I fail to compile their example clients listed, and obviously I fail to build my own using that API. I suspect it is broken, but I can't imagine noone reporting it so I don't really know what to do now.
In my jacktest.cpp the following is written:
#include <iostream>
#include "jack/control.h"
int main(){
jackctl_server_t *server;
jackctl_driver_t *driver;
if (jackctl_server_start(server, driver)) {
std::cout << "Started!";
return 0;
}else{
std::cout <<"Failed!";
return 1;
};
}
based on the function documented here. Try to start a jack server and return a bool if operation successful or not.
If I try to compile this (with 'pkg-config' as I am supposed to):
$ g++ -o jacktest `pkg-config --cflags --libs jack` jacktest.cpp
it throws:
jacktest.cpp:8:44: error: too many arguments to function 'bool jackctl_server_start(jackctl_server_t*)'
if (jackctl_server_start(server, driver))
So I checked and indeed, in my /usr/include/jack/control.h, it defines jackctl_server_start with only one argument. I don't know if their documentation is outdated or if I am missing files/have the wrong ones...
Then I tried to do it with only one argument
...
if (jackctl_server_start(server)) {
...
which then throws:
/usr/bin/ld: /tmp/ccxm3fWC.o: undefined reference to symbol '_ZNSt8ios_base4InitD1Ev##GLIBCXX_3.4'
/usr/lib/libstdc++.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
I tried to rearrange the arguments:
$ g++ -o jacktest `pkg-config --cflags --libs jack` jacktest.cpp
$ g++ -o jacktest jacktest.cpp `pkg-config --cflags --libs jack`
$ g++ jacktest.cpp `pkg-config --cflags --libs jack` -o jacktest
$ g++ jacktest.cpp -o jacktest `pkg-config --cflags --libs jack`
which always throws the same error...
now the thing that really makes me think something is broken: another jacktest_2.cpp now including jack.h and excluding control.h
#include <iostream>
#include "jack/jack.h"
int main(){
jack_client_t *client;
if (client = jack_client_new("test_client")) {
std::cout << "Running!";
return 0;
}else{
std::cout <<"Not Running!";
return 1;
};
}
which I CAN compile:
$ g++ -o jacktest_2 jacktest_2.cpp `pkg-config --cflags --libs jack`
altough it gives me complains that this function is depricated, the program does what it should too! So at least some of it is working?!
Also:
$ g++ -print-file-name=jack
/usr/lib/gcc/x86_64-pc-linux-gnu/7.2.1/../../../../lib/jack
is that normal? There is no lib/jack in usr/lib/gcc/x86_64-pc-linux-gnu/7.2.1
To conclude: I really NEED control.h, I even went as far as changing control.h and include their 'driver' part from the API Docs back into the function, but that didn't get me anywhere neither... (undefined reference...) I feel like I am missing something really simple, or something really is broken with that API. I have been on this for almost a week, and I just can't figure it out.
If anyone stumbles upon this and wondered what happend: I posted this in the JackAudio forum here. Anyone can read it if he/she wants to, but I will mark this question as answered now, since it really is not a C++ or compiling problem but rather a Jack problem. Thank you!
I have read all of the related questions with no success trying anything mentioned anywhere. I am new to cross-compiling and have been working on this for over a week with no progress. So please forgive me if you think I am stupid or have overlooked something.
So I have an application running in C++ that works great on my development computer running Ubuntu 14.04 x64. I am trying to cross compile for my Banana Pro running Lubuntu. Based on the documentation from Lemaker I am supposed to cross compile using "arm-linux-gnueabihf-"
So far the farthest I have been able to get is to :
/usr/local/opencv-arm/usr/local/lib/libopencv_calib3d.so: file not recognized: File format not recognized
collect2: error: ld returned 1 exit status
I get this error regardless of what command I run, Here is a list of commands I have tried:
arm-linux-gnueabihf-g++ `arm-linux-gnueabihf-pkg-config arm-opencv --cflags` -Wall test.cpp -o vis-300 `arm-linux-gnueabihf-pkg-config arm-opencv --libs`
arm-linux-gnueabihf-g++ `pkg-config arm-opencv --cflags` -Wall test.cpp -o vis-300 `pkg-config arm-opencv --libs`
arm-linux-gnueabihf-gcc `pkg-config arm-opencv --cflags` -Wall test.cpp -o vis-300 `pkg-config arm-opencv --libs`
arm-linux-gnueabihf-g++ `pkg-config arm-opencv --cflags` test.cpp -o vis-300 `pkg-config arm-opencv --libs`
And there have been many more commands before those with different errors such as:
arm-linux-gnueabihf-gcc: error trying to exec 'cc1plus': execvp: No such file or directory
arm-linux-gnueabihf-cpp fatal error too many input files
I have tried with just normal arm-linux-gnueabihf-gcc/g++, 4.6, 4.7, and 4.8
I have built opencv making small changes for hf using these 2 guides and both produced the same results:
http://processors.wiki.ti.com/index.php/Building_OpenCV_for_ARM_Cortex-A8
http://www.ridgesolutions.ie/index.php/2013/05/24/building-cross-compiling-opencv-for-linux-arm/
and not included in either I install it using this command because it will conflict with my current x86_64 install:
sudo make install DESTDIR=/usr/local/opencv-arm
Also the above pkg-config lines point to my custom pkg config file named arm-opencv.pc
# Package Information for pkg-config
prefix=/usr/local/opencv-arm/usr/local
exec_prefix=${prefix}
libdir=
includedir_old=${prefix}/include/opencv
includedir_new=${prefix}/include
Name: OpenCV-arm
Description: Open Source Computer Vision Library
Version: 2.4.10
Libs: ${exec_prefix}/lib/libopencv_calib3d.so ${exec_prefix}/lib/libopencv_contrib.so ${exec_prefix}/lib/libopencv_core.so ${exec_prefix}/lib/libopencv_features2d.so ${exec_prefix}/lib/libopencv_flann.so ${exec_prefix}/lib/libopencv_gpu.so ${exec_prefix}/lib/libopencv_highgui.so ${exec_prefix}/lib/libopencv_imgproc.so ${exec_prefix}/lib/libopencv_legacy.so ${exec_prefix}/lib/libopencv_ml.so ${exec_prefix}/lib/libopencv_nonfree.so ${exec_prefix}/lib/libopencv_objdetect.so ${exec_prefix}/lib/libopencv_ocl.so ${exec_prefix}/lib/libopencv_photo.so ${exec_prefix}/lib/libopencv_stitching.so ${exec_prefix}/lib/libopencv_superres.so ${exec_prefix}/lib/libopencv_ts.a ${exec_prefix}/lib/libopencv_video.so ${exec_prefix}/lib/libopencv_videostab.so -lrt -lpthread -lm -ldl
Cflags: -I${includedir_old} -I${includedir_new}
Anyways I have tried a lot of stuff short of just installing everything on the board itself and compiling there. Any help is much appreciated and keep in mind I have never successfully cross-compiled before. I always give up and compile on the board.
I'm trying to setup a trivial OpenCV example following instructions from here. But when I try to run my example using
$ g++ -ggdb `pkg-config --cflags opencv` -o `basename opencvtest.cpp .cpp` opencvtest.cpp `pkg-config --libs opencv`
$ ./opencvtest`
I get the following error
g++ error missing argument to ‘-l’
I would appreciate any insight on how I could solve this.