Boost, Os X, Linker question

Hi.
I have a question about compile programm with more what one source files.

SRC/
main.cpp
server.hpp
server.cpp


If i compile this in one line

c++ -I/Developer/boost_1_57_0 -std=c++0x -stdlib=libc++ main.cpp server.cpp -o mainex -L /Developer/boost_current/lib/ -lboost_system -lboost_regex -lpthread

Compile done and app work.

If i do like

c++ -c -I/Developer/boost_1_57_0 -std=c++0x -stdlib=libc++ main.cpp -o main.o
c++ -c -I/Developer/boost_1_57_0 -std=c++0x -stdlib=libc++ server.cpp -o server.o
c++ main.o server.o -o progexe -lstdc++ -lpthread -L/Developer/boost_current/lib/ -lboost_regex -lboost_system

i get errors

Undefined symbols for architecture x86_64:
  "std::__1::__shared_weak_count::__get_deleter(std::type_info const&) const", referenced from:
      vtable for std::__1::__shared_ptr_emplace<session, std::__1::allocator<session> > in server.o
  "std::__1::locale::use_facet(std::__1::locale::id&) const", referenced from:
      std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::operator<<<std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*) in main.o
      std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::operator<<<std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*) in server.o
  "std::__1::ios_base::getloc() const", referenced from:
      std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::operator<<<std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*) in main.o
      std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::operator<<<std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*) in server.o
  "std::runtime_error::runtime_error(char const*)", referenced from:
      boost::system::system_error::system_error(boost::system::error_code, char const*) in main.o
      boost::system::system_error::system_error(boost::system::error_code) in main.o
      boost::system::system_error::system_error(boost::system::error_code, char const*) in server.o
      boost::system::system_error::system_error(boost::system::error_code) in server.o
  "std::runtime_error::runtime_error(std::runtime_error const&)", referenced from:
      boost::system::system_error::system_error(boost::system::system_error const&) in main.o
      boost::system::system_error::system_error(boost::system::system_error const&) in server.o
  "std::__1::bad_weak_ptr::~bad_weak_ptr()", referenced from:
....
....
....
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)



c++ -v

Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin12.6.0
Thread model: posix
Last edited on
Topic archived. No new replies allowed.