libco
libco copied to clipboard
centos7.9 cmake3.20 编译报错了,帮忙看下 GNU 9.3.1
40%] Building CXX object libco/CMakeFiles/example_cond.dir/example_cond.cpp.o
[ 43%] Linking CXX executable example_cond
/opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/ld: libcolib.a(co_hook_sys_call.cpp.o): in function co_gethostbyname_r(char const*, hostent*, char*, unsigned long, hostent**, int*)': co_hook_sys_call.cpp:(.text+0x1e39): undefined reference to
clsCoMutex::clsCoMutex()'
/opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/ld: libcolib.a(co_hook_sys_call.cpp.o): in function clsSmartLock::clsSmartLock(clsCoMutex*)': co_hook_sys_call.cpp:(.text._ZN12clsSmartLockC2EP10clsCoMutex[_ZN12clsSmartLockC5EP10clsCoMutex]+0x26): undefined reference to
clsCoMutex::CoLock()'
/opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/ld: libcolib.a(co_hook_sys_call.cpp.o): in function clsSmartLock::~clsSmartLock()': co_hook_sys_call.cpp:(.text._ZN12clsSmartLockD2Ev[_ZN12clsSmartLockD5Ev]+0x17): undefined reference to
clsCoMutex::CoUnLock()'
collect2: error: ld returned 1 exit status
make[2]: *** [libco/CMakeFiles/example_cond.dir/build.make:105: libco/example_cond] Error 1
make[1]: *** [CMakeFiles/Makefile2:244: libco/CMakeFiles/example_cond.dir/all] Error 2
make: *** [Makefile:115: all] Error 2
40%] Building CXX object libco/CMakeFiles/example_cond.dir/example_cond.cpp.o [ 43%] Linking CXX executable example_cond /opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/ld: libcolib.a(co_hook_sys_call.cpp.o): in function
co_gethostbyname_r(char const*, hostent*, char*, unsigned long, hostent**, int*)': co_hook_sys_call.cpp:(.text+0x1e39): undefined reference to
clsCoMutex::clsCoMutex()' /opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/ld: libcolib.a(co_hook_sys_call.cpp.o): in functionclsSmartLock::clsSmartLock(clsCoMutex*)': co_hook_sys_call.cpp:(.text._ZN12clsSmartLockC2EP10clsCoMutex[_ZN12clsSmartLockC5EP10clsCoMutex]+0x26): undefined reference to
clsCoMutex::CoLock()' /opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/ld: libcolib.a(co_hook_sys_call.cpp.o): in functionclsSmartLock::~clsSmartLock()': co_hook_sys_call.cpp:(.text._ZN12clsSmartLockD2Ev[_ZN12clsSmartLockD5Ev]+0x17): undefined reference to
clsCoMutex::CoUnLock()' collect2: error: ld returned 1 exit status make[2]: *** [libco/CMakeFiles/example_cond.dir/build.make:105: libco/example_cond] Error 1 make[1]: *** [CMakeFiles/Makefile2:244: libco/CMakeFiles/example_cond.dir/all] Error 2 make: *** [Makefile:115: all] Error 2
CMakeLists文件漏了一个源文件co_comm.cpp set(SOURCE_FILES co_comm.cpp co_epoll.cpp co_hook_sys_call.cpp co_routine.cpp coctx.cpp coctx_swap.S)
添加了就能编译过了
楼上正解,这字面意思就是找不到函数签名的引用(定义,实现), 一般可能是编译时没有链接到对应的模块(库或者源文件, 在c++中一般是cpp文件),这里明显是库中的函数找不到链接,那就在库里找下函数的定义在哪里,CMake配置文件加上就可以了
哩噶来件已经被我收埋佐啦哈哈 ^ ^