My application uses my shared library. The application and library should be mudflapped to check the read and write boundaries both on the stack and on the heap. The shared library was successfully created, but I had a lot of errors when linking the application.
I made a simple example that reproduces this problem. Here are the steps to play:
- create a C ++ dynamic shared library project with two files: h and cpp files with some class, and in the h or cpp file use
#include <iostream> - create a C ++ application that uses this library (uses a class from a shared library)
- build a library
- build an application (here you will catch a communication error)
Here are my files:
SharedLibTest.h
#ifndef SHAREDLIBTEST_H_ #define SHAREDLIBTEST_H_ #include <iostream> class SharedLibTest { public: void func(); }; #endif
SharedLibTest.cpp
#include "SharedLibTest.h" void SharedLibTest::func() {}
main.cpp
#include <SharedLibTest.h> int main(int argc, char *argv[]) { SharedLibTest obj; obj.func(); return 0; }
Building a library:
g++ -O0 -g3 -Wall -c -fmessage-length=0 -fmudflap -funwind-tables -fPIC -MMD -MP -MF"SharedLibTest.d" -MT"SharedLibTest.d" -o "SharedLibTest.o" "../SharedLibTest.cpp" g++ -rdynamic -shared -o "libshared_lib.so" ./SharedLibTest.o -lmudflap
Application Building:
g++ -I"/home/msviridov/work/prj/workspace/shared_lib" -O0 -g3 -Wall -c -fmessage-length=0 -fmudflap -funwind-tables -MMD -MP -MF"main.d" -MT"main.d" -o "main.o" "../main.cpp" g++ -L"/home/msviridov/work/prj/workspace/shared_lib/Debug" -rdynamic -v -o "executable" ./main.o -lshared_lib -lmudflap
Linker Error Output:
/home/msviridov/work/prj/workspace/shared_lib/Debug/libshared_lib.so: undefined reference to `__gnu_cxx::__numeric_traits_integer<unsigned long>::__digits' /home/msviridov/work/prj/workspace/shared_lib/Debug/libshared_lib.so: undefined reference to `__gnu_cxx::__numeric_traits_integer<long>::__min' /home/msviridov/work/prj/workspace/shared_lib/Debug/libshared_lib.so: undefined reference to `__gnu_cxx::__numeric_traits_integer<short>::__min' /home/msviridov/work/prj/workspace/shared_lib/Debug/libshared_lib.so: undefined reference to `__gnu_cxx::__numeric_traits_integer<char>::__max' /home/msviridov/work/prj/workspace/shared_lib/Debug/libshared_lib.so: undefined reference to `__gnu_cxx::__numeric_traits_integer<short>::__max' /home/msviridov/work/prj/workspace/shared_lib/Debug/libshared_lib.so: undefined reference to `__gnu_cxx::__numeric_traits_integer<long>::__max' /home/msviridov/work/prj/workspace/shared_lib/Debug/libshared_lib.so: undefined reference to `__gnu_cxx::__numeric_traits_integer<int>::__max' /home/msviridov/work/prj/workspace/shared_lib/Debug/libshared_lib.so: undefined reference to `__gnu_cxx::__numeric_traits_integer<int>::__min' collect2: ld returned 1 exit status make: *** [executable] Error 1
Although, if I remove the mudflap compiler and linker flags for the library, building the application will succeed. But this is not the case for the opposite.
I do not understand what leads to this result. My platform is Linux Mint 13 Maya 64 bit. I would appreciate any help. Thanks.
source share