g++ undefined reference error on compiling - c++

Im trying to compile my program on linux. It works great on Windows (compiled under Visual Studio 2015). But when I try to do the same on Linux, I get this error:
g++ -std=c++0x -std=c++0x Prueba1.cpp -o Prueba1
/tmp/cc9HTgYi.o: In function `Escuchador::onFrame(Leap::Controller const&)':
Prueba1.cpp:(.text+0x51): undefined reference to `Leap::Controller::frame(int) const'
Prueba1.cpp:(.text+0x6c): undefined reference to `Leap::Frame::fingers() const'
Prueba1.cpp:(.text+0x7d): undefined reference to `Leap::FingerList::count() const'
Prueba1.cpp:(.text+0x97): undefined reference to `Leap::Frame::hands() const'
Prueba1.cpp:(.text+0xa8): undefined reference to `Leap::HandList::count() const'
Prueba1.cpp:(.text+0xbc): undefined reference to `Leap::Frame::timestamp() const'
Prueba1.cpp:(.text+0xce): undefined reference to `Leap::Frame::id() const'
Prueba1.cpp:(.text+0x1ac): undefined reference to `Leap::Frame::hands() const'
Prueba1.cpp:(.text+0x1c7): undefined reference to `Leap::HandList::begin() const'
Prueba1.cpp:(.text+0x203): undefined reference to `Leap::Hand::isLeft() const'
Prueba1.cpp:(.text+0x245): undefined reference to `Leap::Hand::id() const'
Prueba1.cpp:(.text+0x2fc): undefined reference to `Leap::Hand::palmNormal() const'
Prueba1.cpp:(.text+0x317): undefined reference to `Leap::Hand::direction() const'
Prueba1.cpp:(.text+0x332): undefined reference to `Leap::Hand::fingers() const'
Prueba1.cpp:(.text+0x34d): undefined reference to `Leap::FingerList::begin() const'
Prueba1.cpp:(.text+0x37e): undefined reference to `Leap::Pointable::id() const'
Prueba1.cpp:(.text+0x38e): undefined reference to `Leap::Finger::type() const'
Prueba1.cpp:(.text+0x47b): undefined reference to `Leap::Finger::bone(Leap::Bone::Type) const'
Prueba1.cpp:(.text+0x510): undefined reference to `Leap::Frame::hands() const'
Prueba1.cpp:(.text+0x533): undefined reference to `Leap::HandList::operator[](int) const'
Prueba1.cpp:(.text+0x54e): undefined reference to `Leap::Hand::fingers() const'
Prueba1.cpp:(.text+0x582): undefined reference to `Leap::FingerList::begin() const'
Prueba1.cpp:(.text+0x595): undefined reference to `Leap::Bone::Bone()'
Prueba1.cpp:(.text+0x5ea): undefined reference to `Leap::Finger::bone(Leap::Bone::Type) const'
Prueba1.cpp:(.text+0x63e): undefined reference to `Leap::Finger::type() const'
Prueba1.cpp:(.text+0x67f): undefined reference to `Leap::operator<<(std::ostream&, Leap::Bone const&)'
Prueba1.cpp:(.text+0x6ee): undefined reference to `Leap::FingerList::end() const'
Prueba1.cpp:(.text+0x726): undefined reference to `Leap::Hand::fingers() const'
Prueba1.cpp:(.text+0x74d): undefined reference to `Leap::FingerList::begin() const'
Prueba1.cpp:(.text+0x768): undefined reference to `Leap::FingerList::end() const'
Prueba1.cpp:(.text+0x7ab): undefined reference to `Leap::Finger::bone(Leap::Bone::Type) const'
Prueba1.cpp:(.text+0x7ce): undefined reference to `Leap::Finger::bone(Leap::Bone::Type) const'
Prueba1.cpp:(.text+0x7f1): undefined reference to `Leap::Finger::bone(Leap::Bone::Type) const'
Prueba1.cpp:(.text+0x814): undefined reference to `Leap::Finger::bone(Leap::Bone::Type) const'
Prueba1.cpp:(.text+0x825): undefined reference to `Leap::Finger::type() const'
Prueba1.cpp:(.text+0x848): undefined reference to `Leap::Bone::direction() const'
Prueba1.cpp:(.text+0x863): undefined reference to `Leap::Bone::direction() const'
Prueba1.cpp:(.text+0x89e): undefined reference to `Leap::Bone::direction() const'
Prueba1.cpp:(.text+0x8b9): undefined reference to `Leap::Bone::direction() const'
Prueba1.cpp:(.text+0x8f4): undefined reference to `Leap::Bone::direction() const'
/tmp/cc9HTgYi.o:Prueba1.cpp:(.text+0x90c): more undefined references to `Leap::Bone::direction() const' follow
/tmp/cc9HTgYi.o: In function `Escuchador::onFrame(Leap::Controller const&)':
Prueba1.cpp:(.text+0xa15): undefined reference to `Leap::Finger::type() const'
Prueba1.cpp:(.text+0xa37): undefined reference to `Leap::Bone::direction() const'
Prueba1.cpp:(.text+0xa4f): undefined reference to `Leap::Bone::direction() const'
Prueba1.cpp:(.text+0xa87): undefined reference to `Leap::Bone::direction() const'
Prueba1.cpp:(.text+0xa9f): undefined reference to `Leap::Bone::direction() const'
Prueba1.cpp:(.text+0xad7): undefined reference to `Leap::Bone::direction() const'
/tmp/cc9HTgYi.o:Prueba1.cpp:(.text+0xaef): more undefined references to `Leap::Bone::direction() const' follow
/tmp/cc9HTgYi.o: In function `Escuchador::onFrame(Leap::Controller const&)':
Prueba1.cpp:(.text+0xbf8): undefined reference to `Leap::Finger::type() const'
Prueba1.cpp:(.text+0xc1b): undefined reference to `Leap::Bone::direction() const'
Prueba1.cpp:(.text+0xc33): undefined reference to `Leap::Bone::direction() const'
Prueba1.cpp:(.text+0xc6b): undefined reference to `Leap::Bone::direction() const'
Prueba1.cpp:(.text+0xc83): undefined reference to `Leap::Bone::direction() const'
Prueba1.cpp:(.text+0xcbb): undefined reference to `Leap::Bone::direction() const'
/tmp/cc9HTgYi.o:Prueba1.cpp:(.text+0xcd3): more undefined references to `Leap::Bone::direction() const' follow
/tmp/cc9HTgYi.o: In function `Escuchador::onFrame(Leap::Controller const&)':
Prueba1.cpp:(.text+0xeb4): undefined reference to `Leap::FingerList::end() const'
Prueba1.cpp:(.text+0xf27): undefined reference to `Leap::HandList::end() const'
/tmp/cc9HTgYi.o: In function `main':
Prueba1.cpp:(.text+0x11a3): undefined reference to `Leap::Controller::Controller()'
Prueba1.cpp:(.text+0x11b7): undefined reference to `Leap::Controller::addListener(Leap::Listener&)'
Prueba1.cpp:(.text+0x11fb): undefined reference to `Leap::Controller::removeListener(Leap::Listener&)'
Prueba1.cpp:(.text+0x120c): undefined reference to `Leap::Controller::~Controller()'
Prueba1.cpp:(.text+0x122a): undefined reference to `Leap::Controller::~Controller()'
/tmp/cc9HTgYi.o: In function `Leap::Pointable::~Pointable()':
Prueba1.cpp:(.text._ZN4Leap9PointableD2Ev[_ZN4Leap9PointableD5Ev]+0x16): undefined reference to `Leap::Interface::~Interface()'
/tmp/cc9HTgYi.o: In function `Leap::Bone::operator=(Leap::Bone&&)':
Prueba1.cpp:(.text._ZN4Leap4BoneaSEOS0_[_ZN4Leap4BoneaSEOS0_]+0x14): undefined reference to `Leap::Interface::operator=(Leap::Interface const&)'
/tmp/cc9HTgYi.o: In function `Leap::ConstListIterator<Leap::HandList, Leap::Hand>::operator*() const':
Prueba1.cpp:(.text._ZNK4Leap17ConstListIteratorINS_8HandListENS_4HandEEdeEv[_ZNK4Leap17ConstListIteratorINS_8HandListENS_4HandEEdeEv]+0x20): undefined reference to `Leap::HandList::operator[](int) const'
/tmp/cc9HTgYi.o: In function `Leap::ConstListIterator<Leap::FingerList, Leap::Finger>::operator*() const':
Prueba1.cpp:(.text._ZNK4Leap17ConstListIteratorINS_10FingerListENS_6FingerEEdeEv[_ZNK4Leap17ConstListIteratorINS_10FingerListENS_6FingerEEdeEv]+0x20): undefined reference to `Leap::FingerList::operator[](int) const'
/tmp/cc9HTgYi.o: In function `Leap::Frame::~Frame()':
Prueba1.cpp:(.text._ZN4Leap5FrameD2Ev[_ZN4Leap5FrameD5Ev]+0x16): undefined reference to `Leap::Interface::~Interface()'
/tmp/cc9HTgYi.o: In function `Leap::HandList::~HandList()':
Prueba1.cpp:(.text._ZN4Leap8HandListD2Ev[_ZN4Leap8HandListD5Ev]+0x16): undefined reference to `Leap::Interface::~Interface()'
/tmp/cc9HTgYi.o: In function `Leap::FingerList::~FingerList()':
Prueba1.cpp:(.text._ZN4Leap10FingerListD2Ev[_ZN4Leap10FingerListD5Ev]+0x16): undefined reference to `Leap::Interface::~Interface()'
/tmp/cc9HTgYi.o: In function `Leap::Hand::~Hand()':
Prueba1.cpp:(.text._ZN4Leap4HandD2Ev[_ZN4Leap4HandD5Ev]+0x16): undefined reference to `Leap::Interface::~Interface()'
/tmp/cc9HTgYi.o: In function `Leap::Bone::~Bone()':
Prueba1.cpp:(.text._ZN4Leap4BoneD2Ev[_ZN4Leap4BoneD5Ev]+0x16): undefined reference to `Leap::Interface::~Interface()'
/tmp/cc9HTgYi.o:(.rodata._ZTIN4Leap5FrameE[_ZTIN4Leap5FrameE]+0x8): undefined reference to `typeinfo for Leap::Interface'
/tmp/cc9HTgYi.o:(.rodata._ZTIN4Leap8HandListE[_ZTIN4Leap8HandListE]+0x8): undefined reference to `typeinfo for Leap::Interface'
/tmp/cc9HTgYi.o:(.rodata._ZTIN4Leap10FingerListE[_ZTIN4Leap10FingerListE]+0x8): undefined reference to `typeinfo for Leap::Interface'
/tmp/cc9HTgYi.o:(.rodata._ZTIN4Leap4HandE[_ZTIN4Leap4HandE]+0x8): undefined reference to `typeinfo for Leap::Interface'
/tmp/cc9HTgYi.o:(.rodata._ZTIN4Leap4BoneE[_ZTIN4Leap4BoneE]+0x8): undefined reference to `typeinfo for Leap::Interface'
/tmp/cc9HTgYi.o:(.rodata._ZTIN4Leap9PointableE[_ZTIN4Leap9PointableE]+0x8): more undefined references to `typeinfo for Leap::Interface' follow
collect2: error: ld returned 1 exit status
make: *** [Prueba1] Error 1
My #include are:
#include <iostream>
#include <cstring>
#include "Leap.h"
So it seems the problem is with the Leap.h header. In the SDK there is a Sample.cpp that I can compile and runs great. Im using the same makefile and the same filesystem; I am using the same #include than the Sample.cpp, so I move my .cpp file into the same folder the Sample.cpp is and try to compile, and I get the error. I dont know how to solve it, any ideas? Here is the makefile:
OS := $(shell uname)
ARCH := $(shell uname -m)
CXXFLAGS := -std=c++0x -std=c++0x
ifeq ($(OS), Linux)
ifeq ($(ARCH), x86_64)
LEAP_LIBRARY := ../lib/x64/libLeap.so -Wl,-rpath,../lib/x64
else
LEAP_LIBRARY := ../lib/x86/libLeap.so -Wl,-rpath,../lib/x86
endif
else
# OS X
LEAP_LIBRARY := ../lib/libLeap.dylib
endif
Sample: Sample.cpp
$(CXX) -Wall -g -I../include Sample.cpp -o Sample $(LEAP_LIBRARY)
ifeq ($(OS), Darwin)
install_name_tool -change #loader_path/libLeap.dylib ../lib/libLeap.dylib Sample
endif
clean:
rm -rf Sample Sample.dSYM
I only added the CXXFLAGS to solve a C+98 compiler error. I can compile the Sample.cpp this way too, but when I try to do the same on my file, I get the errors. Thanks for the help!

So it seems the problem is with the Leap.h header.
No, there's no problem with the header. You're simply not linking to the library that provides the definitions of those functions.
Look at how the makefile builds the sample program: it links to libleap.so,
You need to do the same:
g++ -std=c++0x -std=c++0x Prueba1.cpp -o Prueba1 ../lib/x64/libleap.so -Wl,-rpath,../lib/x64
(replacing x64 with x86 if you're on a 32-bit system).

First, required reading: What is an undefined reference/unresolved external symbol error and how do I fix it? Please read at least answers related to external library components, then return to this question.
OK so in your case you are running a link command without specifying the external library. How come? Why are you able to compile a sample that comes with the package?
Take a look at the makefile. It says
Sample: Sample.cpp
$(CXX) -Wall -g -I../include Sample.cpp -o Sample $(LEAP_LIBRARY)
This rule tells make three things: what to build (the first line before the colon), what to build it from (after the colon), and how to build it (the second line). So when you run a command like
make Sample
make has a pretty good idea what to do.
Now if you say
make Prueba1
things are a bit different. There are no special rules in the makefile that talk about Prueba1, so make fetches its (huge) set of built-in rules and looks for one that would allow it to build Prueba1 for you. There is indeed such a built-in rule, but it doesn't know about libLeap.so. This is why you don't see it in your build log.
Of course you can add something like this to your makefile:
Prueba1: Prueba1.cpp
$(CXX) -Wall -g -I../include Prueba1.cpp -o Prueba1 $(LEAP_LIBRARY)
but I'd venture to guess that it will grow somewhat old when you get to Prueba99. Can we do better?
Yes we can, but let's answer another question first. How come your compilation command knows about -std=c++0x?
This is because you added this flag to a built-in macro CXXFLAGS, and the built-in rule uses this macro. By the way you don't need to specify -std=c++0x twice.
Is there a way to treat the libraries similarly to compiler flags? Absolutely! There are two built in macros LDLIBS and LDFLAGS. If you define them this way:
LDLIBS := ../lib/x64/libLeap.so
LDFLAGS := -Wl,-rpath,../lib/x64
or (alternatively)
LDLIBS := -lLeap
LDFLAGS := -L ../lib/x64 -Wl,-rpath,../lib/x64
your makefile should be able to build any C++ program against libLeap (if it is written as a single C++ source file).
It is probably wise to add -I../include to CPPFLAGS since the Sample rule uses it. Your compilation seems to work without it but it may fail if you e.g. change your working directory.

Related

Can't build C++ program using Pistache.io due to link errors

I followed the instructions on the official website to build and install Pistache.io. Now, I'm trying to build this sample program from the official repository: https://github.com/pistacheio/pistache/blob/master/examples/hello_server.cc
However, I get the following error even though I've used the -lpistache flag:
g++ -Wall -Wextra -std=c++17 -lpistache hellopis.cpp -o hellopis
/usr/bin/ld: /tmp/ccuHXrLC.o: warning: relocation against `_ZTVN8Pistache3Tcp7HandlerE' in read-only section `.text._ZN8Pistache3Tcp7HandlerC2ERKS1_[_ZN8Pistache3Tcp7HandlerC5ERKS1_]'
/usr/bin/ld: /tmp/ccuHXrLC.o: in function `main':
hellopis.cpp:(.text+0x3b): undefined reference to `Pistache::Port::Port(unsigned short)'
/usr/bin/ld: hellopis.cpp:(.text+0x4a): undefined reference to `Pistache::IP::any()'
/usr/bin/ld: hellopis.cpp:(.text+0x9f): undefined reference to `Pistache::Address::Address(Pistache::IP, Pistache::Port)'
/usr/bin/ld: hellopis.cpp:(.text+0xb2): undefined reference to `Pistache::Http::Endpoint::options()'
/usr/bin/ld: hellopis.cpp:(.text+0xc6): undefined reference to `Pistache::Http::Endpoint::Options::threads(int)'
/usr/bin/ld: hellopis.cpp:(.text+0x103): undefined reference to `Pistache::Http::Endpoint::Endpoint(Pistache::Address const&)'
/usr/bin/ld: hellopis.cpp:(.text+0x11c): undefined reference to `Pistache::Http::Endpoint::init(Pistache::Http::Endpoint::Options const&)'
/usr/bin/ld: hellopis.cpp:(.text+0x151): undefined reference to `Pistache::Http::Endpoint::setHandler(std::shared_ptr<Pistache::Http::Handler> const&)'
/usr/bin/ld: hellopis.cpp:(.text+0x178): undefined reference to `Pistache::Http::Endpoint::serve()'
/usr/bin/ld: /tmp/ccuHXrLC.o: in function `Pistache::Http::Endpoint::~Endpoint()':
hellopis.cpp:(.text._ZN8Pistache4Http8EndpointD2Ev[_ZN8Pistache4Http8EndpointD5Ev]+0x3c): undefined reference to `Pistache::Tcp::Listener::~Listener()'
/usr/bin/ld: /tmp/ccuHXrLC.o: in function `Pistache::Async::Promise<long> Pistache::Http::ResponseWriter::send<13ul>(Pistache::Http::Code, char const (&) [13ul], Pistache::Http::Mime::MediaType const&)':
hellopis.cpp:(.text._ZN8Pistache4Http14ResponseWriter4sendILm13EEENS_5Async7PromiseIlEENS0_4CodeERAT__KcRKNS0_4Mime9MediaTypeE[_ZN8Pistache4Http14ResponseWriter4sendILm13EEENS_5Async7PromiseIlEENS0_4CodeERAT__KcRKNS0_4Mime9MediaTypeE]+0x3b): undefined reference to `Pistache::Http::ResponseWriter::sendImpl(Pistache::Http::Code, char const*, unsigned long, Pistache::Http::Mime::MediaType const&)'
/usr/bin/ld: /tmp/ccuHXrLC.o: in function `Pistache::Tcp::Handler::Handler(Pistache::Tcp::Handler const&)':
hellopis.cpp:(.text._ZN8Pistache3Tcp7HandlerC2ERKS1_[_ZN8Pistache3Tcp7HandlerC5ERKS1_]+0x26): undefined reference to `vtable for Pistache::Tcp::Handler'
/usr/bin/ld: /tmp/ccuHXrLC.o: in function `Pistache::Http::Handler::Handler(Pistache::Http::Handler const&)':
hellopis.cpp:(.text._ZN8Pistache4Http7HandlerC2ERKS1_[_ZN8Pistache4Http7HandlerC5ERKS1_]+0x26): undefined reference to `vtable for Pistache::Http::Handler'
/usr/bin/ld: /tmp/ccuHXrLC.o: in function `Pistache::Http::Handler::~Handler()':
hellopis.cpp:(.text._ZN8Pistache4Http7HandlerD2Ev[_ZN8Pistache4Http7HandlerD5Ev]+0xf): undefined reference to `vtable for Pistache::Http::Handler'
/usr/bin/ld: hellopis.cpp:(.text._ZN8Pistache4Http7HandlerD2Ev[_ZN8Pistache4Http7HandlerD5Ev]+0x22): undefined reference to `Pistache::Tcp::Handler::~Handler()'
/usr/bin/ld: /tmp/ccuHXrLC.o: in function `Pistache::Http::Handler::Handler()':
hellopis.cpp:(.text._ZN8Pistache4Http7HandlerC2Ev[_ZN8Pistache4Http7HandlerC5Ev]+0x15): undefined reference to `Pistache::Tcp::Handler::Handler()'
/usr/bin/ld: hellopis.cpp:(.text._ZN8Pistache4Http7HandlerC2Ev[_ZN8Pistache4Http7HandlerC5Ev]+0x1c): undefined reference to `vtable for Pistache::Http::Handler'
/usr/bin/ld: hellopis.cpp:(.text._ZN8Pistache4Http7HandlerC2Ev[_ZN8Pistache4Http7HandlerC5Ev]+0x7b): undefined reference to `Pistache::Tcp::Handler::~Handler()'
/usr/bin/ld: /tmp/ccuHXrLC.o:(.data.rel.ro._ZTV12HelloHandler[_ZTV12HelloHandler]+0x28): undefined reference to `Pistache::Http::Handler::onInput(char const*, unsigned long, std::shared_ptr<Pistache::Tcp::Peer> const&)'
/usr/bin/ld: /tmp/ccuHXrLC.o:(.data.rel.ro._ZTV12HelloHandler[_ZTV12HelloHandler]+0x30): undefined reference to `Pistache::Http::Handler::onConnection(std::shared_ptr<Pistache::Tcp::Peer> const&)'
/usr/bin/ld: /tmp/ccuHXrLC.o:(.data.rel.ro._ZTV12HelloHandler[_ZTV12HelloHandler]+0x38): undefined reference to `Pistache::Tcp::Handler::onDisconnection(std::shared_ptr<Pistache::Tcp::Peer> const&)'
/usr/bin/ld: /tmp/ccuHXrLC.o:(.data.rel.ro._ZTV12HelloHandler[_ZTV12HelloHandler]+0x48): undefined reference to `Pistache::Http::Handler::onTimeout(Pistache::Http::Request const&, Pistache::Http::ResponseWriter)'
/usr/bin/ld: /tmp/ccuHXrLC.o:(.data.rel.ro._ZTI12HelloHandler[_ZTI12HelloHandler]+0x10): undefined reference to `typeinfo for Pistache::Http::Handler'
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE
collect2: error: ld returned 1 exit status
make: *** [<builtin>: hellopis] Error 1
What is this error and how can I resolve it?
The problem was resolved when I invoked the g++ command myself without using the Makefile. In particular, I ran the following command: g++ -Wall -Wextra -std=c++17 hellopis.cpp -o hellopis -lpistache.
My Makefile is as follows:
CXXFLAGS=-Wall -Wextra -std=c++17
LDFLAGS=-lpistache

How to link MinGW (gcc) and TBB

I am trying to compile my TBB program using MinGW. I know that TBB is installed on my machine correctly because it compiles just fine in Visual Studio. Do I have to do something more to tell MinGW where TBB is installed? Or is just linking the library all that is needed? I am getting these error, when trying to compile using gcc.
C:\Users\Owner\Desktop\New folder\OpenMP vs TBB>make
g++ -LC:\tbb\tbb\lib\intel64\vc14 -O3 -o pps avl.o main.o parPlaneSweep.o -fopenmp -ltbb
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text+0x433f): undefined reference to `tbb::task_group_context::init()'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text+0x435d): undefined reference to `tbb::internal::allocate_root_with_context_proxy::allocate(unsigned int) const'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text+0x439d): undefined reference to `tbb::internal::get_initial_auto_partitioner_divisor()'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text+0x43d0): undefined reference to `tbb::task_group_context::~task_group_context()'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text+0x47d5): undefined reference to `tbb::task_group_context::init()'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text+0x47f3): undefined reference to `tbb::internal::allocate_root_with_context_proxy::allocate(unsigned int) const'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text+0x4835): undefined reference to `tbb::internal::get_initial_auto_partitioner_divisor()'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text+0x4868): undefined reference to `tbb::task_group_context::~task_group_context()'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text+0x7743): undefined reference to `tbb::internal::allocate_continuation_proxy::allocate(unsigned int) const'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text+0x776c): undefined reference to `tbb::internal::allocate_child_proxy::allocate(unsigned int) const'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text+0x7a66): undefined reference to `tbb::task_group_context::is_group_execution_cancelled() const'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text+0x7abc): undefined reference to `tbb::internal::allocate_continuation_proxy::allocate(unsigned int) const'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text+0x7ae5): undefined reference to `tbb::internal::allocate_child_proxy::allocate(unsigned int) const'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text+0x8cab): undefined reference to `tbb::internal::allocate_continuation_proxy::allocate(unsigned int) const'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text+0x8cd4): undefined reference to `tbb::internal::allocate_child_proxy::allocate(unsigned int) const'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text+0x8f69): undefined reference to `tbb::task_group_context::is_group_execution_cancelled() const'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text+0x8fb4): undefined reference to `tbb::internal::allocate_continuation_proxy::allocate(unsigned int) const'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text+0x8fdd): undefined reference to `tbb::internal::allocate_child_proxy::allocate(unsigned int) const'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text$_ZN3tbb4flow11interface105graphD1Ev[__ZN3tbb4flow11interface105graphD1Ev]+0x43): undefined reference to `tbb::interface7::internal::task_arena_base::internal_execute(tbb::interface7::internal::delegate_base&) const'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text$_ZN3tbb4flow11interface105graphD1Ev[__ZN3tbb4flow11interface105graphD1Ev]+0x4e): undefined reference to `tbb::task_group_context::is_group_execution_cancelled() const'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text$_ZN3tbb4flow11interface105graphD1Ev[__ZN3tbb4flow11interface105graphD1Ev]+0x73): undefined reference to `tbb::interface5::internal::task_base::destroy(tbb::task&)'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text$_ZN3tbb4flow11interface105graphD1Ev[__ZN3tbb4flow11interface105graphD1Ev]+0x87): undefined reference to `tbb::task_group_context::~task_group_context()'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text$_ZN3tbb4flow11interface105graphD1Ev[__ZN3tbb4flow11interface105graphD1Ev]+0xe3): undefined reference to `tbb::interface7::internal::task_arena_base::internal_terminate()'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text$_ZN3tbb4flow11interface105graphD1Ev[__ZN3tbb4flow11interface105graphD1Ev]+0xf1): undefined reference to `tbb::task_group_context::reset()'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text$_ZN3tbb4flow11interface105graphD1Ev[__ZN3tbb4flow11interface105graphD1Ev]+0x10b): undefined reference to `tbb::interface7::internal::task_arena_base::internal_initialize()'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text$_ZN3tbb4flow11interface105graphD1Ev[__ZN3tbb4flow11interface105graphD1Ev]+0x12e): undefined reference to `tbb::task_group_context::reset()'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text$_ZN3tbb4flow11interface105graphD0Ev[__ZN3tbb4flow11interface105graphD0Ev]+0x44): undefined reference to `tbb::interface7::internal::task_arena_base::internal_execute(tbb::interface7::internal::delegate_base&) const'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text$_ZN3tbb4flow11interface105graphD0Ev[__ZN3tbb4flow11interface105graphD0Ev]+0x4f): undefined reference to `tbb::task_group_context::is_group_execution_cancelled() const'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text$_ZN3tbb4flow11interface105graphD0Ev[__ZN3tbb4flow11interface105graphD0Ev]+0x74): undefined reference to `tbb::interface5::internal::task_base::destroy(tbb::task&)'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text$_ZN3tbb4flow11interface105graphD0Ev[__ZN3tbb4flow11interface105graphD0Ev]+0x88): undefined reference to `tbb::task_group_context::~task_group_context()'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text$_ZN3tbb4flow11interface105graphD0Ev[__ZN3tbb4flow11interface105graphD0Ev]+0xf3): undefined reference to `tbb::interface7::internal::task_arena_base::internal_terminate()'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text$_ZN3tbb4flow11interface105graphD0Ev[__ZN3tbb4flow11interface105graphD0Ev]+0x101): undefined reference to `tbb::task_group_context::reset()'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text$_ZN3tbb4flow11interface105graphD0Ev[__ZN3tbb4flow11interface105graphD0Ev]+0x11b): undefined reference to `tbb::interface7::internal::task_arena_base::internal_initialize()'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text$_ZN3tbb4flow11interface105graphD0Ev[__ZN3tbb4flow11interface105graphD0Ev]+0x13e): undefined reference to `tbb::task_group_context::reset()'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text.unlikely+0xf3): undefined reference to `tbb::internal::allocate_root_with_context_proxy::free(tbb::task&) const'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text.unlikely+0xff): undefined reference to `tbb::task_group_context::~task_group_context()'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text.unlikely+0x118): undefined reference to `tbb::internal::allocate_root_with_context_proxy::free(tbb::task&) const'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.rdata$_ZTVN3tbb10interface98internal9flag_taskE[__ZTVN3tbb10interface98internal9flag_taskE]+0x14): undefined reference to `tbb::task::note_affinity(unsigned short)'
collect2.exe: error: ld returned 1 exit status
Makefile:10: recipe for target 'pps' failed
make: *** [pps] Error 1
This is what my current Makefile looks like right now.
CC=gcc
CPLUSPLUS = g++
OPTFLAGS = -O3
TBB_INCLUDE_PATH = C:\tbb-2020.1-win\tbb\include
TBB_LIBRARY_PATH = C:\tbb\tbb\lib\intel64\vc14
all: pps
pps: avl.o main.o parPlaneSweep.o
$(CPLUSPLUS) -L$(TBB_LIBRARY_PATH) $(OPTFLAGS) -o $# $^ -fopenmp -ltbb
avl.o: avl.h avl.c
$(CC) -c $(OPTFLAGS) -fPIC avl.c
main.o: main.cpp parPlaneSweep.h
$(CPLUSPLUS) -c $(OPTFLAGS) -fopenmp main.cpp
parPlaneSweep.o: parPlaneSweep.h parPlaneSweep.cpp
$(CPLUSPLUS) -c $(OPTFLAGS) -ITBB_INCLUDE_PATH -fPIC -fopenmp parPlaneSweep.cpp
clean:
rm *.o
rm pps
MinGW and MSVC are different toolchains, even though both can produce EXE/DLL files in "native" Windows format. But the C++ symbol decoration (aka mangling) is done very differently, so the same function in source code would be compiled into differently named binary functions. There might also be more application binary interface (ABI) differences between the toolchains. Therefore you cannot simply link object files/libraries created by/for MinGW and by/for MSVC; you need all libraries to be prepared with the same toolchain.
You can build TBB binaries for MinGW on your own (it's supported in TBB makefiles), or you can try finding a ready-to-use package such as the one for MSYS2 mentioned in the comments to the question.

Compiling Qt5 App on Raspberry

I'd like to compile a program on my Raspberry Pi 3.
I've installed the latest Raspbian and crosscompiled Qt 5.8 as described in this manual and then I've tried to build GST to run it on the board. The compile process seems to finish, however, I've got following linker errors:
root#raspberrypi:/home/pi/headunit-WIP-headunit-gst/gst# make
g++ -fPIC -std=c++11 `pkg-config --cflags gstreamer-1.0 gstreamer-app-1.0 gstreamer-video-1.0 libcrypto libusb-1.0 openssl` -I../jni -I/opt/Qt5.8/include/QtWidgets -I/opt/Qt5.8/include -I/opt/Qt5.8/include/QtGui -c main.cc -o main.o
g++ -o headunit ../jni/hu_aad.o ../jni/hu_aap.o ../jni/hu_ssl.o ../jni/hu_usb.o ../jni/hu_uti.o main.o `pkg-config --libs gstreamer-1.0 gstreamer-app-1.0 gstreamer-video-1.0 libcrypto libusb-1.0 openssl` -L/opt/Qt5.8/include/QtCore/QtCore -L/opt/Qt5.8/include/QtWidgets/QtWidgets -L/opt/Qt5.8/include/QtGui/QtGui
main.o: In function `gst_loop(gst_app_t*, QApplication*)':
main.cc:(.text+0xb5c): undefined reference to `QApplication::exec()'
main.o: In function `main':
main.cc:(.text+0x10e0): undefined reference to `QApplication::QApplication(int&, char**, int)'
main.cc:(.text+0x10f0): undefined reference to `qFlagLocation(char const*)'
main.cc:(.text+0x1104): undefined reference to `qFlagLocation(char const*)'
main.cc:(.text+0x1134): undefined reference to `QObject::connect(QObject const*, char const*, QObject const*, char const*, Qt::ConnectionType)'
main.cc:(.text+0x1140): undefined reference to `QMetaObject::Connection::~Connection()'
main.cc:(.text+0x1178): undefined reference to `QWidget::show()'
main.cc:(.text+0x11bc): undefined reference to `QWidget::winId() const'
main.cc:(.text+0x1280): undefined reference to `QWidget::hide()'
main.cc:(.text+0x12c4): undefined reference to `QApplication::~QApplication()'
main.cc:(.text+0x12e4): undefined reference to `QApplication::~QApplication()'
main.o: In function `QWidget::resize(int, int)':
main.cc:(.text._ZN7QWidget6resizeEii[_ZN7QWidget6resizeEii]+0x38): undefined reference to `QWidget::resize(QSize const&)'
main.o: In function `HuMainWindow::HuMainWindow()':
main.cc:(.text._ZN12HuMainWindowC2Ev[_ZN12HuMainWindowC5Ev]+0x38): undefined reference to `QMainWindow::QMainWindow(QWidget*, QFlags<Qt::WindowType>)'
main.o: In function `HuMainWindow::~HuMainWindow()':
main.cc:(.text._ZN12HuMainWindowD2Ev[_ZN12HuMainWindowD5Ev]+0x48): undefined reference to `QMainWindow::~QMainWindow()'
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0x8): undefined reference to `QMainWindow::metaObject() const'
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0xc): undefined reference to `QMainWindow::qt_metacast(char const*)'
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0x10): undefined reference to `QMainWindow::qt_metacall(QMetaObject::Call, int, void**)'
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0x1c): undefined reference to `QMainWindow::event(QEvent*)'
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0x20): undefined reference to `QObject::eventFilter(QObject*, QEvent*)'
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0x24): undefined reference to `QObject::timerEvent(QTimerEvent*)'
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0x28): undefined reference to `QObject::childEvent(QChildEvent*)'
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0x2c): undefined reference to `QObject::customEvent(QEvent*)'
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0x30): undefined reference to `QObject::connectNotify(QMetaMethod const&)'
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0x34): undefined reference to `QObject::disconnectNotify(QMetaMethod const&)'
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0x38): undefined reference to `QWidget::devType() const'
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0x3c): undefined reference to `QWidget::setVisible(bool)'
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0x40): undefined reference to `QWidget::sizeHint() const'
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0x44): undefined reference to `QWidget::minimumSizeHint() const'
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0x48): undefined reference to `QWidget::heightForWidth(int) const'
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0x4c): undefined reference to `QWidget::hasHeightForWidth() const'
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0x50): undefined reference to `QWidget::paintEngine() const'
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0x5c): undefined reference to `QWidget::mouseDoubleClickEvent(QMouseEvent*)'
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0x64): undefined reference to `QWidget::wheelEvent(QWheelEvent*)'
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0x68): undefined reference to `QWidget::keyPressEvent(QKeyEvent*)'
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0x6c): undefined reference to `QWidget::keyReleaseEvent(QKeyEvent*)'
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0x70): undefined reference to `QWidget::focusInEvent(QFocusEvent*)'
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0x74): undefined reference to `QWidget::focusOutEvent(QFocusEvent*)'
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0x78): undefined reference to `QWidget::enterEvent(QEvent*)'
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0x7c): undefined reference to `QWidget::leaveEvent(QEvent*)'
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0x80): undefined reference to `QWidget::paintEvent(QPaintEvent*)'
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0x84): undefined reference to `QWidget::moveEvent(QMoveEvent*)'
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0x88): undefined reference to `QWidget::resizeEvent(QResizeEvent*)'
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0x8c): undefined reference to `QWidget::closeEvent(QCloseEvent*)'
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0x90): undefined reference to `QMainWindow::contextMenuEvent(QContextMenuEvent*)'
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0x94): undefined reference to `QWidget::tabletEvent(QTabletEvent*)'
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0x98): undefined reference to `QWidget::actionEvent(QActionEvent*)'
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0x9c): undefined reference to `QWidget::dragEnterEvent(QDragEnterEvent*)'
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0xa0): undefined reference to `QWidget::dragMoveEvent(QDragMoveEvent*)'
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0xa4): undefined reference to `QWidget::dragLeaveEvent(QDragLeaveEvent*)'
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0xa8): undefined reference to `QWidget::dropEvent(QDropEvent*)'
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0xac): undefined reference to `QWidget::showEvent(QShowEvent*)'
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0xb0): undefined reference to `QWidget::hideEvent(QHideEvent*)'
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0xb4): undefined reference to `QWidget::nativeEvent(QByteArray const&, void*, long*)'
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0xb8): undefined reference to `QWidget::changeEvent(QEvent*)'
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0xbc): undefined reference to `QWidget::metric(QPaintDevice::PaintDeviceMetric) const'
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0xc0): undefined reference to `QWidget::initPainter(QPainter*) const'
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0xc4): undefined reference to `QWidget::redirected(QPoint*) const'
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0xc8): undefined reference to `QWidget::sharedPainter() const'
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0xcc): undefined reference to `QWidget::inputMethodEvent(QInputMethodEvent*)'
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0xd0): undefined reference to `QWidget::inputMethodQuery(Qt::InputMethodQuery) const'
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0xd4): undefined reference to `QWidget::focusNextPrevChild(bool)'
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0xd8): undefined reference to `QMainWindow::createPopupMenu()'
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0xec): undefined reference to `non-virtual thunk to QWidget::devType() const'
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0xf0): undefined reference to `non-virtual thunk to QWidget::paintEngine() const'
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0xf4): undefined reference to `non-virtual thunk to QWidget::metric(QPaintDevice::PaintDeviceMetric) const'
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0xf8): undefined reference to `non-virtual thunk to QWidget::initPainter(QPainter*) const'
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0xfc): undefined reference to `non-virtual thunk to QWidget::redirected(QPoint*) const'
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0x100): undefined reference to `non-virtual thunk to QWidget::sharedPainter() const'
main.o:(.data.rel.ro._ZTI12HuMainWindow[_ZTI12HuMainWindow]+0x8): undefined reference to `typeinfo for QMainWindow'
collect2: error: ld returned 1 exit status
Makefile:23: recipe for target 'headunit' failed
make: *** [headunit] Error 1
As far as I understand, there is no reference to QApplication, but I wrote it in the Makefile:
CC=gcc
CPP=g++
LD=ld
INCLUDES=`pkg-config --cflags gstreamer-1.0 gstreamer-app-1.0 gstreamer-video-1.0 libcrypto libusb-1.0 openssl` -I$(TOP)/jni -I/opt/Qt5.8/include/QtWidgets -I/opt/Qt5.8/include -I/opt/Qt5.8/include/QtGui
CFLAGS=
CPPFLAGS=-fPIC -std=c++11
LFLAGS=`pkg-config --libs gstreamer-1.0 gstreamer-app-1.0 gstreamer-video-1.0 libcrypto libusb-1.0 openssl` -L/opt/Qt5.8/include/QtCore/QtCore -L/opt/Qt5.8/include/QtWidgets/QtWidgets -L/opt/Qt5.8/include/QtGui/QtGui
TOP = ..
AASRCS = $(TOP)/jni/hu_aad.c \
$(TOP)/jni/hu_aap.c \
$(TOP)/jni/hu_ssl.c \
$(TOP)/jni/hu_usb.c \
$(TOP)/jni/hu_uti.c
HSRCS = main.cc
OBJS = $(AASRCS:.c=.o) $(HSRCS:.cc=.o)
APP = headunit
.PHONY: depend clean
all: $(APP)
$(APP): $(OBJS)
$(CPP) -o $(APP) $(OBJS) $(LFLAGS)
.c.o:
$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $#
.cc.o:
$(CPP) $(CPPFLAGS) $(INCLUDES) -c $< -o $#
clean:
rm -f $(OBJS) *~ $(APP)
depend: $(SRCS)
makedepend $^
# DO NOT DELETE
I also tried qmake -project to get a project file and then qmake and make.
But then i receive other errors.
Maybe someone can help me fixing these problems to finally compile this program.
did you try to let the Pi find the libraries by adding the /lib folder of the Qt installation to ld.so.conf?
In your case this would maybe look like echo /opt/Qt5.8/lib | sudo tee /etc/ld.so.conf.d/qt5pi.conf
After that you have to reload the ld.so.conf by using sudo ldconfig
Now the linker can find the Qt-Libs without any additions to your Makefile.
Maybe this will help you.

Getting unexpected "undefined reference to" errors when compiling with a static library

I've been trying to make a static library out of this: https://github.com/onlinecity/cpp-smpp , as I'd like to make a single file executable that uses it.
So far I have gone into src/smpp/ and created the .o files with:
g++-5 -c *.cpp -std=c++11 -I.
Then made them into an .a file with:
ar rvs libsmpp.a *.o
Then I'm trying to compile a small main.cpp file that uses the library with this:
g++-5 main.cpp -I/usr/local/include -static libsmpp.a -lboost_system -lboost_regex -lboost_date_time -lpthread -lm -lglog -lgflags -std=c++11
And I get some undefined reference errors:
/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a(condition_variable.o): In function `std::condition_variable::~condition_variable()':
(.text._ZNSt18condition_variableD2Ev+0x1): undefined reference to `pthread_cond_destroy'
/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a(condition_variable.o): In function `std::condition_variable::wait(std::unique_lock<std::mutex>&)':
(.text._ZNSt18condition_variable4waitERSt11unique_lockISt5mutexE+0x8): undefined reference to `pthread_cond_wait'
libsmpp.a(smppclient.o): In function `smpp::SmppClient::sendPdu(smpp::PDU&)':
smppclient.cpp:(.text+0x22a1): undefined reference to `google::LogMessage::LogMessage(char const*, int)'
smppclient.cpp:(.text+0x22b0): undefined reference to `google::LogMessage::stream()'
smppclient.cpp:(.text+0x22d4): undefined reference to `google::LogMessage::~LogMessage()'
smppclient.cpp:(.text+0x2534): undefined reference to `google::LogMessage::~LogMessage()'
libsmpp.a(smppclient.o): In function `smpp::SmppClient::readPdu(bool const&)':
smppclient.cpp:(.text+0x29d8): undefined reference to `google::LogMessage::LogMessage(char const*, int)'
smppclient.cpp:(.text+0x29e7): undefined reference to `google::LogMessage::stream()'
smppclient.cpp:(.text+0x2a0b): undefined reference to `google::LogMessage::~LogMessage()'
smppclient.cpp:(.text+0x2a48): undefined reference to `google::LogMessage::~LogMessage()'
libsmpp.a(smppclient.o): In function `boost::asio::detail::posix_event::~posix_event()':
smppclient.cpp:(.text._ZN5boost4asio6detail11posix_eventD2Ev[_ZN5boost4asio6detail11posix_eventD5Ev]+0x14): undefined reference to `pthread_cond_destroy'
libsmpp.a(smppclient.o): In function `boost::asio::detail::posix_event::posix_event()':
smppclient.cpp:(.text._ZN5boost4asio6detail11posix_eventC2Ev[_ZN5boost4asio6detail11posix_eventC5Ev]+0x2e): undefined reference to `pthread_cond_init'
libsmpp.a(smppclient.o): In function `void boost::asio::detail::posix_event::wait<boost::asio::detail::scoped_lock<boost::asio::detail::posix_mutex> >(boost::asio::detail::scoped_lock<boost::asio::detail::posix_mutex>&)':
smppclient.cpp:(.text._ZN5boost4asio6detail11posix_event4waitINS1_11scoped_lockINS1_11posix_mutexEEEEEvRT_[_ZN5boost4asio6detail11posix_event4waitINS1_11scoped_lockINS1_11posix_mutexEEEEEvRT_]+0x5f): undefined reference to `pthread_cond_wait'
libsmpp.a(timeformat.o): In function `boost::date_time::month_formatter<boost::gregorian::greg_month, boost::date_time::iso_format<char>, char>::format_month(boost::gregorian::greg_month const&, std::ostream&)':
timeformat.cpp:(.text._ZN5boost9date_time15month_formatterINS_9gregorian10greg_monthENS0_10iso_formatIcEEcE12format_monthERKS3_RSo[_ZN5boost9date_time15month_formatterINS_9gregorian10greg_monthENS0_10iso_formatIcEEcE12format_monthERKS3_RSo]+0x33): undefined reference to `boost::gregorian::greg_month::as_short_string() const'
timeformat.cpp:(.text._ZN5boost9date_time15month_formatterINS_9gregorian10greg_monthENS0_10iso_formatIcEEcE12format_monthERKS3_RSo[_ZN5boost9date_time15month_formatterINS_9gregorian10greg_monthENS0_10iso_formatIcEEcE12format_monthERKS3_RSo]+0x56): undefined reference to `boost::gregorian::greg_month::as_long_string() const'
collect2: error: ld returned 1 exit status
It compiles fine when I link to a dynamic version of the smpp library, although that's made using the cmake files included with the smpp lib. I didn't know how to modify them to output a static library, so I just used the g++ command at the top, and added the libraries listed in them (like glog) in the main.cpp compile command.
The "undefined reference to google::logMessage" seems especially strange, as I'm pretty sure thats part of glog, which is definitely loaded and included in the smppclient.cpp file itself.
Any ideas? Thanks.

Why am I getting such error message in Installing Package?

I am currently running Ubuntu 12.04.
I am looking to install This Package.
I have already installed packages:
'fftw2', 'fftw-dev', 'fftw-doc', 'fftw-3.3.4'
However, when I try to root#ubuntu:~/spectrum-master# make:
cc -lm -lasound -L/usr/lib/x86_64-linux-gnu -lSDL -lfftw3f -lm spectrum.o mmap_file.o pcm.o wav.o alsa.o window.o stft.o cqt.o trans.o -o spectrum
spectrum.o: In function handle_events': /home/userKum/spectrum-master/spectrum.c:27: undefined reference toSDL_PollEvent'
spectrum.o: In function srgb': /home/userKum/spectrum-master/spectrum.c:78: undefined reference to__powf_finite'
/home/userKum/spectrum-master/spectrum.c:76: undefined reference to __powf_finite' /home/userKum/spectrum-master/spectrum.c:77: undefined reference to__powf_finite'
spectrum.o: In function main': /home/userKum/spectrum-master/spectrum.c:126: undefined reference toSDL_Init'
/home/userKum/spectrum-master/spectrum.c:127: undefined reference to SDL_SetVideoMode' /home/userKum/spectrum-master/spectrum.c:143: undefined reference toSDL_WM_SetCaption'
/home/userKum/spectrum-master/spectrum.c:144: undefined reference to SDL_EnableKeyRepeat' /home/userKum/spectrum-master/spectrum.c:199: undefined reference to__log10f_finite'
/home/userKum/spectrum-master/spectrum.c:157: undefined reference to SDL_Flip' /home/userKum/spectrum-master/spectrum.c:158: undefined reference toSDL_Delay'
alsa.o: In function write_alsa': /home/userKum/spectrum-master/alsa.c:71: undefined reference tosnd_pcm_writei'
/home/userKum/spectrum-master/alsa.c:72: undefined reference to snd_pcm_prepare' alsa.o: In functionread_alsa':
/home/userKum/spectrum-master/alsa.c:54: undefined reference to snd_pcm_readi' /home/userKum/spectrum-master/alsa.c:55: undefined reference tosnd_pcm_prepare'
alsa.o: In function close_alsa': /home/userKum/spectrum-master/alsa.c:26: undefined reference tosnd_pcm_drain'
/home/userKum/spectrum-master/alsa.c:27: undefined reference to snd_pcm_close' alsa.o: In functionopen_alsa_read':
/home/userKum/spectrum-master/alsa.c:92: undefined reference to snd_pcm_hw_params_sizeof' /home/userKum/spectrum-master/alsa.c:92: undefined reference tosnd_pcm_hw_params_sizeof'
/home/userKum/spectrum-master/alsa.c:94: undefined reference to snd_pcm_open' /home/userKum/spectrum-master/alsa.c:100: undefined reference tosnd_pcm_hw_params_any'
/home/userKum/spectrum-master/alsa.c:107: undefined reference to snd_pcm_hw_params_set_access' /home/userKum/spectrum-master/alsa.c:114: undefined reference tosnd_pcm_hw_params_set_format'
/home/userKum/spectrum-master/alsa.c:121: undefined reference to snd_pcm_hw_params_set_rate_resample' /home/userKum/spectrum-master/alsa.c:130: undefined reference tosnd_pcm_hw_params_set_rate_min'
/home/userKum/spectrum-master/alsa.c:109: undefined reference to snd_pcm_close' /home/userKum/spectrum-master/alsa.c:137: undefined reference tosnd_pcm_hw_params'
/home/userKum/spectrum-master/alsa.c:144: undefined reference to snd_pcm_hw_params_get_rate' /home/userKum/spectrum-master/alsa.c:151: undefined reference tosnd_pcm_hw_params_get_channels'
alsa.o: In function open_alsa_write': /home/userKum/spectrum-master/alsa.c:177: undefined reference tosnd_pcm_hw_params_sizeof'
/home/userKum/spectrum-master/alsa.c:177: undefined reference to snd_pcm_hw_params_sizeof' /home/userKum/spectrum-master/alsa.c:179: undefined reference tosnd_pcm_open'
/home/userKum/spectrum-master/alsa.c:185: undefined reference to snd_pcm_hw_params_any' /home/userKum/spectrum-master/alsa.c:192: undefined reference tosnd_pcm_hw_params_set_access'
/home/userKum/spectrum-master/alsa.c:199: undefined reference to snd_pcm_hw_params_set_format' /home/userKum/spectrum-master/alsa.c:206: undefined reference tosnd_pcm_hw_params_set_rate_resample'
/home/userKum/spectrum-master/alsa.c:213: undefined reference to snd_pcm_hw_params_set_rate_near' /home/userKum/spectrum-master/alsa.c:218: undefined reference tosnd_pcm_hw_params_set_channels_near'
/home/userKum/spectrum-master/alsa.c:223: undefined reference to snd_pcm_hw_params' /home/userKum/spectrum-master/alsa.c:194: undefined reference tosnd_pcm_close'
window.o: In function sinc': /home/userKum/spectrum-master/window.c:14: undefined reference tosinf'
window.o: In function hann': /home/userKum/spectrum-master/window.c:24: undefined reference tocosf'
window.o: In function hamming': /home/userKum/spectrum-master/window.c:29: undefined reference tocosf'
window.o: In function sinc': /home/userKum/spectrum-master/window.c:14: undefined reference tosinf'
window.o: In function gauss': /home/userKum/spectrum-master/window.c:38: undefined reference to__expf_finite'
stft.o: In function free_stft': /home/userKum/spectrum-master/stft.c:44: undefined reference tofftwf_destroy_plan'
stft.o: In function get_stft': /home/userKum/spectrum-master/stft.c:38: undefined reference tocabsf'
stft.o: In function create_stft': /home/userKum/spectrum-master/stft.c:66: undefined reference tofftwf_plan_dft_r2c_1d'
stft.o: In function slide_stft': /home/userKum/spectrum-master/stft.c:31: undefined reference tofftwf_execute'
cqt.o: In function get_cqt': /home/userKum/spectrum-master/cqt.c:33: undefined reference tocabsf'
cqt.o: In function free_cqt': /home/userKum/spectrum-master/cqt.c:47: undefined reference tofftwf_destroy_plan'
cqt.o: In function create_cqt': /home/userKum/spectrum-master/cqt.c:65: undefined reference to__logf_finite'
/home/userKum/spectrum-master/cqt.c:65: undefined reference to __expf_finite' /home/userKum/spectrum-master/cqt.c:66: undefined reference to__log2_finite'
/home/userKum/spectrum-master/cqt.c:87: undefined reference to fftwf_plan_dft_1d' /home/userKum/spectrum-master/cqt.c:98: undefined reference tocexpf'
/home/userKum/spectrum-master/cqt.c:103: undefined reference to fftwf_execute' /home/userKum/spectrum-master/cqt.c:57: undefined reference tocabsf'
/home/userKum/spectrum-master/cqt.c:57: undefined reference to cabsf' /home/userKum/spectrum-master/cqt.c:115: undefined reference tocabsf'
/home/userKum/spectrum-master/cqt.c:117: undefined reference to cabsf' /home/userKum/spectrum-master/cqt.c:117: undefined reference tocabsf'
/home/userKum/spectrum-master/cqt.c:57: undefined reference to __powf_finite' /home/userKum/spectrum-master/cqt.c:139: undefined reference tofftwf_destroy_plan'
/home/userKum/spectrum-master/cqt.c:146: undefined reference to fftwf_plan_dft_r2c_1d' cqt.o: In functionslide_cqt':
/home/userKum/spectrum-master/cqt.c:30: undefined reference to `fftwf_execute'
collect2: ld returned 1 exit status
make: *** [spectrum] Error 1
I have no idea what these undefined reference is all about...... It looks it is missing a linkage to '-lasound' during compilation. What should I do so that I can solve this issue?
As requested by some of the viewer, the MakeFile is as follows:
CFLAGS = -g -D_GNU_SOURCE=1 -W -Wall -O3 -std=c99 -fno-math-errno -ffinite-math-only -fno-rounding-math -fno-signaling-nans -fno-trapping-math -fcx-limited-range -fsingle-precision-constant $(shell sdl-config --cflags) $(shell pkg-config fftw3f --cflags)
LDFLAGS = -lm -lasound $(shell sdl-config --libs) $(shell pkg-config fftw3f --libs)
all: spectrum
clean:
rm -f spectrum *.o
spectrum: spectrum.o mmap_file.o pcm.o wav.o alsa.o window.o stft.o cqt.o trans.o
Another classic case of "libraries need to come after the objects":
Your libraries, defined by
LDFLAGS = -lm -lasound $(shell sdl-config --libs) $(shell pkg-config fftw3f --libs)
Given that (according to here) the rule for linking is:
$(CC) $(LDFLAGS) n.o $(LOADLIBES) $(LDLIBS)
I would expect that
LDLIBS = -lm -lasound $(shell sdl-config --libs) $(shell pkg-config fftw3f --libs)
would do the trick, although I prefer to actually write my own linker line, as inevitably I end up wanting to know exactly what is linked...
(Unix linkers are rather simplistic in their dealing with libraries, so if you list -lsomething x.o to the linker, the linker will not take anything from -lsomething, and complaim that somethingFunc1(which can be found in libsomething.a) is missing because it wasn't found AFTER x.o.