Guest User

static link into shared lib

a guest
Oct 26th, 2012
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. ----main.cpp
  2. #include <iostream>
  3.  
  4. void doit();
  5.  
  6. int main()
  7. {
  8.         std::cout << "main\n";
  9.         doit();
  10.         return 0;
  11. };
  12.  
  13. -------------------------
  14. ---example.cpp
  15. #include <boost/thread.hpp>
  16.  
  17. void doit()
  18. {
  19.         boost::thread t1;
  20. }
  21. ------------------------
  22. ---build script
  23. g++ -Wall -fPIC -I/usr/include -c example.cpp -o example.o
  24. g++ -shared /usr/lib/libboost_thread.a /usr/lib/libboost_system.a -Wl,-rpath,/usr/lib example.o -o libexample.so
  25.  
  26. g++ -Wall -c main.cpp -o main.o
  27. g++ libexample.so main.o -o main
  28. ---------------------------
  29.  
  30. error message:
  31. libexample.so: undefined reference to `boost::thread::thread()'
  32. libexample.so: undefined reference to `boost::thread::~thread()'
  33. collect2: ld returned 1 exit status
Advertisement
Add Comment
Please, Sign In to add comment