Warning: Newbie Ubuntu/g++ user
I'm trying to build a C++ app (C++11, OpenMP, OpenCV3, experimental filesystem) that works on another platform, but I get linker errors for missing libraries. The names are too generic to find answers via Google.
What do I need to install and/or configure to resolve these, please? I'm using g++ 6.2 on Ubuntu 16.04.1
g++ -g -pthread -m64 -I/usr/include/root -O3 -fprofile-generate \
-march=native -fomit-frame-pointer -std=c++11 -std=c++1y -fopenmp \
-flto -lstdc++fs -DNDEBUG -c -o docproc.o docproc.cpp
/usr/bin/ld: cannot find -lGraf3d
/usr/bin/ld: cannot find -lPostscript
/usr/bin/ld: cannot find -lPhysics
collect2: error: ld returned 1 exit status
Here's my g++ version
$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/6/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 6.2.0-3ubuntu11~16.04' --with-bugurl=file:///usr/share/doc/gcc-6/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-6 --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-6-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-6-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-6-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 6.2.0 20160901 (Ubuntu 6.2.0-3ubuntu11~16.04)
This seems to have been solved in the past by installing:
libroot-*
root-plugin-*
root-system-*
Related
Iam currently struggeling with linking just a simple library.
I compiled and installed successfully the G729 implementation from here Belledonne G729 like this:
cmake . -DCMAKE_INSTALL_PREFIX=/usr
make
make install
When i check the if the symbols exist they exsist:
nm /usr/lib64/libbcg729.so | less
....
0000000000001fb8 T _init
000000000000de40 T initBcg729CNGChannel
00000000000046dd T initBcg729DecoderChannel
000000000000f5c6 T initBcg729DTXChannel
0000000000005353 T initBcg729EncoderChannel
0000000000010107 T initBcg729VADChannel
....
But when i try to compile this simple main.cpp:
#include <bcg729/decoder.h> // for bcg729DecoderChannelContextStruct
int main()
{
bcg729DecoderChannelContextStruct* decoderChannelContext = initBcg729DecoderChannel();
return 0;
}
I get this as result:
c++ -v main.o -o main -lbcg729
Using built-in specs.
COLLECT_GCC=c++
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --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-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC)
COMPILER_PATH=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/:/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/:/usr/libexec/gcc/x86_64-redhat-linux/:/usr/lib/gcc/x86_64-redhat-linux/4.8.5/:/usr/lib/gcc/x86_64-redhat-linux/
LIBRARY_PATH=/usr/lib/gcc/x86_64-redhat-linux/4.8.5/:/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/:/lib/../lib64/:/usr/lib/../lib64/:/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-o' 'main' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/collect2 --build-id --no-add-needed --eh-frame-hdr --hash-style=gnu -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o main /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/crt1.o /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/crti.o /usr/lib/gcc/x86_64-redhat-linux/4.8.5/crtbegin.o -L/usr/lib/gcc/x86_64-redhat-linux/4.8.5 -L/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../.. main.o -lbcg729 -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc/x86_64-redhat-linux/4.8.5/crtend.o /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/crtn.o
main.o: In function `main':
/opt/cppplayground/main.cpp:39: undefined reference to `initBcg729DecoderChannel()'
collect2: error: ld returned 1 exit status
I dont get where the issue is here, since if the library wouldnt be found, the linker would complain it does not exist. But in this case the library exists and the function i want to use does also exists.
Woulbe be nice if anyone could help ;)
Thanks in advance!
Found it ....
Since it's a C-Library i forgot to add the 'extern "C" {}' around the includes.
According to http://en.cppreference.com/w/cpp/utility/tuple/tuple, std::tuple cannot be implicitly constructed before C++17. They even give an example demonstrating it:
std::tuple<int, int> foo_tuple()
{
return {1, -1}; // Error until C++17
return std::make_tuple(1, -1); // Always works
}
Yet, using both gcc 6.2 and clang 3.8.1 I can compile this code cleanly in both C++11 and C++14 mode:
piotrek#piotrek-Inspiron-5423:~/test$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/6/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 6.2.0-5ubuntu12' --with-bugurl=file:///usr/share/doc/gcc-6/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-6 --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 --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 --enable-default-pie --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-6-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-6-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-6-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 6.2.0 20161005 (Ubuntu 6.2.0-5ubuntu12)
piotrek#piotrek-Inspiron-5423:~/test$ clang++ -v
clang version 3.8.1-12ubuntu1 (tags/RELEASE_381/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/i686-linux-gnu/6.2.0
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.1
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/6.2.0
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/6.2.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.4.1
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.2.0
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/6.2.0
Candidate multilib: .;#m64
Selected multilib: .;#m64
piotrek#piotrek-Inspiron-5423:~/test$ cat test.cpp
#include <tuple>
std::tuple<int, int> f()
{
return {1,1};
}
piotrek#piotrek-Inspiron-5423:~/test$ clang++ -Wall -pedantic -fsyntax-only -std=c++14 test.cpp
piotrek#piotrek-Inspiron-5423:~/test$ clang++ -Wall -pedantic -fsyntax-only -std=c++11 test.cpp
piotrek#piotrek-Inspiron-5423:~/test$ g++ -Wall -pedantic -fsyntax-only -std=c++14 test.cpp
piotrek#piotrek-Inspiron-5423:~/test$ g++ -Wall -pedantic -fsyntax-only -std=c++11 test.cpp
piotrek#piotrek-Inspiron-5423:~/test$
What's going on here?
This is LWG 2051, a defect report. Defect reports address mistakes in the published standards. In this case, the defect is resolved in C++17, so strictly speaking, applying it retroactively to standards prior to C++17 is not standard-conforming.
However, compilers have traditionally been applying defect reports to all standard modes. It is reasonable for compilers to fix an official "bug" in C++11 and C++14 IMO. Therefore, this change is made even though it turns ill-formed code into accepted code and even changes the observable behavior of SFINAE tricks.
first of all I've searched this one quite a bit and haven't managed to find a question with the same situation.
I'm building a 32 bit plugin as a shared-object on a 64 bit machine and using cpp-redis. cpp-redis built fine and I used a cmake toolchain to force 32 bit, checked the .o files during build and confirmed they are 32 bit.
I compiled and linked my very basic program (consisting of one main source file and an extra lib for talking to my host application since this is a plugin).
Upon running loading the plugin into the host app, I am greeted with:
symbol lookup error: plugins/samp-redis.so: undefined symbol: _ZN9cpp_redis16redis_subscriberC1ERKSt10shared_ptrINS_7network10io_serviceEE
I'm pretty stumped as I've added the cpp-redis dir to the linker path with -L and the library with -l, here's my comp/link lines:
(SDK_DIR is my host app sdk, pretty small and minimal set of .c/h files)
g++ -fpermissive -fPIC -m32 -std=c++11 -c -O3 -w -D LINUX -I$(SDK_DIR) -I$(SDK_DIR)/amx -I/usr/local/include/cpp_redis (source .cpp files...)
g++ -v -Wall -O2 -m32 -fshort-wchar -s -shared -L/usr/local/lib/ -lcpp_redis -o $(OUTFILE) *.o
Which runs fine with no errors, I ran the link stage with -v to check the flags went in properly and it all looks fine.
(added some newlines for readability)
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.9/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure
-v
--with-pkgversion='Debian 4.9.2-10'
--with-bugurl=file:///usr/share/doc/gcc-4.9/README.Bugs
--enable-languages=c,c++,java,go,d,fortran,objc,obj-c++
--prefix=/usr
--program-suffix=-4.9
--enable-shared
--enable-linker-build-id
--libexecdir=/usr/lib
--without-included-gettext
--enable-threads=posix
--with-gxx-include-dir=/usr/include/c++/4.9
--libdir=/usr/lib
--enable-nls
--with-sysroot=/
--enable-clocale=gnu
--enable-libstdcxx-debug
--enable-libstdcxx-time=yes
--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-4.9-amd64/jre
--enable-java-home
--with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.9-amd64
--with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.9-amd64
--with-arch-directory=amd64
--with-ecj-jar=/usr/share/java/eclipse-ecj.jar
--enable-objc-gc
--enable-multiarch
--with-arch-32=i586
--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 4.9.2 (Debian 4.9.2-10)
COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/4.9/
:/usr/lib/gcc/x86_64-linux-gnu/4.9/
:/usr/lib/gcc/x86_64-linux-gnu/
:/usr/lib/gcc/x86_64-linux-gnu/4.9/
:/usr/lib/gcc/x86_64-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/4.9/32/
:/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../lib32/
:/lib/../lib32/
:/usr/lib/../lib32/
:/usr/lib/gcc/x86_64-linux-gnu/4.9/
:/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../
:/lib/
:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-Wall' '-O2' '-m32' '-fshort-wchar' '-s' '-shared' '-L/usr/local/lib/' '-o' 'samp-redis.so' '-shared-libgcc' '-mtune=generic' '-march=i586'
/usr/lib/gcc/x86_64-linux-gnu/4.9/collect2
-plugin /usr/lib/gcc/x86_64-linux-gnu/4.9/liblto_plugin.so
-plugin-opt=/usr/lib/gcc/x86_64-linux-gnu/4.9/lto-wrapper
-plugin-opt=-fresolution=/tmp/cc0Lo5po.res
-plugin-opt=-pass-through=-lgcc_s
-plugin-opt=-pass-through=-lc
-plugin-opt=-pass-through=-lgcc_s
--sysroot=/
--build-id
--eh-frame-hdr
-m elf_i386
--hash-style=gnu
-shared
-o samp-redis.so
-s /usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../lib32/crti.o /usr/lib/gcc/x86_64-linux-gnu/4.9/32/crtbeginS.o
-L/usr/local/lib/
-L/usr/lib/gcc/x86_64-linux-gnu/4.9/32
-L/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../lib32
-L/lib/../lib32
-L/usr/lib/../lib32
-L/usr/lib/gcc/x86_64-linux-gnu/4.9
-L/usr/lib/gcc/x86_64-linux-gnu/4.9/../../..
-lcpp_redis amxplugin2.o amxplugin.o main.o
-lstdc++
-lm
-lgcc_s
-lc
-lgcc_s /usr/lib/gcc/x86_64-linux-gnu/4.9/32/crtendS.o /usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../lib32/crtn.o
Am I misunderstanding the linking stage or statically linking? It has been a while since I did C++... I'm all about Python and Go these days!
EDIT:
Compiling with -W,--no-undefined results in this output:
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.9/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure
-v
--with-pkgversion='Debian 4.9.2-10'
--with-bugurl=file:///usr/share/doc/gcc-4.9/README.Bugs
--enable-languages=c,c++,java,go,d,fortran,objc,obj-c++
--prefix=/usr
--program-suffix=-4.9
--enable-shared
--enable-linker-build-id
--libexecdir=/usr/lib
--without-included-gettext
--enable-threads=posix
--with-gxx-include-dir=/usr/include/c++/4.9
--libdir=/usr/lib
--enable-nls
--with-sysroot=/
--enable-clocale=gnu
--enable-libstdcxx-debug
--enable-libstdcxx-time=yes
--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-4.9-amd64/jre
--enable-java-home
--with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.9-amd64
--with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.9-amd64
--with-arch-directory=amd64
--with-ecj-jar=/usr/share/java/eclipse-ecj.jar
--enable-objc-gc
--enable-multiarch
--with-arch-32=i586
--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 4.9.2 (Debian 4.9.2-10)
COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/4.9/
:/usr/lib/gcc/x86_64-linux-gnu/4.9/
:/usr/lib/gcc/x86_64-linux-gnu/
:/usr/lib/gcc/x86_64-linux-gnu/4.9/
:/usr/lib/gcc/x86_64-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/4.9/32/
:/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../lib32/
:/lib/../lib32/
:/usr/lib/../lib32/
:/usr/lib/gcc/x86_64-linux-gnu/4.9/
:/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../
:/lib/
:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-Wall' '-O2' '-m32' '-fshort-wchar' '-s' '-shared' '-L/usr/local/lib/' '-o' 'samp-redis.so' '-shared-libgcc' '-mtune=generic' '-march=i586'
/usr/lib/gcc/x86_64-linux-gnu/4.9/collect2
-plugin /usr/lib/gcc/x86_64-linux-gnu/4.9/liblto_plugin.so
-plugin-opt=/usr/lib/gcc/x86_64-linux-gnu/4.9/lto-wrapper
-plugin-opt=-fresolution=/tmp/ccOq8qY8.res
-plugin-opt=-pass-through=-lgcc_s
-plugin-opt=-pass-through=-lc
-plugin-opt=-pass-through=-lgcc_s
--sysroot=/
--build-id
--eh-frame-hdr
-m elf_i386
--hash-style=gnu
-shared
-o samp-redis.so
-s /usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../lib32/crti.o /usr/lib/gcc/x86_64-linux-gnu/4.9/32/crtbeginS.o
-L/usr/local/lib/
-L/usr/lib/gcc/x86_64-linux-gnu/4.9/32
-L/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../lib32
-L/lib/../lib32
-L/usr/lib/../lib32
-L/usr/lib/gcc/x86_64-linux-gnu/4.9
-L/usr/lib/gcc/x86_64-linux-gnu/4.9/../../..
-Bstatic
--no-undefined
-lcpp_redis amxplugin.o amxplugin2.o main.o
-lstdc++
-lm
-lgcc_s
-lc
-lgcc_s /usr/lib/gcc/x86_64-linux-gnu/4.9/32/crtendS.o /usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../lib32/crtn.o
/usr/bin/ld: cannot find
-lgcc_s
/usr/bin/ld: cannot find
-lgcc_s
collect2: error: ld returned 1 exit status
makefile:15: recipe for target 'build' failed
make: *** [build] Error 1
Apparently it can't find gcc_s whatever that is? s=static?
I tried searching for gcc libs:
$ find /usr/ -name libgcc*
/usr/lib/gcc/x86_64-linux-gnu/4.9/libgcc_s.so
/usr/lib/gcc/x86_64-linux-gnu/4.9/libgcc_eh.a
/usr/lib/gcc/x86_64-linux-gnu/4.9/x32/libgcc_s.so
/usr/lib/gcc/x86_64-linux-gnu/4.9/x32/libgcc_eh.a
/usr/lib/gcc/x86_64-linux-gnu/4.9/x32/libgcc.a
/usr/lib/gcc/x86_64-linux-gnu/4.9/libgcc.a
/usr/lib/gcc/x86_64-linux-gnu/4.9/32/libgcc_s.so
/usr/lib/gcc/x86_64-linux-gnu/4.9/32/libgcc_eh.a
/usr/lib/gcc/x86_64-linux-gnu/4.9/32/libgcc.a
/usr/lib/gcc/x86_64-linux-gnu/4.9/libgcc_s_32.so
/usr/lib/gcc/x86_64-linux-gnu/4.9/libgcc_s_x32.so
/usr/lib/gcc/x86_64-linux-gnu/4.8/libgcc_s.so
/usr/lib/gcc/x86_64-linux-gnu/4.8/libgcc_eh.a
/usr/lib/gcc/x86_64-linux-gnu/4.8/libgcc.a
/usr/lib/x86_64-linux-gnu/libgccpp.so.1
/usr/lib/x86_64-linux-gnu/libgccpp.so.1.0.3
Yet doing a ldconfig search shows files named libgcc.so.1:
$ sudo /sbin/ldconfig -p | grep libgcc
libgccpp.so.1 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libgccpp.so.1
libgcc_s.so.1 (libc6,x32) => /usr/libx32/libgcc_s.so.1
libgcc_s.so.1 (libc6,x86-64) => /lib/x86_64-linux-gnu/libgcc_s.so.1
libgcc_s.so.1 (libc6) => /usr/lib32/libgcc_s.so.1
Could this be the reason?
And googling the error brings up some results so I'll keep digging...
Even if you build cpp_redis as static library for it to be linkable with shared library it must be compiled with -fPIC flag ie code must be relocatable. Looks like in your case linker silently ignores incompatible code when linking shared lib. You can check if symbols from cpp_redis resolved into your plugin by running nm with your .so file.
According to your update, you should link your plugin with -W,--no-undefined not cpp_redis. Most probably it will fail as symbols from host program would be missing. But you can check if symbols from cpp_redis are listed as missing or not.
I'm having problems compiling .c and .cpp files using gcc and g++, for both cases i got the message:
g++(or gcc): error trying to exec 'cc1plus': execvp: No such file or directory`
I've already tried to reinstall both gcc and g++ and be sure that they're both in the same version.
Edits: I'm using ubuntu 16.04.1 LTS, both g++ and gcc are in version 5.4.0 20160609.
The following is the output of echo | g++ -v -xc++ -fsyntax-only -:
Using built-in specs.
COLLECT_GCC=g++
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 5.4.0-6ubuntu1~16.04.4' --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.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4)
COLLECT_GCC_OPTIONS='-v' '-fsyntax-only' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
cc1plus -quiet -v -imultiarch x86_64-linux-gnu -iprefix ../lib/gcc/x86_64-linux-gnu/5/ -D_GNU_SOURCE - -quiet -dumpbase - -mtune=generic -march=x86-64 -auxbase - -version -fsyntax-only -o /dev/null -fstack-protector-strong -Wformat -Wformat-security
g++: error trying to exec 'cc1plus': execvp: No such file or directory
Thats the outuput of compiling a hello world program with gcc -v:
Using built-in specs.
COLLECT_GCC=gcc
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 5.4.0-6ubuntu1~16.04.4' --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.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4)
COLLECT_GCC_OPTIONS='-v' '-mtune=generic' '-march=x86-64'
cc1 -quiet -v -imultiarch x86_64-linux-gnu -iprefix ../lib/gcc/x86_64-linux-gnu/5/ codigo.c -quiet -dumpbase codigo.c -mtune=generic -march=x86-64 -auxbase codigo -version -fstack-protector-strong -Wformat -Wformat-security -o /tmp/cckVKe9E.s
gcc: error trying to exec 'cc1': execvp: No such file or directory
The following is the output of /usr/lib/gcc/x86_64-linux-gnu/5/cc1plus </dev/null:
Analyzing compilation unit
Performing interprocedural optimizations
<*free_lang_data> <visibility> <build_ssa_passes> <opt_local_passes> <free-inline-summary> <whole-program> <inline>Assembling functions:
Execution times (seconds)
phase setup : 0.00 ( 0%) usr 0.00 ( 0%) sys 0.01 (20%) wall 1408 kB (81%) ggc
phase parsing : 0.00 ( 0%) usr 0.00 ( 0%) sys 0.01 (20%) wall 318 kB (18%) ggc
parser (global) : 0.00 ( 0%) usr 0.00 ( 0%) sys 0.01 (20%) wall 302 kB (17%) ggc
TOTAL : 0.00 0.00 0.05 1746 kB
Something has been broken in your GCC installation (read also about GCC environment variables & spec files).
Check also your environment, be sure to avoid any GCC_EXEC_PREFIX environment variables
I would suggest to re-install with aptitude:
aptitude reinstall gcc-5 g++-5
(perhaps you need to replace both occurrences of 5 by 6, at least on newer versions of Ubuntu)
Then compile some hello world program with gcc -v to be sure it is working.
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.