Closed dongshimou closed 5 years ago
请用master分支。
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: /usr/local/lib/liblibgo.a(epoll_reactor.cpp.o) has no symbols 这个错误可以无视
你说的“找不到引用的错”可以贴出来看看吗
~/C/test1> g++ -std=c++1z main.cpp -llibgo -pthread -ldl
Undefined symbols for architecture x86_64:
"co::Scheduler::CreateTask(std::function<void ()> const&, co::TaskOpt const&)", referenced from:
_main in ccIMFdbE.o
"std::__1::__vector_base_common<true>::__throw_length_error() const", referenced from:
void std::__1::vector<co::Anys<co::TaskGroupKey>::KeyInfo, std::__1::allocator<co::Anys<co::TaskGroupKey>::KeyInfo> >::__push_back_slow_path<co::Anys<co::TaskGroupKey>::KeyInfo const&>(co::Anys<co::TaskGroupKey>::KeyInfo const&) in liblibgo.a(processer.cpp.o)
void std::__1::vector<co::Anys<co::TaskGroupKey>::KeyInfo, std::__1::allocator<co::Anys<co::TaskGroupKey>::KeyInfo> >::__push_back_slow_path<co::Anys<co::TaskGroupKey>::KeyInfo const&>(co::Anys<co::TaskGroupKey>::KeyInfo const&) in liblibgo.a(scheduler.cpp.o)
void std::__1::vector<std::__1::pair<int, int>, std::__1::allocator<std::__1::pair<int, int> > >::__push_back_slow_path<std::__1::pair<int, int> >(std::__1::pair<int, int>&&) in liblibgo.a(scheduler.cpp.o)
_select$1050 in liblibgo.a(hook.cpp.o)
void std::__1::vector<co::Anys<co::TaskGroupKey>::KeyInfo, std::__1::allocator<co::Anys<co::TaskGroupKey>::KeyInfo> >::__push_back_slow_path<co::Anys<co::TaskGroupKey>::KeyInfo const&>(co::Anys<co::TaskGroupKey>::KeyInfo const&) in liblibgo.a(config.cpp.o)
void std::__1::vector<co::Anys<co::TaskGroupKey>::KeyInfo, std::__1::allocator<co::Anys<co::TaskGroupKey>::KeyInfo> >::__push_back_slow_path<co::Anys<co::TaskGroupKey>::KeyInfo const&>(co::Anys<co::TaskGroupKey>::KeyInfo const&) in liblibgo.a(task.cpp.o)
void std::__1::vector<co::Reactor*, std::__1::allocator<co::Reactor*> >::__push_back_slow_path<co::Reactor*>(co::Reactor*&&) in liblibgo.a(reactor.cpp.o)
...
"std::__1::__basic_string_common<true>::__throw_length_error() const", referenced from:
co::GetCurrentTime() in liblibgo.a(config.cpp.o)
co::Format(char const*, ...) in liblibgo.a(config.cpp.o)
co::P(char const*, ...) in liblibgo.a(config.cpp.o)
"std::exception_ptr::exception_ptr(std::exception_ptr const&)", referenced from:
co::Processer::Process() in liblibgo.a(processer.cpp.o)
"std::exception_ptr::~exception_ptr()", referenced from:
co::Processer::Process() in liblibgo.a(processer.cpp.o)
co::Task::Run() in liblibgo.a(task.cpp.o)
co::Task::Task(std::__1::function<void ()> const&, unsigned long) in liblibgo.a(task.cpp.o)
co::Task::~Task() in liblibgo.a(task.cpp.o)
"std::__1::this_thread::sleep_for(std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > const&)", referenced from:
co::FastSteadyClock::ThreadRun() in liblibgo.a(scheduler.cpp.o)
co::Scheduler::DispatcherThread() in liblibgo.a(scheduler.cpp.o)
void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, co::staticGetTimer()::$_4> >(void*) in liblibgo.a(scheduler.cpp.o)
void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, co::Scheduler::Start(int, int)::$_0> >(void*) in liblibgo.a(scheduler.cpp.o)
void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, co::Scheduler::UseAloneTimerThread()::$_2> >(void*) in liblibgo.a(scheduler.cpp.o)
"std::__1::__next_prime(unsigned long)", referenced from:
std::__1::__hash_table<std::__1::__hash_value_type<int, std::__1::shared_ptr<co::HookHelper::FdSlot> >, std::__1::__unordered_map_hasher<int, std::__1::__hash_value_type<int, std::__1::shared_ptr<co::HookHelper::FdSlot> >, std::__1::hash<int>, true>, std::__1::__unordered_map_equal<int, std::__1::__hash_value_type<int, std::__1::shared_ptr<co::HookHelper::FdSlot> >, std::__1::equal_to<int>, true>, std::__1::allocator<std::__1::__hash_value_type<int, std::__1::shared_ptr<co::HookHelper::FdSlot> > > >::rehash(unsigned long) in liblibgo.a(hook_helper.cpp.o)
std::__1::__hash_table<std::__1::__hash_value_type<int, short>, std::__1::__unordered_map_hasher<int, std::__1::__hash_value_type<int, short>, std::__1::hash<int>, true>, std::__1::__unordered_map_equal<int, std::__1::__hash_value_type<int, short>, std::__1::equal_to<int>, true>, std::__1::allocator<std::__1::__hash_value_type<int, short> > >::rehash(unsigned long) in liblibgo.a(kqueue_reactor.cpp.o)
"std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::append(char const*, unsigned long)", referenced from:
co::DbgTimer::ToString() in liblibgo.a(scheduler.cpp.o)
"std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::assign(char const*, unsigned long)", referenced from:
co::TaskDebugInfo(co::Task*) in liblibgo.a(scheduler.cpp.o)
co::TaskDebugInfo(co::Task*) in liblibgo.a(task.cpp.o)
"std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::reserve(unsigned long)", referenced from:
co::DbgTimer::ToString() in liblibgo.a(scheduler.cpp.o)
"std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::~basic_string()", referenced from:
co::TaskDebugInfo(co::Task*) in liblibgo.a(scheduler.cpp.o)
co::Scheduler::SetCurrentTaskDebugInfo(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in liblibgo.a(scheduler.cpp.o)
co::LibgoInitialize() in liblibgo.a(config.cpp.o)
co::TaskDebugInfo(co::Task*) in liblibgo.a(task.cpp.o)
"std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::operator=(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
co::Scheduler::SetCurrentTaskDebugInfo(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in liblibgo.a(scheduler.cpp.o)
"std::__1::__thread_struct::__thread_struct()", referenced from:
co::Scheduler::Start(int, int) in liblibgo.a(scheduler.cpp.o)
co::Scheduler::NewProcessThread() in liblibgo.a(scheduler.cpp.o)
co::Scheduler::UseAloneTimerThread() in liblibgo.a(scheduler.cpp.o)
co::Scheduler::StaticGetTimer() in liblibgo.a(scheduler.cpp.o)
std::__1::thread::thread<void (&)(), , void>(void (&)()) in liblibgo.a(scheduler.cpp.o)
co::Reactor::InitLoopThread() in liblibgo.a(reactor.cpp.o)
"std::__1::__thread_struct::~__thread_struct()", referenced from:
co::Scheduler::Start(int, int) in liblibgo.a(scheduler.cpp.o)
co::Scheduler::NewProcessThread() in liblibgo.a(scheduler.cpp.o)
co::Scheduler::UseAloneTimerThread() in liblibgo.a(scheduler.cpp.o)
co::Scheduler::StaticGetTimer() in liblibgo.a(scheduler.cpp.o)
void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, co::staticGetTimer()::$_4> >(void*) in liblibgo.a(scheduler.cpp.o)
void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, co::Scheduler::Start(int, int)::$_0> >(void*) in liblibgo.a(scheduler.cpp.o)
void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, co::Scheduler::Start(int, int)::$_1> >(void*) in liblibgo.a(scheduler.cpp.o)
...
"std::__1::condition_variable::notify_all()", referenced from:
co::Processer::AddTask(co::Task*) in liblibgo.a(processer.cpp.o)
co::Processer::OnAddTask() in liblibgo.a(processer.cpp.o)
co::Processer::AddTask(co::SList<co::Task>&&) in liblibgo.a(processer.cpp.o)
co::Processer::NotifyCondition() in liblibgo.a(processer.cpp.o)
co::Processer::WakeupBySelf(co::IncursivePtr<co::Task> const&, unsigned long long) in liblibgo.a(processer.cpp.o)
"std::__1::condition_variable::__do_timed_wait(std::__1::unique_lock<std::__1::mutex>&, std::__1::chrono::time_point<std::__1::chrono::system_clock, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > >)", referenced from:
co::Processer::WaitCondition() in liblibgo.a(processer.cpp.o)
"std::__1::__shared_weak_count::__release_weak()", referenced from:
co::Scheduler::Scheduler() in liblibgo.a(scheduler.cpp.o)
co::Scheduler::~Scheduler() in liblibgo.a(scheduler.cpp.o)
co::Scheduler::~Scheduler() in liblibgo.a(scheduler.cpp.o)
co::setTcpConnectTimeout(int, int) in liblibgo.a(hook.cpp.o)
_connect in liblibgo.a(hook.cpp.o)
co::libgo_poll(pollfd*, unsigned int, int, bool) in liblibgo.a(hook.cpp.o)
_accept in liblibgo.a(hook.cpp.o)
...
"std::__1::__shared_weak_count::~__shared_weak_count()", referenced from:
std::__1::__shared_ptr_pointer<bool*, std::__1::default_delete<bool>, std::__1::allocator<bool> >::~__shared_ptr_pointer() in liblibgo.a(scheduler.cpp.o)
std::__1::__shared_ptr_pointer<bool*, std::__1::default_delete<bool>, std::__1::allocator<bool> >::~__shared_ptr_pointer() in liblibgo.a(scheduler.cpp.o)
std::__1::__shared_ptr_pointer<short*, co::libgo_poll(pollfd*, unsigned int, int, bool)::{lambda(short*)#1}, std::__1::allocator<short> >::~__shared_ptr_pointer() in liblibgo.a(hook.cpp.o)
std::__1::__shared_ptr_pointer<short*, co::libgo_poll(pollfd*, unsigned int, int, bool)::{lambda(short*)#1}, std::__1::allocator<short> >::~__shared_ptr_pointer() in liblibgo.a(hook.cpp.o)
std::__1::__shared_ptr_pointer<co::FdContext*, std::__1::default_delete<co::FdContext>, std::__1::allocator<co::FdContext> >::~__shared_ptr_pointer() in liblibgo.a(hook_helper.cpp.o)
std::__1::__shared_ptr_pointer<co::FdContext*, std::__1::default_delete<co::FdContext>, std::__1::allocator<co::FdContext> >::~__shared_ptr_pointer() in liblibgo.a(hook_helper.cpp.o)
std::__1::__shared_ptr_pointer<co::HookHelper::FdSlot*, std::__1::default_delete<co::HookHelper::FdSlot>, std::__1::allocator<co::HookHelper::FdSlot> >::~__shared_ptr_pointer() in liblibgo.a(hook_helper.cpp.o)
...
"std::__1::__thread_local_data()", referenced from:
void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, co::staticGetTimer()::$_4> >(void*) in liblibgo.a(scheduler.cpp.o)
void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, co::Scheduler::Start(int, int)::$_0> >(void*) in liblibgo.a(scheduler.cpp.o)
void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, co::Scheduler::Start(int, int)::$_1> >(void*) in liblibgo.a(scheduler.cpp.o)
void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)()> >(void*) in liblibgo.a(scheduler.cpp.o)
void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, co::Scheduler::UseAloneTimerThread()::$_2> >(void*) in liblibgo.a(scheduler.cpp.o)
void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, co::Scheduler::NewProcessThread()::$_3> >(void*) in liblibgo.a(scheduler.cpp.o)
void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, co::Reactor::InitLoopThread()::$_0> >(void*) in liblibgo.a(reactor.cpp.o)
...
"std::__1::__throw_system_error(int, char const*)", referenced from:
co::Scheduler::Start(int, int) in liblibgo.a(scheduler.cpp.o)
co::Scheduler::NewProcessThread() in liblibgo.a(scheduler.cpp.o)
co::Scheduler::UseAloneTimerThread() in liblibgo.a(scheduler.cpp.o)
co::Scheduler::StaticGetTimer() in liblibgo.a(scheduler.cpp.o)
std::__1::thread::thread<void (&)(), , void>(void (&)()) in liblibgo.a(scheduler.cpp.o)
co::Reactor::InitLoopThread() in liblibgo.a(reactor.cpp.o)
"std::__1::mutex::lock()", referenced from:
co::Processer::AddTask(co::Task*) in liblibgo.a(processer.cpp.o)
co::Processer::AddTask(co::SList<co::Task>&&) in liblibgo.a(processer.cpp.o)
co::Processer::Process() in liblibgo.a(processer.cpp.o)
co::Processer::WaitCondition() in liblibgo.a(processer.cpp.o)
co::Processer::Steal(unsigned long) in liblibgo.a(processer.cpp.o)
co::Processer::SuspendBySelf(co::Task*) in liblibgo.a(processer.cpp.o)
co::Processer::WakeupBySelf(co::IncursivePtr<co::Task> const&, unsigned long long) in liblibgo.a(processer.cpp.o)
...
"std::__1::mutex::unlock()", referenced from:
co::Processer::AddTask(co::Task*) in liblibgo.a(processer.cpp.o)
co::Processer::AddTask(co::SList<co::Task>&&) in liblibgo.a(processer.cpp.o)
co::Processer::Process() in liblibgo.a(processer.cpp.o)
co::Processer::WaitCondition() in liblibgo.a(processer.cpp.o)
co::Processer::Steal(unsigned long) in liblibgo.a(processer.cpp.o)
co::Processer::SuspendBySelf(co::Task*) in liblibgo.a(processer.cpp.o)
co::Processer::WakeupBySelf(co::IncursivePtr<co::Task> const&, unsigned long long) in liblibgo.a(processer.cpp.o)
...
"std::__1::mutex::~mutex()", referenced from:
unsigned long co::Anys<co::TaskGroupKey>::Register<std::__1::atomic<unsigned long long> >(void (*)(void*), void (*)(void*)) in liblibgo.a(processer.cpp.o)
unsigned long co::Anys<co::TaskGroupKey>::Register<bool>(void (*)(void*), void (*)(void*)) in liblibgo.a(scheduler.cpp.o)
unsigned long co::Anys<co::TaskGroupKey>::Register<co::SourceLocation>(void (*)(void*), void (*)(void*)) in liblibgo.a(scheduler.cpp.o)
unsigned long co::Anys<co::TaskGroupKey>::Register<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(void (*)(void*), void (*)(void*)) in liblibgo.a(scheduler.cpp.o)
co::HookHelper::~HookHelper() in liblibgo.a(hook_helper.cpp.o)
co::ReactorElement::~ReactorElement() in liblibgo.a(hook_helper.cpp.o)
unsigned long co::Anys<co::TaskGroupKey>::Register<bool>(void (*)(void*), void (*)(void*)) in liblibgo.a(config.cpp.o)
...
"std::__1::chrono::steady_clock::now()", referenced from:
co::Processer::WaitCondition() in liblibgo.a(processer.cpp.o)
co::FastSteadyClock::now() in liblibgo.a(processer.cpp.o)
co::FastSteadyClock::ThreadRun() in liblibgo.a(scheduler.cpp.o)
co::FastSteadyClock::now() in liblibgo.a(scheduler.cpp.o)
"std::__1::chrono::system_clock::now()", referenced from:
co::Processer::WaitCondition() in liblibgo.a(processer.cpp.o)
"std::__1::thread::hardware_concurrency()", referenced from:
co::Scheduler::Start(int, int) in liblibgo.a(scheduler.cpp.o)
"std::__1::thread::detach()", referenced from:
co::Scheduler::Start(int, int) in liblibgo.a(scheduler.cpp.o)
co::Scheduler::NewProcessThread() in liblibgo.a(scheduler.cpp.o)
co::Scheduler::UseAloneTimerThread() in liblibgo.a(scheduler.cpp.o)
co::Scheduler::StaticGetTimer() in liblibgo.a(scheduler.cpp.o)
co::Reactor::InitLoopThread() in liblibgo.a(reactor.cpp.o)
"std::__1::thread::~thread()", referenced from:
co::Scheduler::Start(int, int) in liblibgo.a(scheduler.cpp.o)
co::Scheduler::NewProcessThread() in liblibgo.a(scheduler.cpp.o)
co::Scheduler::UseAloneTimerThread() in liblibgo.a(scheduler.cpp.o)
co::Scheduler::StaticGetTimer() in liblibgo.a(scheduler.cpp.o)
co::Reactor::InitLoopThread() in liblibgo.a(reactor.cpp.o)
"std::rethrow_exception(std::exception_ptr)", referenced from:
co::Processer::Process() in liblibgo.a(processer.cpp.o)
"typeinfo for std::__1::__shared_weak_count", referenced from:
typeinfo for std::__1::__shared_ptr_pointer<bool*, std::__1::default_delete<bool>, std::__1::allocator<bool> > in liblibgo.a(scheduler.cpp.o)
typeinfo for std::__1::__shared_ptr_pointer<short*, co::libgo_poll(pollfd*, unsigned int, int, bool)::{lambda(short*)#1}, std::__1::allocator<short> > in liblibgo.a(hook.cpp.o)
typeinfo for std::__1::__shared_ptr_pointer<co::FdContext*, std::__1::default_delete<co::FdContext>, std::__1::allocator<co::FdContext> > in liblibgo.a(hook_helper.cpp.o)
typeinfo for std::__1::__shared_ptr_pointer<co::HookHelper::FdSlot*, std::__1::default_delete<co::HookHelper::FdSlot>, std::__1::allocator<co::HookHelper::FdSlot> > in liblibgo.a(hook_helper.cpp.o)
typeinfo for std::__1::__shared_ptr_pointer<co::FdContext*, std::__1::default_delete<co::FdContext>, std::__1::allocator<co::FdContext> > in liblibgo.a(fd_context.cpp.o)
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
你这是没链接到c++标准库啊
在master分支上
make install
出现下面这样的日志,然后g++ -std=c++11 xxx.cpp -llibgo
会抱找不到引用的错.[100%] Linking CXX static library liblibgo.a /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: liblibgo.a(epoll_reactor.cpp.o) has no symbols /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: liblibgo.a(epoll_reactor.cpp.o) has no symbols [100%] Built target libgo_static Install the project... -- Install configuration: "RELEASE" -- Installing: /usr/local/lib/liblibgo.a /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: /usr/local/lib/liblibgo.a(epoll_reactor.cpp.o) has no symbols
在3.0分支
make install
也会出现这种错误.但是在编译的时候又是另外的错误了.