I use this command to compile the file:
g++ rec.cpp -o rec -I /usr/local/include -L /usr/local/lib -lavformat -lavcodec -lavutil -lavdevice -lswscale -lasound -ldl -pthread -lz -lbz2 -lswresample -llzma -lva -lX11
After excute it I got the error:
/usr/bin/ld: /usr/local/lib/libavdevice.a(xcbgrab.o): undefined reference to symbol 'xcb_setup_pixmap_formats_length'//usr/lib/x86_64-linux-gnu/libxcb.so.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
How could I cope with this issue?
I found a way to deal with my issue. Since it's definitely a library problem so you can check how many libraries you need before compiling. For example:
pkg-config --libs libavcodec libavformat libswscale libavutil libavdevice
Then it'll tell you:
-L/usr/local/lib -lavdevice -lm -lxcb -lxcb-shm -lxcb -lxcb-shape -lxcb -lxcb-xfixes -lxcb-render -lxcb-shape -lxcb -lasound -lavfilter -pthread -lm -lva -ldl -lswscale -lm -lavformat -lm -lbz2 -lz -lavcodec -pthread -lm -llzma -lz -lva -ldl -lswresample -lm -lavutil -pthread -lva -lva-drm -lva -lva-x11 -lX11 -lm -lva -ldl
These libraries are what you need when you compile and then it's done.
You may also need pkg-config --cflags libavcodec libavformat libswscale libavutil libavdevice to add you CFLAGS or CXXFLAGS.
Related
I compiled a fltk application on linux with Code::blocks (file: test.cpp) without problems and was able to run the test.cpp file from within Code::blocks and from the linux command line.
Now I want to compile the test.cpp file or the whole project (prj.cbp) to a Windows 64 bit executable.
I installed mingw and it works fine because I can convert normal (NOT fltk) .cpp files to .exe files and run them on Windows.
But when I try to compile the test.cpp file with the mingw command (x86_64-w64-mingw32-g++ --static test.cpp -o app.exe) I get this error:
main.cpp:4:10: fatal error: FL/Fl.H: No such file or directory
#include <FL/Fl.H>
^~~~~~~~~
compilation terminated.
How can I fix this and how can I compile .cbp projects to get Windows binaries? Is it possible to do this from in Code::blocks and how do I set the mingw compiler to find the FLTK libraries?
If I try to compile from Code::blocks with the mingw compiler under linux for Windows I get this build log:
`-------------- Build: Debug in newFLTKproject (compiler: MingW64 compiler)---------------
x86_64-linux-gnu-c++ -std=c++14 -I/usr/local/include -I/usr/local/include/FL/images -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_THREAD_SAFE -D_REENTRANT -L/usr/local/lib -lfltk -lXrender -lXcursor -lXfixes -lXext -lXft -lfontconfig -lXinerama -lpthread -ldl -lm -lX11 -L/usr/local/lib -lfltk_forms -lfltk -lXrender -lXcursor -lXfixes -lXext -lXft -lfontconfig -lXinerama -lpthread -ldl -lm -lX11 -L/usr/local/lib -lfltk_gl -lGL -lfltk -lXrender -lXcursor -lXfixes -lXext -lXft -lfontconfig -lXinerama -lpthread -ldl -lm -lX11 -L/usr/local/lib -lfltk_images -lpng -lz -lfltk_jpeg -lfltk -lXrender -lXcursor -lXfixes -lXext -lXft -lfontconfig -lXinerama -lpthread -ldl -lm -lX11 -L/usr/local/lib -lfltk_images -lpng -lz -lfltk_jpeg -lfltk_gl -lGL -lfltk_forms -lfltk -lXrender -lXcursor -lXfixes -lXext -lXft -lfontconfig -lXinerama -lpthread -ldl -lm -lX11 -DWINVER=0x0400 -D__WIN95__ -D__GNUWIN32__ -DSTRICT -DHAVE_W32API_H -D__WXMSW__ -D__WINDOWS__ -std=c++14 -g -I/usr/local/include -I/usr/local/include/FL/images -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_THREAD_SAFE -D_REENTRANT -L/usr/local/lib -lfltk -lXrender -lXcursor -lXfixes -lXext -lXft -lfontconfig -lXinerama -lpthread -ldl -lm -lX11 -L/usr/local/lib -lfltk_forms -lfltk -lXrender -lXcursor -lXfixes -lXext -lXft -lfontconfig -lXinerama -lpthread -ldl -lm -lX11 -L/usr/local/lib -lfltk_gl -lGL -lfltk -lXrender -lXcursor -lXfixes -lXext -lXft -lfontconfig -lXinerama -lpthread -ldl -lm -lX11 -L/usr/local/lib -lfltk_images -lpng -lz -lfltk_jpeg -lfltk -lXrender -lXcursor -lXfixes -lXext -lXft -lfontconfig -lXinerama -lpthread -ldl -lm -lX11 -L/usr/local/lib -lfltk_images -lpng -lz -lfltk_jpeg -lfltk_gl -lGL -lfltk_forms -lfltk -lXrender -lXcursor -lXfixes -lXext -lXft -lfontconfig -lXinerama -lpthread -ldl -lm -lX11 -DWINVER=0x0400 -D__WIN95__ -D__GNUWIN32__ -DSTRICT -DHAVE_W32API_H -D__WXMSW__ -D__WINDOWS__ -std=c++14 -I/usr/local/include -I/usr/local/include/FL/images -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_THREAD_SAFE -D_REENTRANT -L/usr/local/lib -lfltk -lXrender -lXcursor -lXfixes -lXext -lXft -lfontconfig -lXinerama -lpthread -ldl -lm -lX11 -L/usr/local/lib -lfltk_forms -lfltk -lXrender -lXcursor -lXfixes -lXext -lXft -lfontconfig -lXinerama -lpthread -ldl -lm -lX11 -L/usr/local/lib -lfltk_gl -lGL -lfltk -lXrender -lXcursor -lXfixes -lXext -lXft -lfontconfig -lXinerama -lpthread -ldl -lm -lX11 -L/usr/local/lib -lfltk_images -lpng -lz -lfltk_jpeg -lfltk -lXrender -lXcursor -lXfixes -lXext -lXft -lfontconfig -lXinerama -lpthread -ldl -lm -lX11 -L/usr/local/lib -lfltk_images -lpng -lz -lfltk_jpeg -lfltk_gl -lGL -lfltk_forms -lfltk -lXrender -lXcursor -lXfixes -lXext -lXft -lfontconfig -lXinerama -lpthread -ldl -lm -lX11 -DWINVER=0x0400 -D__WIN95__ -D__GNUWIN32__ -DSTRICT -DHAVE_W32API_H -D__WXMSW__ -D__WINDOWS__ -I/usr/x86_64-w64-mingw32/include -I/usr/local/include/FL -I/usr/x86_64-w64-mingw32/include -I/usr/local/include/FL -I/usr/x86_64-w64-mingw32/include -I/usr/local/include/FL -I/usr/local/include -c /home/melt/Documents/C++/FLTK_C++2020/newFLTKproject/main.cpp -o obj/Debug/main.o
x86_64-linux-gnu-g++ -L/usr/x86_64-w64-mingw32/lib -L/usr/local/lib -L/usr/x86_64-w64-mingw32/lib -L/usr/local/lib -L/usr/x86_64-w64-mingw32/lib -L/usr/local/lib -o bin/Debug/newFLTKproject obj/Debug/main.o -lstdc++ -lgcc -lodbc32 -lwsock32 -lwinspool -lwinmm -lshell32 -lcomctl32 -ladvapi32 -lopengl32 -lglu32 -lole32 -loleaut32 -luuid -lXext -lX11 -lm -lfltkgl -lfltkforms -lfltkimages --use-forms --ldflags --use-gl --ldflags --use-images --ldflags --use-forms --use-gl --use-images --ldflags -lstdc++ -lgcc -lodbc32 -lwsock32 -lwinspool -lwinmm -lshell32 -lcomctl32 -ladvapi32 -lopengl32 -lglu32 -lole32 -loleaut32 -luuid -lXext -lX11 -lm -lfltkgl -lfltkforms -lfltkimages --use-forms --ldflags --use-gl --ldflags --use-images --ldflags --use-forms --use-gl --use-images --ldflags -lstdc++ -lgcc -lodbc32 -lwsock32 -lwinspool -lwinmm -lshell32 -lcomctl32 -lodbc32 -ladvapi32 -lodbc32 -lwsock32 -lopengl32 -lglu32 -lole32 -loleaut32 -luuid -lXext -lX11 -lm -lfltkgl -lfltkforms -lfltkimages /usr/local/lib /usr/local/lib /usr/local/lib /usr/x86_64-w64-mingw32/lib
/bin/sh: 1: x86_64-linux-gnu-c++: not found
Process terminated with status 127 (0 minute(s), 0 second(s))
0 error(s), 0 warning(s) (0 minute(s), 0 second(s))`
I am on Fedora and trying to compile and link a project with Poco libraries installed on my system. Everything works fine with I compile and link my project with GCC 6. However, there's a linking error when I use clang-3.9 to compile and link my project:
undefined reference to `Poco::JSON::Object::operator Poco::Dynamic::Struct<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > const&() const'
I checked the symbols in libPocoJSON.so and it contains this:
0000000000022d80 T Poco::JSON::Object::operator Poco::Dynamic::Struct<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > const&[abi:cxx11]() const
So, the problem is that when I'm compiling with clang, it's looking for a symbol which doesn't exist in library.
I tried supplying -D_GLIBCXX_USE_CXX11_ABI=1 to my program hoping that it will force it to look for symbols with the abi:cxx11 tag but it doesn't help. I am confused now, whether this is a POCO issue, or clang++ issue?
Edit:
Output of clang -v
clang version 3.9.1 (tags/RELEASE_391/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-redhat-linux/6.4.1
Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/6.4.1
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-redhat-linux/6.4.1
Candidate multilib: .;#m64
Candidate multilib: 32;#m32
Selected multilib: .;#m64
Edit2:
Compile and link commands:
/bin/sh ../libtool --tag=CXX --mode=link clang++ -DTDOC=\"../test/data\" -I../common -I../net -I../wsd -I../kit -D_GLIBCXX_USE_CXX11_ABI=1 -std=c++11 -pthread -module -rpath /dummy -lz -o test test-TileQueueTests.o test-WhiteBoxTests.o test-DeltaTests.o ../common/test-FileUtil.o ../common/test-SigUtil.o ../common/test-IoUtil.o ../common/test-Log.o ../common/test-Protocol.o ../common/test-Session.o ../common/test-Util.o ../common/test-MessageQueue.o ../kit/test-Kit.o ../wsd/test-Auth.o ../wsd/test-TileCache.o ../wsd/test-TestStubs.o ../common/test-Unit.o ../net/test-Socket.o test-TileCacheTests.o test-integration-http-server.o test-httpwstest.o test-httpcrashtest.o test-httpwserror.o test-test.o -lcppunit -lcap -lpng -ldl -lPocoNet -lPocoUtil -lPocoJSON -lPocoFoundation -lPocoXML -lPocoNetSSL -lPocoCrypto -lpcre
libtool: link: clang++ -DTDOC=\"../test/data\" -I../common -I../net -I../wsd -I../kit -D_GLIBCXX_USE_CXX11_ABI=1 -std=c++11 -pthread -o test test-TileQueueTests.o test-WhiteBoxTests.o test-DeltaTests.o ../common/test-FileUtil.o ../common/test-SigUtil.o ../common/test-IoUtil.o ../common/test-Log.o ../common/test-Protocol.o ../common/test-Session.o ../common/test-Util.o ../common/test-MessageQueue.o ../kit/test-Kit.o ../wsd/test-Auth.o ../wsd/test-TileCache.o ../wsd/test-TestStubs.o ../common/test-Unit.o ../net/test-Socket.o test-TileCacheTests.o test-integration-http-server.o test-httpwstest.o test-httpcrashtest.o test-httpwserror.o test-test.o -lz -lcppunit -lcap -lpng -ldl -lPocoNet -lPocoUtil -lPocoJSON -lPocoFoundation -lPocoXML -lPocoNetSSL -lPocoCrypto -lpcre -pthread -Wl,-rpath -Wl,/dummy
Edit3:
Linker Invcation:
"/usr/bin/ld" --hash-style=gnu --no-add-needed --build-id --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o test /usr/bin/../lib/gcc/x86_64-redhat-linux/6.4.1/../../../../lib64/crt1.o /usr/bin/../lib/gcc/x86_64-redhat-linux/6.4.1/../../../../lib64/crti.o /usr/bin/../lib/gcc/x86_64-redhat-linux/6.4.1/crtbegin.o -L/usr/bin/../lib/gcc/x86_64-redhat-linux/6.4.1 -L/usr/bin/../lib/gcc/x86_64-redhat-linux/6.4.1/../../../../lib64 -L/usr/bin/../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/bin/../lib/gcc/x86_64-redhat-linux/6.4.1/../../.. -L/usr/bin/../lib -L/lib -L/usr/lib test-TileQueueTests.o test-WhiteBoxTests.o test-DeltaTests.o ../common/test-FileUtil.o ../common/test-SigUtil.o ../common/test-IoUtil.o ../common/test-Log.o ../common/test-Protocol.o ../common/test-Session.o ../common/test-Util.o ../common/test-MessageQueue.o ../kit/test-Kit.o ../wsd/test-Auth.o ../wsd/test-TileCache.o ../wsd/test-TestStubs.o ../common/test-Unit.o ../net/test-Socket.o test-TileCacheTests.o test-integration-http-server.o test-httpwstest.o test-httpcrashtest.o test-httpwserror.o test-test.o -lz -lcppunit -lcap -lpng -ldl -lPocoNet -lPocoUtil -lPocoJSON -lPocoFoundation -lPocoXML -lPocoNetSSL -lPocoCrypto -lpcre -rpath /dummy -lstdc++ -lm -lgcc_s -lgcc -lpthread -lc -lgcc_s -lgcc /usr/bin/../lib/gcc/x86_64-redhat-linux/6.4.1/crtend.o /usr/bin/../lib/gcc/x86_64-redhat-linux/6.4.1/../../../../lib64/crtn.o
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'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?