Compilation error after including <map> - c++

I just started with C++, trying to learn some basics. Right now compiling using gcc version 5.2.1 in Eclipse, project is compiled with c++11 parameter.
Now the include problem occurs when I try to #include <map> (it doesn't really matter where as long as compiler gets into it, I don't even use map yet, just trying to include it). As far as I can understand there's a problem with map itself, but it doesn't seem right. Short failure snippet here.
08:54:59 **** Incremental Build of configuration Debug for project RpnCalculator ****
make all
Building file: ../Test/AddShouldBeRegistered.cpp
Invoking: Cross G++ Compiler
g++ -I/home/yoger/Coding/cpputest/include -O0 -g3 -Wall -c -fmessage- length=0 -std=c++11 -v -MMD -MP -MF"Test/AddShouldBeRegistered.d" -MT"Test/AddShouldBeRegistered.d" -o "Test/AddShouldBeRegistered.o" "../Test/AddShouldBeRegistered.cpp"
Using built-in specs.
COLLECT_GCC=g++
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 5.2.1-22ubuntu2' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-5 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 5.2.1 20151010 (Ubuntu 5.2.1-22ubuntu2)
COLLECT_GCC_OPTIONS='-I' '/home/yoger/Coding/cpputest/include' '-O0' '-g3' '-Wall' '-c' '-fmessage-length=0' '-std=c++11' '-v' '-MMD' '-MP' '-MF' 'Test/AddShouldBeRegistered.d' '-MT' 'Test/AddShouldBeRegistered.d' '-o' 'Test/AddShouldBeRegistered.o' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
/usr/lib/gcc/x86_64-linux-gnu/5/cc1plus -quiet -v -I /home/yoger/Coding/cpputest/include -imultiarch x86_64-linux-gnu -MMD Test/AddShouldBeRegistered.d -MF Test/AddShouldBeRegistered.d -MP -MT Test/AddShouldBeRegistered.d -dD -D_GNU_SOURCE ../Test/AddShouldBeRegistered.cpp -quiet -dumpbase AddShouldBeRegistered.cpp -mtune=generic -march=x86-64 -auxbase-strip Test/AddShouldBeRegistered.o -g3 -O0 -Wall -std=c++11 -version -fmessage-length=0 -fstack-protector-strong -Wformat-security -o /tmp/cc8xNfBA.s
GNU C++11 (Ubuntu 5.2.1-22ubuntu2) version 5.2.1 20151010 (x86_64-linux-gnu)
compiled by GNU C version 5.2.1 20151010, GMP version 6.0.0, MPFR version 3.1.3, MPC version 1.0.3
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring duplicate directory "/usr/include/x86_64-linux-gnu/c++/5"
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/5/../../../../x86_64-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
/home/yoger/Coding/cpputest/include
/usr/include/c++/5
/usr/include/x86_64-linux-gnu/c++/5
/usr/include/c++/5/backward
/usr/lib/gcc/x86_64-linux-gnu/5/include
/usr/local/include
/usr/lib/gcc/x86_64-linux-gnu/5/include-fixed
/usr/include/x86_64-linux-gnu
/usr/include
End of search list.
GNU C++11 (Ubuntu 5.2.1-22ubuntu2) version 5.2.1 20151010 (x86_64-linux-gnu)
compiled by GNU C version 5.2.1 20151010, GMP version 6.0.0, MPFR version 3.1.3, MPC version 1.0.3
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 5ed623d6fe11f4bcc1afee70f77e33b0
In file included from /usr/include/c++/5/map:60:0,
from ../Test/../MathOperations/MathOperationFactory.h:11,
from ../Test/ShouldBeRegistered.h:13,
from ../Test/AddShouldBeRegistered.cpp:9:
/usr/include/c++/5/bits/stl_tree.h: In member function ‘void std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_construct_node(std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Link_type, _Args&& ...)’:
/usr/include/c++/5/bits/stl_tree.h:528:14: error: ‘__node’ does not name a type
::new(__node) _Rb_tree_node<_Val>;
^
Test/subdir.mk:66: recipe for target 'Test/AddShouldBeRegistered.o' failed
make: *** [Test/AddShouldBeRegistered.o] Error 1
08:54:59 Build Finished (took 361ms)
Alright, the file where I include map
#ifndef MATHOPERATIONFACTORY_H_
#define MATHOPERATIONFACTORY_H_
#include <map>
#include <string>
class MathOperation;
class MathOperationFactory {
public:
MathOperationFactory();
virtual ~MathOperationFactory();
virtual MathOperation& findOperationNamed(const std::string &name);
private:
typedef std::map<std::string, MathOperation*> OperationMap;
typedef OperationMap::iterator iterator;
OperationMap _operationsByName;
};
#endif

It's a problem related with memory leak detection feature of Cpputest. You can apply one of the solutions described in documentation page of Cpputest.
http://cpputest.github.io/manual.html#memory_leak_detection

I am able to avoid this issue by making sure that <map> is included before any CppUTest related includes.
example:
class1.h:
#include <map>
.
.
//your code for class 1 business logic
class1_test.cpp:
#include "class1.h"
//other include
#include <CppUTest/TestHarness.h> // at very end
Follow this rule in places wherever you are going to include CppUtest header

So I didn't find exact answer but managed to completely fix the issue by simply moving all project files to new project.
That means that problem was somehow related to project settings, I compared compiler settings for both projects, they were the same so the reason is still covered with very fine layer of diamond hard mist.

Related

/usr/include/c++/8/cstdlib:75:15: fatal error: stdlib.h: No such file or directory

I'm a beginner in linux and when I was running my first program "HELLOWORLD" on my raspberry pi this warning appeared:
pi#raspberrypi:~/raspitest $ g++ test.cpp -o test
In file included from /usr/include/c++/8/ext/string_conversions.h:41,
from /usr/include/c++/8/bits/basic_string.h:6400,
from /usr/include/c++/8/string:52,
from /usr/include/c++/8/bits/locale_classes.h:40,
from /usr/include/c++/8/bits/ios_base.h:41,
from /usr/include/c++/8/ios:42,
from /usr/include/c++/8/ostream:38,
from /usr/include/c++/8/iostream:39,
from test.cpp:1:
/usr/include/c++/8/cstdlib:75:15: fatal error: stdlib.h: No No such file or directory
#include_next <stdlib.h>
^~~~~~~~~~
compilation terminated.
I was not using any make tools, just wrote the code via vim and ran the following command:
pi#raspberrypi:~/raspitest $ g++ test.cpp -o test
The stdlib.h should have been in the right path:
pi#raspberrypi:~/raspitest $ locate stdlib.h
/opt/Wolfram/WolframEngine/12.1/SystemFiles/Links/ArduinoLink/Resources/CSource/avr-libc/1.8.1/avr/include/stdlib.h
/usr/include/stdlib.h
/usr/include/arm-linux-gnueabihf/bits/stdlib.h
/usr/include/c++/8/stdlib.h
/usr/include/c++/8/tr1/stdlib.h
/usr/include/freetype2/freetype/config/ftstdlib.h
here are my original code:
#include<iostream>
#include<stdlib.h>
using namespace std;
int main()
{
cout <<"hello,world" << endl;
return 0;
}
and here is the output of g++ -v test.cpp:
pi#raspberrypi:~/raspitest $ g++ -v test.cpp
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/arm-linux-gnueabihf/8/lto-wrapper
Target: arm-linux-gnueabihf
Configured with: ../src/configure -v --with-pkgversion='Raspbian 8.3.0-6+rpi1' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-8 --program-prefix=arm-linux-gnueabihf- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libitm --disable-libquadmath --disable-libquadmath-support --enable-plugin --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-sjlj-exceptions --with-arch=armv6 --with-fpu=vfp --with-float=hard --disable-werror --enable-checking=release --build=arm-linux-gnueabihf --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf
Thread model: posix
gcc version 8.3.0 (Raspbian 8.3.0-6+rpi1)
COLLECT_GCC_OPTIONS='-v' '-shared-libgcc' '-mfloat-abi=hard' '-mfpu=vfp' '-mtls-dialect=gnu' '-marm' '-march=armv6+fp'
/usr/lib/gcc/arm-linux-gnueabihf/8/cc1plus -quiet -v -imultilib . -imultiarch arm-linux-gnueabihf -D_GNU_SOURCE test.cpp -quiet -dumpbase test.cpp -mfloat-abi=hard -mfpu=vfp -mtls-dialect=gnu -marm -march=armv6+fp -auxbase test -version -o /tmp/cchrh8l9.s
GNU C++14 (Raspbian 8.3.0-6+rpi1) version 8.3.0 (arm-linux-gnueabihf)
compiled by GNU C version 8.3.0, GMP version 6.1.2, MPFR version 4.0.2, MPC version 1.1.0, isl version isl-0.20-GMP
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring duplicate directory "/usr/include/arm-linux-gnueabihf/c++/8"
ignoring nonexistent directory "/usr/local/include/arm-linux-gnueabihf"
ignoring nonexistent directory "/usr/lib/gcc/arm-linux-gnueabihf/8/../../../../arm-linux-gnueabihf/include"
ignoring duplicate directory "/usr/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/include
/usr/include/c++/8
/usr/include/arm-linux-gnueabihf/c++/8
/usr/include/c++/8/backward
/usr/lib/gcc/arm-linux-gnueabihf/8/include
/usr/local/include
/usr/lib/gcc/arm-linux-gnueabihf/8/include-fixed
/usr/include/arm-linux-gnueabihf
End of search list.
GNU C++14 (Raspbian 8.3.0-6+rpi1) version 8.3.0 (arm-linux-gnueabihf)
compiled by GNU C version 8.3.0, GMP version 6.1.2, MPFR version 4.0.2, MPC version 1.1.0, isl version isl-0.20-GMP
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 7defdc925cf5fede452fc531d54623d1
In file included from /usr/include/c++/8/ext/string_conversions.h:41,
from /usr/include/c++/8/bits/basic_string.h:6400,
from /usr/include/c++/8/string:52,
from /usr/include/c++/8/bits/locale_classes.h:40,
from /usr/include/c++/8/bits/ios_base.h:41,
from /usr/include/c++/8/ios:42,
from /usr/include/c++/8/ostream:38,
from /usr/include/c++/8/iostream:39,
from test.cpp:1:
/usr/include/c++/8/cstdlib:75:15: fatal error: stdlib.h: 没有那个文件或目录
#include_next <stdlib.h>
^~~~~~~~~~
compilation terminated.
Thanks for the hints from the comments. Here is my soloution:
add
export CPLUS_INCLUDE_PATH=/usr/include/c++/8:$CPLUS_INCLUDE_PATH
to ~/.bashrcfile. If still not working, try to reboot or copy all the headfiles to a new folder and change the cplus_path again.

Why does g++ require libstdc++.a? Why is it not the default?

I had this problem, and the solution was to explicitly pass libstdc++.a to g++, like the following:
/usr/local/gcc-10.2.0/bin/g++ -I/usr/local/gcc-10.2.0/include -L/usr/local/gcc-10.2.0/lib64 -Wl,-rpath,/usr/local/gcc-10.2.0/lib64 b.cpp /usr/local/gcc-10.2.0/lib64/libstdc++.a
My question: Why do I need to explicitly pass libstdc++.a? How can I make it automatic so that libstdc++.a is used by default? How can I find the answer to the two questions?
The test code:
#include <sstream>
using namespace std;
int
main ()
{
ostringstream oss;
unsigned long k = 5;
oss << k;
}
Compiled with the following parameters:
/usr/local/gcc-10.2.0/bin/g++ -I/usr/local/gcc-10.2.0/include -L/usr/local/gcc-10.2.0/lib64 -Wl,-rpath,/usr/local/gcc-10.2.0/lib64 -lstdc++ b.cpp
Got the following output:
/tmp/cclRSXGV.o: In function main': b.cpp:(.text+0x35): undefined reference to std::ostream::operator<<(unsigned long)'
collect2: error: ld returned 1 exit status
Using GNU gcc 10.2.0, installed with the following:
../gcc-10.2.0/configure --prefix=/usr/local/gcc-10.2.0 --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-languages=c,c++ --disable-dssi --enable-libgcj-multifile --with-ppl --with-cloog --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux && make install-strip
Already had GNU gcc 4.4.7 installed by default at /usr, and GNU gcc 9.2.0 at /usr/local/gcc-9.2.0
Running /usr/local/gcc-10.2.0/bin/g++ -v b.cpp produces the following:
Using built-in specs.
COLLECT_GCC=/usr/local/gcc-10.2.0/bin/g++
COLLECT_LTO_WRAPPER=/usr/local/gcc-10.2.0/libexec/gcc/x86_64-redhat-linux/10.2.0/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../gcc-10.2.0/configure --prefix=/usr/local/gcc-10.2.0 --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-languages=c,c++ --disable-dssi --enable-libgcj-multifile --with-ppl --with-cloog --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 10.2.0 (GCC)
COLLECT_GCC_OPTIONS='-v' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
/usr/local/gcc-10.2.0/libexec/gcc/x86_64-redhat-linux/10.2.0/cc1plus -quiet -v -D_GNU_SOURCE b.cpp -quiet -dumpbase b.cpp -mtune=generic -march=x86-64 -auxbase b -version -o /tmp/ccJiMH6j.s
GNU C++14 (GCC) version 10.2.0 (x86_64-redhat-linux)
compiled by GNU C version 10.2.0, GMP version 6.1.0, MPFR version 3.1.4, MPC version 1.0.3, isl version isl-0.18-GMP
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/local/gcc-10.2.0/lib/gcc/x86_64-redhat-linux/10.2.0/../../../../x86_64-redhat-linux/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/gcc-10.2.0/lib/gcc/x86_64-redhat-linux/10.2.0/../../../../include/c++/10.2.0
/usr/local/gcc-10.2.0/lib/gcc/x86_64-redhat-linux/10.2.0/../../../../include/c++/10.2.0/x86_64-redhat-linux
/usr/local/gcc-10.2.0/lib/gcc/x86_64-redhat-linux/10.2.0/../../../../include/c++/10.2.0/backward
/usr/local/gcc-10.2.0/lib/gcc/x86_64-redhat-linux/10.2.0/include
/usr/local/include
/usr/local/gcc-10.2.0/include
/usr/local/gcc-10.2.0/lib/gcc/x86_64-redhat-linux/10.2.0/include-fixed
/usr/include
End of search list.
GNU C++14 (GCC) version 10.2.0 (x86_64-redhat-linux)
compiled by GNU C version 10.2.0, GMP version 6.1.0, MPFR version 3.1.4, MPC version 1.0.3, isl version isl-0.18-GMP
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 410dfe626634fcd13dbcedee05209c5e
COLLECT_GCC_OPTIONS='-v' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
as -v --64 -o /tmp/ccUyoUr2.o /tmp/ccJiMH6j.s
GNU assembler version 2.35 (x86_64-pc-linux-gnu) using BFD version (GNU Binutils) 2.35
COMPILER_PATH=/usr/local/gcc-10.2.0/libexec/gcc/x86_64-redhat-linux/10.2.0/:/usr/local/gcc-10.2.0/libexec/gcc/x86_64-redhat-linux/10.2.0/:/usr/local/gcc-10.2.0/libexec/gcc/x86_64-redhat-linux/:/usr/local/gcc-10.2.0/lib/gcc/x86_64-redhat-linux/10.2.0/:/usr/local/gcc-10.2.0/lib/gcc/x86_64-redhat-linux/
LIBRARY_PATH=/usr/local/gcc-10.2.0/lib/gcc/x86_64-redhat-linux/10.2.0/:/usr/local/gcc-10.2.0/lib/gcc/x86_64-redhat-linux/10.2.0/../../../../lib64/:/lib/../lib64/:/usr/lib/../lib64/:/usr/local/gcc-10.2.0/lib/gcc/x86_64-redhat-linux/10.2.0/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
/usr/local/gcc-10.2.0/libexec/gcc/x86_64-redhat-linux/10.2.0/collect2 -plugin /usr/local/gcc-10.2.0/libexec/gcc/x86_64-redhat-linux/10.2.0/liblto_plugin.so -plugin-opt=/usr/local/gcc-10.2.0/libexec/gcc/x86_64-redhat-linux/10.2.0/lto-wrapper -plugin-opt=-fresolution=/tmp/ccfGN6NK.res -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 /usr/lib/../lib64/crt1.o /usr/lib/../lib64/crti.o /usr/local/gcc-10.2.0/lib/gcc/x86_64-redhat-linux/10.2.0/crtbegin.o -L/usr/local/gcc-10.2.0/lib/gcc/x86_64-redhat-linux/10.2.0 -L/usr/local/gcc-10.2.0/lib/gcc/x86_64-redhat-linux/10.2.0/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/local/gcc-10.2.0/lib/gcc/x86_64-redhat-linux/10.2.0/../../.. /tmp/ccUyoUr2.o -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/local/gcc-10.2.0/lib/gcc/x86_64-redhat-linux/10.2.0/crtend.o /usr/lib/../lib64/crtn.o
/usr/local/bin/ld: /tmp/ccUyoUr2.o: in function `main':
b.cpp:(.text+0xc9): undefined reference to `std::cout'
/usr/local/bin/ld: b.cpp:(.text+0x35): undefined reference to std::ostream::operator<<(unsigned long)'
collect2: error: ld returned 1 exit status
By default g++ links against the dynamic libstdc++ library (libstdc++.so). By passing libstdc++.a explicitly you're linking against the static counterpart. You could achieve the same end result with -static-libstdc++.
Both static and dynamic linking against libstdc++ should work. Your issue could be possibly caused by building or installing GCC incorrectly (e.g. applying an incorrect patch, or mixing include files from different GCC builds).
To investigate, produce object file b.o by adding -c to your g++ command line, and preprocessed source b.ii by adding -E -o b.ii. Use nm -u b.o to get mangled names of undefined symbols (add -C to demangle). You'll see that mangled name of the missing symbol is _ZNSolsEm. Try to grep the missing symbol in the list of symbols defined by libstdc++ (nm -D --defined-only /usr/local/gcc-10.2.0/lib64/libstdc++.so). If it is missing from the library, the issue is that the included files expect the library to provide those template instantiations, while the actual library does not.
If you look in b.ii, you'll find that it declares the corresponding extern template towards the end:
extern template class basic_ostringstream<char>;
If you look into sstream.tcc file from gcc install tree that this line comes from, you'll see it's guarded by #if _GLIBCXX_EXTERN_TEMPLATE. The definition of this macro is in c++config.h, and is set depending on --enable-extern-template option at libstdc++ configuration time. If the library is built with --disable-extern-template, it will not provide those template instantiations.

Linking error in test program with RTP (Real-Time Transport Protocol) [duplicate]

This question already has answers here:
What is an undefined reference/unresolved external symbol error and how do I fix it?
(39 answers)
Closed 2 years ago.
I am trying to compile a simple test program using rtp (Real-Time Transport Protocol). Unfortunately I get a linking error I can not get rid off. Here is the Code i try to compile with:
g++ -v main.cpp -o rtp -lccrtp
Here is the main.cpp
#include <ccrtp/rtp.h>
int main(int argc, char *argv[])
{
ost::RTPSession s(ost::InetHostAddress("127.0.0.1"),9000); // bind reception socket.
return 0;
}
and the output:
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 8.3.0-6' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-8 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 8.3.0 (Debian 8.3.0-6)
COLLECT_GCC_OPTIONS='-v' '-o' 'rtp' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
/usr/lib/gcc/x86_64-linux-gnu/8/cc1plus -quiet -v -imultiarch x86_64-linux-gnu -D_GNU_SOURCE main.cpp -quiet -dumpbase main.cpp -mtune=generic -march=x86-64 -auxbase main -version -o /tmp/ccMnYiXi.s
GNU C++14 (Debian 8.3.0-6) version 8.3.0 (x86_64-linux-gnu)
compiled by GNU C version 8.3.0, GMP version 6.1.2, MPFR version 4.0.2, MPC version 1.1.0, isl version isl-0.20-GMP
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring duplicate directory "/usr/include/x86_64-linux-gnu/c++/8"
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/8/../../../../x86_64-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/include/c++/8
/usr/include/x86_64-linux-gnu/c++/8
/usr/include/c++/8/backward
/usr/lib/gcc/x86_64-linux-gnu/8/include
/usr/local/include
/usr/lib/gcc/x86_64-linux-gnu/8/include-fixed
/usr/include/x86_64-linux-gnu
/usr/include
End of search list.
GNU C++14 (Debian 8.3.0-6) version 8.3.0 (x86_64-linux-gnu)
compiled by GNU C version 8.3.0, GMP version 6.1.2, MPFR version 4.0.2, MPC version 1.1.0, isl version isl-0.20-GMP
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 3c854693d01dc9a844a56a0b1ab1c0f4
COLLECT_GCC_OPTIONS='-v' '-o' 'rtp' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
as -v --64 -o /tmp/ccBl5GBx.o /tmp/ccMnYiXi.s
GNU assembler version 2.31.1 (x86_64-linux-gnu) using BFD version (GNU Binutils for Debian) 2.31.1
COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/8/:/usr/lib/gcc/x86_64-linux-gnu/8/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/8/:/usr/lib/gcc/x86_64-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/8/:/usr/lib/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/8/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/8/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-o' 'rtp' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
/usr/lib/gcc/x86_64-linux-gnu/8/collect2 -plugin /usr/lib/gcc/x86_64-linux-gnu/8/liblto_plugin.so -plugin-opt=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper -plugin-opt=-fresolution=/tmp/cc36T3hM.res -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc --build-id --eh-frame-hdr -m elf_x86_64 --hash-style=gnu -dynamic-linker /lib64/ld-linux-x86-64.so.2 -pie -o rtp /usr/lib/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu/Scrt1.o /usr/lib/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/8/crtbeginS.o -L/usr/lib/gcc/x86_64-linux-gnu/8 -L/usr/lib/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/8/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/8/../../.. /tmp/ccBl5GBx.o -lccrtp -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc/x86_64-linux-gnu/8/crtendS.o /usr/lib/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu/crtn.o
/usr/bin/ld: /tmp/ccBl5GBx.o: undefined reference to symbol '_ZNK7ucommon14JoinableThread9is_activeEv'
/usr/bin/ld: //lib/x86_64-linux-gnu/libucommon.so.8: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
Thanks for the help.
Thanks for the fast reply. That directed me to the solution. I also needed to install
libcommoncpp2-dev
and now it compiles with:
g++ -lccrtp -lucommon -lcommoncpp -o rtp main.cpp
without any errors. Thanks again.

g++ compilation undefined references on external hpp file

I am trying to include pugixml.hpp in my code using the following include notation :
#include "pugixml-1.7/src/pugixml.hpp"
Now the weird thing is, this runs in Codeblocks fine, but when I am trying to run it via terminal (I have all the source codes in one single file) using g++ :
g++-5 -v -std=c++11 -03 -Wall -pedantic -fopenmp -pthread main.cpp -o main.o
It throws out a bunch of undefined reference to pugi::xml.. (whichever the api I was using). I have tried everything, by keeping the pugixml.hpp file in the main directory, by adding bunch of flags like -iquote or -c to point to that directory.. but nothing is working. What else I should try? I am including the output till directory search here :
Using built-in specs.
COLLECT_GCC=g++-5
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 5.2.1-23ubuntu1~12.04' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-5 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=gcc4-compatible --disable-libstdcxx-dual-abi --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 5.2.1 20151031 (Ubuntu 5.2.1-23ubuntu1~12.04)
COLLECT_GCC_OPTIONS='-v' '-std=c++11' '-O3' '-Wall' '-Wpedantic' '-fopenmp' '-pthread' '-o' 'main.o' '-shared-libgcc' '-mtune=generic' '-march=x86-64' '-pthread'
/usr/lib/gcc/x86_64-linux-gnu/5/cc1plus -quiet -v -imultiarch x86_64-linux-gnu -D_GNU_SOURCE -D_REENTRANT main.cpp -quiet -dumpbase main.cpp -mtune=generic -march=x86-64 -auxbase main -O3 -Wall -Wpedantic -std=c++11 -version -fopenmp -fstack-protector -Wformat-security -o /tmp/ccXfMWIT.s
GNU C++11 (Ubuntu 5.2.1-23ubuntu1~12.04) version 5.2.1 20151031 (x86_64-linux-gnu)
compiled by GNU C version 5.2.1 20151031, GMP version 5.0.2, MPFR version 3.1.0-p3, MPC version 0.9
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring duplicate directory "/usr/include/x86_64-linux-gnu/c++/5"
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/5/../../../../x86_64-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/include/c++/5
/usr/include/x86_64-linux-gnu/c++/5
/usr/include/c++/5/backward
/usr/lib/gcc/x86_64-linux-gnu/5/include
/usr/local/include
/usr/lib/gcc/x86_64-linux-gnu/5/include-fixed
/usr/include/x86_64-linux-gnu
/usr/include
End of search list.
You need to link against the compiled pugixml library. Including the pugixml.hpp is simply telling the preprocessor to get the interface, however the compiler (more specifically the linker) needs to find the appropriate compiled pugixml code for it to be usable from your source code.

unable to link Intel TBB library with libtbb in /usr/lib

I downloaded the pre built headers and libraries for Intel TBB from Intel's TBB website. I updated ldconfig to add the tbb shared library to /usr/lib. However on compiling with -tbb the code using g++ ld returns -1 as it is unable to find libtbb
libtbb.so.2 is present in /usr/lib/
here is my full g++ output
g++ hellotbb.cpp -o htbb -I$HOME/libs/tbb43/include -v -ltbb
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.8/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.8.2-19ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.8 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.8 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-libmudflap --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.8.2 (Ubuntu 4.8.2-19ubuntu1)
COLLECT_GCC_OPTIONS='-o' 'htbb' '-I' '/home/govind/libs/tbb43/include' '-v' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
/usr/lib/gcc/x86_64-linux-gnu/4.8/cc1plus -quiet -v -I /home/govind/libs/tbb43/include -imultiarch x86_64-linux-gnu -D_GNU_SOURCE hellotbb.cpp -quiet -dumpbase hellotbb.cpp -mtune=generic -march=x86-64 -auxbase hellotbb -version -fstack-protector -Wformat -Wformat-security -o /tmp/ccnjmEt3.s
GNU C++ (Ubuntu 4.8.2-19ubuntu1) version 4.8.2 (x86_64-linux-gnu)
compiled by GNU C version 4.8.2, GMP version 5.1.3, MPFR version 3.1.2-p3, MPC version 1.0.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring duplicate directory "/usr/include/x86_64-linux-gnu/c++/4.8"
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../x86_64-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
/home/govind/libs/tbb43/include
/usr/include/c++/4.8
/usr/include/x86_64-linux-gnu/c++/4.8
/usr/include/c++/4.8/backward
/usr/lib/gcc/x86_64-linux-gnu/4.8/include
/usr/local/include
/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed
/usr/include/x86_64-linux-gnu
/usr/include
End of search list.
GNU C++ (Ubuntu 4.8.2-19ubuntu1) version 4.8.2 (x86_64-linux-gnu)
compiled by GNU C version 4.8.2, GMP version 5.1.3, MPFR version 3.1.2-p3, MPC version 1.0.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 26a7c0bd346d04102f6aea776e0cccc5
COLLECT_GCC_OPTIONS='-o' 'htbb' '-I' '/home/govind/libs/tbb43/include' '-v' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
as -v -I /home/govind/libs/tbb43/include --64 -o /tmp/ccC9Xpee.o /tmp/ccnjmEt3.s
GNU assembler version 2.24 (x86_64-linux-gnu) using BFD version (GNU Binutils for Ubuntu) 2.24
COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/4.8/:/usr/lib/gcc/x86_64-linux-gnu/4.8/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/4.8/:/usr/lib/gcc/x86_64-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/4.8/:/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-o' 'htbb' '-I' '/home/govind/libs/tbb43/include' '-v' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
/usr/lib/gcc/x86_64-linux-gnu/4.8/collect2 --sysroot=/ --build-id --eh-frame-hdr -m elf_x86_64 --hash-style=gnu --as-needed -dynamic-linker /lib64/ld-linux-x86-64.so.2 -z relro -o htbb /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crt1.o /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/4.8/crtbegin.o -L/usr/lib/gcc/x86_64-linux-gnu/4.8 -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../.. /tmp/ccC9Xpee.o -ltbb -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc/x86_64-linux-gnu/4.8/crtend.o /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crtn.o
/usr/bin/ld: cannot find -ltbb
collect2: error: ld returned 1 exit status
It seems that ld does not detect my tbb library in /usr/lib/
Make sure libtbb.so is also present and install libtbb-dev package if needed:
apt-get install libtbb-dev
BTW, your include files are located in suspicious place. Looks like you mixed installation of TBB binaries and include files from different sources. It can lead to bad problems especially if headers are newer than binaries.