Make a standalone OpenCV application using QMake - c++

I was using the OpenCV library to make a console application in Qt Creator (I'm just using QMake and the IDE, not any of the Qt libraries). This is on Ubuntu.
First I was using OpenCV dynamically (using an .so) But I want to execute my application on PCs that don't have OpenCV installed. So I'm trying to make a standalone executable:
I recompile and install OpenCV statically (by using the parameter -DBUILD_SHARED_LIBS=OFF )
I tried adding CONFIG += staticlib on my project.pro but I had remarked that it's still using the dynamic library
I tried to compile on profile/debug/release but none of these build options give me the good result
I finally tried to add QMAKE_LFLAGS += -static and recopied the line on opencv.pc:
LIBS += -L/usr/local/lib -lopencv_contrib -lopencv_stitching -lopencv_nonfree -lopencv_superres -lopencv_ocl -lopencv_ts -lopencv_videostab -lopencv_gpu -lopencv_photo -lopencv_objdetect -lopencv_legacy -lopencv_video -lopencv_ml -lopencv_calib3d -lopencv_features2d -lopencv_highgui -L/usr/local/share/OpenCV/3rdparty/lib -lIlmImf -ljasper -ltiff -lpng -ljpeg -lopencv_imgproc -lopencv_flann -lopencv_core -lzlib -lswscale-ffmpeg -lavutil-ffmpeg -lavformat-ffmpeg -lavcodec-ffmpeg -lgthread-2.0 -lfreetype -lfontconfig -lglib-2.0 -lgobject-2.0 -lpango-1.0 -lpangoft2-1.0 -lgio-2.0 -lgdk_pixbuf-2.0 -lcairo -latk-1.0 -lpangocairo-1.0 -lgdk-x11-2.0 -lgtk-x11-2.0 -lrt -lpthread -lm -ldl -lstdc++
I'm getting these errors:
:-1: error: cannot find -ljasper
:-1: error: cannot find -ltiff
:-1: error: cannot find -ljpeg
:-1: error: cannot find -lgdk_pixbuf-2.0
EDIT:
In reality I'm programming for research purpose, and I m in image processing and pattern recognition, first I was on my computer doing small tests, but now I must do tests on a large database and this is very time comsuming thats why I want to use a cluster and the problem is that the cluster does'nt have opencv that's why I want to bring my .exe
To simplify things I make a small program with main only and some simple function (where figure all the header I used in my program)
headers are:
#include "opencv2/core/core.hpp"
#include "math.h"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv/cv.h"
I put this line in my project.pro to identify the minimal dependencies :
LIBS += -L/usr/local/lib -lopencv_imgproc -lopencv_highgui -lopencv_core
this works correctly but when I add the parametre :
QMAKE_LFLAGS += -static
I have many many erros like:
grfmt_tiff.cpp:-1: error: undefined reference to `TIFFSetErrorHandler'
..
grfmt_jpeg.cpp:-1: error: undefined reference to `jpeg_start_decompress'
..
grfmt_exr.cpp:-1: error: undefined reference to `Imf::FrameBuffer::insert(char const*, Imf::Slice const&)'
..
grfmt_png.cpp:-1: error: undefined reference to `png_create_write_struct'
..
grfmt_jpeg2000.cpp:-1: error: undefined reference to `jas_cleanup'
..
system.cpp:-1: error: undefined reference to `pthread_spin_init'
persistence.cpp:-1: error: undefined reference to `gzeof'
rand.cpp:-1: error: undefined reference to `pthread_once'
..
(.text._ZNSt12_GLOBAL__N_13runEv+0x1d):-1: error: undefined reference to `pthread_setspecific'
After installing what you tell me to install
sudo apt-get install libjasper-dev libtiff-dev libjpeg-dev libgtk2.0-dev
And adding this lines in my .pro
LIBS += -L/usr/lib/x86_64-linux-gnu -ltiff -ljpeg -lpthread -lpng -ljasper -ljbig -lz -llzma
LIBS += -L/usr/local/share/OpenCV/3rdparty/lib -lIlmImf
I had dimunuate the issues to be 63 this error are like :
grfmt_png.cpp:-1: error: undefined reference to `png_set_longjmp_fn'
(.text+0x27a):-1: error: undefined reference to `deflateParams'
IlmThreadMutexPosix.cpp:-1: error: undefined reference to `pthread_mutex_destroy'
IlmThreadPosix.cpp:-1: error: undefined reference to `pthread_join'
ImfZipCompressor.cpp:-1: error: undefined reference to `compress'
(.text+0x185e):-1: error: undefined reference to `pthread_mutex_lock'
ImfPxr24Compressor.cpp:-1: error: undefined reference to `compress'
(.text._ZN12_GLOBAL__N_14pool4freeEPv.constprop.2+0x1d):-1: error: undefined reference to `pthread_mutex_lock'
Here is the simplified code source :
#include <iostream>
#include "opencv2/core/core.hpp"
#include "math.h"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv/cv.h"
#include <iostream>
#include <fstream>
using namespace std;
const double PI_2=atan (1.0)*2.0;
const double PI=atan (1.0)*4.0;
const double PI_4=atan (1.0);
const double PI3_4=PI_2+PI_4;
/*
void Paint_rect(){
cv::Mat imgq=cv::imread("/home/touka/Documents/PalmPrintProject/new-100-bmp-183-187/1_1.jpg",CV_LOAD_IMAGE_COLOR);
cv::Mat imgt=imgq.clone();
cv::rectangle(imgt,cv::Point (150,150),cv::Point (874,874),CV_RGB(255,0,0),2);
cv::imwrite("/home/touka/Desktop/test2.jpg",imgt);
}
void Save_Ort_Mat_File (cv::Mat mt, string file_name){
ofstream myfile;
myfile.open (file_name.c_str());
if(myfile){
for (int i=0;i<mt.rows;i++){
for (int j=0;j<mt.cols; j++)
myfile <<setprecision(8)<< ((mt.at<double>(i,j)*180)/PI)<<" | ";
myfile <<"\n" ;}
myfile.close();}
else{
cout <<"ERROR0";
}
}
*/
cv::Mat Sobel_Gradient_Image (cv::Mat img){
cv::Mat GX,GY,GXY;
cv::Point P(-1,-1);
cv::Vec3d X(1,2,1);
cv::Vec3d Y(1,0,-1);
cv::sepFilter2D(img,GX,img.depth(),Y,X,P,0,cv::BORDER_CONSTANT);
cv::sepFilter2D(img,GY,img.depth(),X,Y,P,0,cv::BORDER_CONSTANT);
vector<cv::Mat> m;
m.push_back(GX); m.push_back(GY);
cv::merge(m,GXY);
return GXY;
}
int main(int argc, char *argv[])
{
cv::Mat test;
cv::Mat imgq=cv::imread("/home/touka/Documents/PalmPrintProject/new-100-bmp-183-187/1_1.jpg",CV_LOAD_IMAGE_COLOR);
// test= Sobel_Gradient_Image(imgq);
// Paint_rect();
// Save_Ort_Mat_File(test,"file");
cout << "Hello World!" << endl;
return 0;
}
EDIT
Affter changing order of library and adding -pthread I finished by having only one error repeated 3 times:
png.cpp:-1: error: undefined reference to `png_set_longjmp_fn'
I don't Know why this error is repeated 3 times Here is the new order:
LIBS += -L/usr/local/lib -lopencv_imgproc -lopencv_highgui -lopencv_core
LIBS += -L/usr/local/share/OpenCV/3rdparty/lib -lIlmImf
LIBS += -L/usr/lib/x86_64-linux-gnu -lpng -ljasper -ltiff -ljpeg -lpthread -ljbig -llzma -pthread -lz

I tried adding CONFIG += staticlib on my project.pro but I had remarked that it's still using the dynamic library
You use this when you want to tell QMake that you are intending your build target itself to be a static library. But you want a console application. See the section with staticlib in it here in QMake's CONFIG documentation
First I was using OpenCV dynamically (using an .so) But I want to execute my application on PCs that don't have OpenCV installed.
In order to replace functionality that was previously provided by a dynamic library, you will need to have all the build dependencies of that library installed (e.g. the xxx-dev packages whoever compiled that .so was using).
I'm really not sure exactly what you're building or what dependencies are legitimate or not. It really helps if you can come up with a Minimal, Complete, Verifiable Example when asking questions. It makes a big difference if you have a tiny program that includes OpenCV, has a main(), and a QMake file that tries to build it...and demonstrates your error, vs. an example others can't see or test!
But...you could try removing those -lxxx lines for the missing libraries and see what happens. If you get link errors from functions which sound like they would be from those libraries, then they are actually needed as a dependency in your app.
But otherwise, just pushing along, you might try:
sudo apt-get install libjasper-dev libtiff-dev libjpeg-dev libgtk2.0-dev

Related

Opencv compilation is not working using -lopencv_videoio

I have installed opencv2.
pkg-config --modversion opencv
2.4.13.5
I am using below code,
#include <iostream>
#include <opencv2/opencv.hpp>
using namespace std;
using namespace cv;
int main(int argc, const char *argv[])
{
VideoCapture vid(0);
if(!vid.isOpened()){
cout<<"Camera could not load..."<<endl;
return -1;
}
namedWindow("webcam",CV_WINDOW_AUTOSIZE);
while(1){
Mat frame;
bool ctrl = vid.read(frame);
imshow("webcam",frame);
if(waitKey(0) == 27){
cout<<"The app is ended..."<<endl;
break;
}
}
return 0;
}
I compiled using, g++ image_writer.cpp
/tmp/ccPWmgA0.o: In function main':
image_writer.cpp:(.text+0x38): undefined reference tocv::VideoCapture::VideoCapture(int)'
image_writer.cpp:(.text+0x47): undefined reference to cv::VideoCapture::isOpened() const'
image_writer.cpp:(.text+0xac): undefined reference tocv::namedWindow(std::__cxx11::basic_string, std::allocator > const&, int)'
image_writer.cpp:(.text+0xe9): undefined reference to cv::VideoCapture::read(cv::Mat&)'
image_writer.cpp:(.text+0x105): undefined reference tocv::_InputArray::_InputArray(cv::Mat const&)'
image_writer.cpp:(.text+0x148): undefined reference to cv::imshow(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::_InputArray const&)'
image_writer.cpp:(.text+0x170): undefined reference tocv::waitKey(int)'
image_writer.cpp:(.text+0x1cd): undefined reference to cv::VideoCapture::~VideoCapture()'
image_writer.cpp:(.text+0x254): undefined reference tocv::VideoCapture::~VideoCapture()'
/tmp/ccPWmgA0.o: In function cv::Mat::~Mat()':
image_writer.cpp:(.text._ZN2cv3MatD2Ev[_ZN2cv3MatD5Ev]+0x39): undefined reference tocv::fastFree(void*)'
/tmp/ccPWmgA0.o: In function cv::Mat::release()':
image_writer.cpp:(.text._ZN2cv3Mat7releaseEv[_ZN2cv3Mat7releaseEv]+0x47): undefined reference tocv::Mat::deallocate()'
collect2: error: ld returned 1 exit status
After surfing I found, I have to include lib file
so, I did this. g++ image_writer.cpp -lopencv_videoio
/usr/bin/ld: cannot find -lopencv_videoio
collect2: error: ld returned 1 exit status
I don't know how to fix this. please help me how to fix this. Any hint would be appreciable.
EDIT-1:
pkg-config --libs opencv returns,
-L/usr/local/lib -lopencv_contrib -lopencv_stitching -lopencv_nonfree -lopencv_superres -lopencv_ocl -lopencv_ts -lopencv_videostab -lopencv_gpu -lopencv_photo -lopencv_objdetect -lopencv_legacy -lopencv_video -lopencv_ml -lopencv_calib3d -lopencv_features2d -lopencv_highgui -lopencv_imgproc -lopencv_flann -lopencv_core -lQtCore -lQtTest -lQtGui -lQtOpenGL -lIlmThread -lHalf -lIex -lIlmImf -lImath -ljasper -ltiff -lpng -ljpeg -lswscale-ffmpeg -lavutil-ffmpeg -lavformat-ffmpeg -lavcodec-ffmpeg -lv4l2 -lv4l1 -ldc1394 -lgstpbutils-0.10 -lgstriff-0.10 -lgstapp-0.10 -lgstvideo-0.10 -lxml2 -lglib-2.0 -lgthread-2.0 -lgmodule-2.0 -lgobject-2.0 -lgstreamer-0.10 -lgstbase-0.10 -lGLU -lGL -lz -latomic -ltbb -lrt -lpthread -lm -ldl -lstdc++
The OpenCV "library" is really a collection of multiple libraries, and you usually need to link with multiple libraries.
The simple solution is to use pkg-config --libs opencv to get all linker flags and libraries that are needed:
g++ image_writer.cpp `pkg-config --libs opencv`
compilation using cmake
cmake_minimum_required(VERSION 2.8)
project(ImageWriter)
add_executable(${PROJECT_NAME} "image_writer.cpp")
FIND_PACKAGE(OpenCV REQUIRED )
include_directories(${OPENCV_INCLUDE_DIRS})
message(" cv_libs: " ${OpenCV_LIBS})
message(" cv_includes: " ${OPENCV_INCLUDE_DIRS})
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${OpenCV_LIBS})

G++ returning errors after attempted compilation with openCV using G++

I'm trying to run a simple c++ file that includes openCV libraries and creates a simple Mat. Unfortunately, when I try and compile the file using g++, it returns a number of errors.
So far, I've tried removing the Mat definition all together and just included the openCV files, which worked! I'm new to the command line, so I'm not sure if it's an issue with the way I'm using g++. However, I have worked quite a bit on openCV in Xcode (though with Xcode, there's no need to work in the command line, as everything is neatly built for you at run time).
Also, this is my first time posting to Stack Overflow, so I may have made a mistake formatting.
This is my main.cpp file which I'm attempting to compile. As I mentioned before, if I remove the line "Mat test;", it compiles successfully and writes to console as it should.
#include <iostream>
#include <string>
#include <opencv2/core.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/videoio.hpp>
using namespace std;
using namespace cv;
int main() {
Mat test;
cout << "Mat Defined!" << endl;
return(0);
}
This is the g++ command I am using:
g++ -o main.out main.cpp
and this is the error I get when I try and run it:
/usr/bin/ld: /tmp/ccbbhoNd.o: in function `cv::Mat::~Mat()':
main.cpp:(.text._ZN2cv3MatD2Ev[_ZN2cv3MatD5Ev]+0x3c): undefined reference to `cv::fastFree(void*)'
/usr/bin/ld: /tmp/ccbbhoNd.o: in function `cv::Mat::release()':
main.cpp:(.text._ZN2cv3Mat7releaseEv[_ZN2cv3Mat7releaseEv]+0x68): undefined reference to `cv::Mat::deallocate()'
collect2: error: ld returned 1 exit status
Any help is greatly appreciated. I also opted out of the verbose flag for g++, as it returned a ton of lines and I wasn't sure how people feel about 50+ lines of code. Thanks so much!
You have problem with linking to OpenCV library. You need to pass to ld program information where to find all necessary lib's. In your case it will be:
g++ -I/usr/local/include/opencv -I/usr/local/include/opencv2 -L/usr/local/lib/ -o main.out main.cpp -lopencv_core
All OpenCV linker flags are:
-lopencv_calib3d
-lopencv_contrib
-lopencv_core
-lopencv_features2d
-lopencv_flann
-lopencv_highgui
-lopencv_imgproc
-lopencv_legacy
-lopencv_ml
-lopencv_nonfree
-lopencv_objdetect
-lopencv_photo
-lopencv_stitching
-lopencv_superres
-lopencv_ts
-lopencv_video
-lopencv_videostab
After all I suggest to jump in CMake build system for your C++ project's. With OpenCV it's much easier to compile program. Checkout doc's. CMake will prepare for you makefile with all needed dependencies.
Best Regards!
It fails because you didn't link the libraries in your command. During compilation, your operating system can't reach opencv libraries because you didn't address them. You need to compile your cpp file using the code below:
g++ -std=c++11 main.cpp `pkg-config --libs --cflags opencv` -o output

Compiling hello world with opencv c++ on mac os x sierra

First time I cannot compile hello world.
I've followed tons of tutorials how to install opencv.
I just have following example:
#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
using namespace std;
using namespace cv;
int main()
{
Mat imageMe = imread("test.jpg", 0);
return 0;
}
from opencv website.
Looks straightforward, but it won't compile.
g++ display_image.cpp `pkg-config --cflags --libs opencv` -l
Here's the error:
display_image.cpp:2:10: fatal error: 'opencv2/core/core.hpp' file not found
#include <opencv2/core/core.hpp>
^
1 error generated.
And running:
pkg-config --cflags --libs opencv
return this:
-I/usr/local/Cellar/opencv3/3.2.0/include/opencv -I/usr/local/Cellar/opencv3/3.2.0/include/opencv2 -L/usr/local/Cellar/opencv3/3.2.0/lib -lopencv_calib3d -lopencv_imgproc -lopencv_contrib -lopencv_legacy -l
these files are present.
Running ls /usr/local/Cellar/opencv3/3.2.0/include/opencv2/core | grep core.hpp
Gives the result:
core.hpp
What's the problem?
edit:
I've been using following tutorials to install opencv on my machine:
http://www.pyimagesearch.com/2016/12/19/install-opencv-3-on-macos-with-homebrew-the-easy-way/
https://www.learnopencv.com/install-opencv-3-on-yosemite-osx-10-10-x/
https://blogs.wcode.org/2014/10/howto-install-build-and-use-opencv-macosx-10-10/
http://seeb0h.github.io/howto/howto-install-homebrew-python-opencv-osx-el-capitan/
edit:
Even after all these answers I cannot compile a single app. Even if it somehow can find .hpp file directly included in my file it fails finding includes inside.
Probably my configuration is wrong.
In /usr/local/Cellar/opencv3 I have 2 directories:
3.2.0 - probably installed binaries
HEAD-9053839 - compiled from source
Now I also have opencv.pc file located in /usr/local/lib/pkgconfig:
prefix=/usr/local/Cellar/opencv3/3.2.0
exec_prefix=${prefix}
includedir=${prefix}/include
libdir=${exec_prefix}/lib
Name: opencv
Description: The opencv library
Version: 2.x.x
Cflags: -I${includedir}/opencv -I${includedir}/opencv2
Libs: -L${libdir} -lopencv_calib3d -lopencv_imgproc -lopencv_contrib -lopencv_legacy -l
As a prefix I've also tried HEAD-9053839.
I've created even simplier example:
#include <opencv2/opencv.hpp>
int main(){return 0; }
It's still telling me that 'opencv2/opencv.hpp' file not found.
Then I printed what pkg-config says:
pkg-config --cflags --libs opencv
-I/usr/local/Cellar/opencv3/3.2.0/include/opencv -I/usr/local/Cellar/opencv3/3.2.0/include/opencv2 -L/usr/local/Cellar/opencv3/3.2.0/lib -lopencv_calib3d -lopencv_imgproc -lopencv_contrib -lopencv_legacy -l
And found out it'd rather should be directly include dir, not opencv/opencv2 subdirectories.
So I've ran g++ like this:
g++ -I/usr/local/Cellar/opencv3/3.2.0/include -L/usr/local/Cellar/opencv3/3.2.0/lib -lopencv_calib3d -lopencv_imgproc -lopencv_contrib -lopencv_legacy -l display_image.cpp
Then it told me:
ld: library not found for -lopencv_contrib
After removing it it said:
ld: library not found for -lopencv_legacy
Then I had to remove -l before display_image.cpp, but then I've got another error:
Undefined symbols for architecture x86_64:
"cv::String::deallocate()", referenced from:
cv::String::~String() in display_image-9d8f86.o
cv::String::operator=(cv::String const&) in display_image-9d8f86.o
This is hell.
I don't have a compilation environment to regenerate your error but I think the problem is about these lines in your code:
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
since the opencv directory is being searched from
/usr/local/Cellar/opencv3/3.2.0/include/opencv2
as your "pkg-config --cflags --libs opencv" implies. So, I suppose, changing the include lines into
#include <core/core.hpp>
#include <highgui/highgui.hpp>
would help, or you can implicitly declare the directory you want to search like this:
g++ -I/usr/local/Cellar/opencv3/3.2.0/include display_image.cpp ...
In OpenCV 3.x, the layout of the header files has changed and now you pretty much just use:
#include <opencv2/opencv.hpp>
So, in concrete terms, I am suggesting you replace your 2nd and 3rd lines with the above incantation.
See the OpenCV Transition Guide.
Soner's answer should solve the OP's problem. I want to add some other solutions.
If you use CMake to install openCV from source, it will put OpenCV libraries in /usr/local/lib and OpenCV headers in /usr/local/include. Where the headers all go in the subfolder /usr/local/include/opencv. Since they are default library and header directories for most IDE's, all the examples you find will work with that config.
Now, brew does not install OpenCV to the above folders as you already knew. So you have three options:
Change compiler's search paths for OpenCV libraries and headers: g++ -I/usr/local/Cellar/opencv3/3.2.0/include -L/usr/local/Cellar/opencv3/3.2.0/lib
Soft link /usr/local/Cellar/opencv3/3.2.0/include/opencv to /usr/local/include and /usr/local/Cellar/opencv3/3.2.0/lib to /usr/local/lib
Install OpenCV from source with CMake.
I did it!
It was a problem with pkg-config.
In /usr/local/Cellar/opencv3/3.2.0/lib/pkgconfig I've found opencv.pc, which looks like this:
# Package Information for pkg-config
prefix=/usr/local/Cellar/opencv3/3.2.0
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir_old=${prefix}/include/opencv
includedir_new=${prefix}/include
Name: OpenCV
Description: Open Source Computer Vision Library
Version: 3.2.0
Libs: -L${exec_prefix}/lib -lopencv_shape -lopencv_stitching -lopencv_objdetect -lopencv_superres -lopencv_videostab -lopencv_calib3d -lopencv_features2d -lopencv_highgui -lopencv_videoio -lopencv_imgcodecs -lopencv_video -lopencv_photo -lopencv_ml -lopencv_imgproc -lopencv_flann -lopencv_core
Libs.private: -framework OpenCL -L/usr/local/opt/jpeg/lib -ljpeg -L/usr/local/lib -lpng -ltiff -lImath -lIlmImf -lIex -lHalf -lIlmThread -L/usr/lib -lz -framework Cocoa -framework AVFoundation -framework CoreGraphics -framework CoreMedia -framework CoreVideo -framework QuartzCore -framework Accelerate
Cflags: -I${includedir_old} -I${includedir_new}
I've replaced old opencv.pc located in: /usr/local/lib/pkgconfig
Now I'm not getting any errors.
I also had to use different include file:
#include <opencv2/opencv.hpp>

Makefile produces undefined references

I am getting the following errors:
//usr/local/lib/libsmfitting.so: undefined reference to `VO_FaceParts::VO_GetOneFacePart(unsigned int) const'
//usr/local/lib/libsmfitting.so: undefined reference to `cv::estimateRigidTransform(cv::_InputArray const&, cv::_InputArray const&, bool)'
collect2: error: ld returned 1 exit status
Being produced from this makefile:
Cxx=g++
CXXFLAGS = -I/usr/local/include/opencv -I/usr/local/include/opencv2 -I/usr/local/include/vosm/smfitting -I/usr/local/include/vosm/smbuilding -I/usr/local/include/vosm/comalgs -I/usr/local/include/vosm/cvcommon -I/usr/local/include/vosm/ensembletraining -I/usr/local/include/vosm/featureextraction -I/usr/local/include/vosm/integraltransform -I/usr/local/include/vosm/utils
LIBS = -lopencv_ml -lopencv_calib3d -lopencv_legacy -lopencv_core -lopencv_highgui -lopencv_imgproc -lopencv_video -lopencv_objdetect -lcomalgs -lcvcommon -lensembletraining -lfeatureextraction -lintegraltransform -lsmbuilding -lutils -lboost_system -lboost_filesystem -lsmfitting
all: faceApp.cpp
$(Cxx) -o faceApp faceApp.cpp $(CXXFLAGS) $(LIBS)
The code appears to be correct and the libraries appear to be built correctly, I believe the error lies in the makefile.
The order of the libraries when linking is significant, and should be in reverse dependency order. So if library B depends on library A, then you need to put B before A when linking.
In your case it seems that the smfitting library depends on one of the OpenCV libraries, as well as some other library, so you need to put it before those libraries.

unable to compile ffmpeg bohr on ubuntu 14.04 32bit

I'm developing an application to capture video from webcam and stream it to Android. I'm using ffmpeg latest release - 2.5.2 "Bohr" on Ubuntu 14.04 32bit and using Eclipse as IDE.
I'm receiving this error when compiling:
g++ -L/usr/local/lib -L/home/idanhahn/ffmpeg/ffmpeg_build/lib -o "camera" ./src/.metadata/.plugins/org.eclipse.cdt.make.core/specs.o ./src/CameraSec.o ./src/camera.o ./.metadata/.plugins/org.eclipse.cdt.make.core/specs.o -lz -lswscale -lopencv_core -lavcodec -lavutil -lpthread -lboost_thread -lboost_system -lboost_date_time -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_contrib -lopencv_legacy -lopencv_flann -lavformat
/usr/bin/ld: /home/idanhahn/ffmpeg/ffmpeg_build/lib/libavformat.a(http.o): undefined reference to symbol 'inflateInit2_'
/usr/lib/gcc/i686-linux-gnu/4.8/../../../i386-linux-gnu/libz.so: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
I've linked avformat (and other ffmpeg related libs).
I've tried the following:
Linked libz.
Tried to recompile using instructions from here: http://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu
What could be the problem?
Why linker points to i686 and then go back to i386?
You are really only missing an additional library here. Just add -llzma to the end of your compilation line.
I additionally had to add other missing libraries. Just append in case you are facing the same problem:
-lswresample -lm -lz
It is because libavcodec includes some math and zlib headers, so you must link to the respective libraries as well. This is also the case for lzma.
then you need to put -llzma with the compilation line of ffmpeg.
or i have an alternative to do it via simpler method.
Try this: http://ubuntuforums.org/showthread.php?t=2219550&p=13101922#post13101922
it will be simple..