I'm trying to compile a program in C++ which uses OpenCV 2.4.10
But during compilation time it can't find the Imf symbol, and gives out a list of errors like
/usr/lib//libopencv_highgui.a(grfmt_exr.o): In function cv::ExrDecoder::readHeader()':
(.text._ZN2cv10ExrDecoder10readHeaderEv+0x12): undefined reference toImf::globalThreadCount()'
I'm compiling with
g++ -L/usr/local/lib/ -L/usr/lib/ -L/usr/lib/x86_64-linux-gnu/ -static -o "find_box_layout" ./src/find_box_layout.o -lopencv_imgproc -lopencv_highgui -lopencv_core -lm -ljasper -ljpeg -ltiff -lpng -lz -lpthread -lrt
Any help with this?
Related
I am trying to build 32bit application on 64bit Debian 7 and something goes wrong:
/usr/bin/ld: cannot find -lxml2
locate~
/usr/lib/x86_64-linux-gnu/libxml2.a
/usr/lib/x86_64-linux-gnu/libxml2.so
/usr/lib/x86_64-linux-gnu/libxml2.so.2
/usr/lib/x86_64-linux-gnu/libxml2.so.2.8.0
Makefile:
CFLAGS=-I. -I/usr/include/libxml2 -I/usr/include/lua50 -I/usr/local/include
LIBLINK=-L/usr/lib64 -lxml2 -lz -lpthread -lm -llualib50 -llua50 -ldl -lboost_thread -lmysqlclient -Wl,-Map=otserv.map
ENDFLAGS=-m32 -Winvalid-pch -O2 -include "preheaders.h"
I am trying to build a shared library that links a static version of libav into it. I build the library with --enable-pic to make sure its usable for me. But upon linking with the following command:
g++ -shared -o libbrake.so -L./ -L./libs -Wl,-z,defs -Wl,--whole-archive -Wl,-Bsymbolic -lavcodec -lavfilter -lavformat -lavresample -lavutil -lswscale -lbluray -ldvdnav -ldvdread -lhandbrake -lvpx -ldl -lm -lpthread -lx264 -ltheoraenc -lvorbis -ljansson -la52 -lass -lbz2 -lz -lxml2 -lopus -lmp3lame -logg -lsamplerate -lfontconfig -ldca -lharfbuzz
The needed static libs of libav are in the ./libs directory as .a archives.
Upon linking I get the error:
./libs/libavformat.a(log2_tab.o):(.rodata+0x0): multiple definition of `ff_log2_tab'
Is there any way to resolve this?
Ive done it now this way: with ar d i delete the multiple object file. but i think this is pretty "dirty"
– Nidhoegger
I am new to C++, openCV and Artoolkit
I am trying to build a motion tracker devices
right now, I am following the tutorial
https://artoolkit.org/blog/2016/05/opencv-with-artoolkit
However I meet some problem when I trying to implement this on SimpleTest on the Linux machine.
The error I get is like this:
"clang++ -c -O3 -fPIC -march=core2 -DHAVE_NFT=1 -I/usr/include/x86_64-linux-gnu -pthread -I/usr/include/gstreamer-0.10 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/libxml2 -I../../include simpleTest.c
clang: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated In file included from simpleTest.c:79: In file included from ../../include/linux-x86_64/opencv2/opencv.hpp:59:/usr/include/opencv2/contrib/contrib.hpp:273:23: error: no template named
'vector'; did you mean 'std::vector'?"
simpleTest code
I added line like this
#include <linux-x86_64/opencv2/opencv.hpp>
#include <linux-x86_64/opencv2/opencv_modules.hpp>
using namespace std;
using namespace cv;
in the make file:
I add some this:
LIBS= -lARgsub -lARvideo -lAR -lARICP -lAR -lglut -lGLU -lGL -lX11 -lm -lpthread -ljpeg -pthread -lgstreamer-0.10 -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lxml2 -lglib-2.0 -ldc1394 -lraw1394 -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_viz -lippicv -lopencv_core
and
CC = clang++
There are some similar issues found on SO here.....
Linking C from C++ in OS X Mavericks
Warning: treating 'c-header' input as 'c++-header' when in C++ mode, this behavior is deprecated
There's a mismatch between C++ and C.
To get around this, it would be best if you used ARWrapper for ARToolkit within a C++ framework.
I can build a Linux executable with g++ like below without any problem:
g++ -I/usr/local/include -I/usr/local/include/FL/images -I/usr/include/freetype2 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_THREAD_SAFE -D_REENTRANT -o '2016_02_06a_1st_Window' '2016_02_06a_1st_Window.cxx' /usr/local/lib/libfltk.a -lXext -lXft -lfontconfig -lpthread -ldl -lm -lX11
But When I try to build a MS Windows executable with MinGW like below and error happens:
i586-mingw32msvc-g++ -I/usr/local/include -I/usr/local/include/FL/images -I/usr/include/freetype2 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_THREAD_SAFE -D_REENTRANT 2016_02_06a_1st_Window.cxx -L/usr/local/lib -lfltk -lXext -lXft -lfontconfig -lpthread -ldl -lm -lX11 -o 2016_02_06a_1st_Window.exe
The error of MinGW is:
Compiling and linking..
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/../../../../i586-mingw32msvc/bin/ld: cannot find -lXext
collect2: ld returned 1 exit status
I have installed all kinds of Xext libraries like these:
I have the following Xext libraries on my machine:
user#computer:~$ locate *Xext*
/usr/include/X11/extensions/Xext.h
/usr/lib/i386-linux-gnu/libXext.a
/usr/lib/i386-linux-gnu/libXext.so
/usr/lib/i386-linux-gnu/libXext.so.6
/usr/lib/i386-linux-gnu/libXext.so.6.4.0
I feel like g++ knows where Xext libraries are, but MinGW doesn't know. Any idea would be helpful.
you are running a cross compiler, which host is linux and target is windows, so when you link your target binaries, you should have target libraries. in your case, you should have libX for windows, and you listed are linux libraries, that's why your cross compiler cannot find libraries to link.
I have created an some classes I want to use with swig in order to generate ruby binding.
Everything is ok when I generate the code or compile the ruby module. But when a script load this module, there is an error:
undefined symbol: _ZTVN5clang5LexerE
I understand that this means that the problem is for the clang::Lexer. But I know I have
set the lclangLex lib for this.
here is the command I use in order to link the objects files:
clang++ -shared -o parser.so parser.o Declarations.o -L. -L/usr/lib -L. -Wl,-O1,\
--sort-common,--as-needed,-z,relro -fstack-protector -rdynamic -Wl,-export-dynamic \
-L/usr/lib -lz -lpthread -lffi -lcurses -ldl -lm -lruby -lclangLex -lclangAST \
-lpthread -lgmp -ldl -lcrypt -lm -lc -lLLVMCppBackendCodeGen -lLLVMCppBackendInfo \
-lLLVMTarget -lLLVMCore -lLLVMMC -lLLVMObject -lLLVMSupport
any idea ?
The problem was the order of the libs given to the linker:
-lclangAST -lclangLex -lclangBasic
lclangAST must be given before lclangLex then I just had to add lclangBasic and everything works.