libco icon indicating copy to clipboard operation
libco copied to clipboard

centos7.9 cmake3.20 编译报错了,帮忙看下 GNU 9.3.1

Open dylu6699 opened this issue 3 years ago • 3 comments

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

dylu6699 avatar Apr 29 '21 10:04 dylu6699

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

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)

添加了就能编译过了

erban-xiao avatar May 07 '21 06:05 erban-xiao

楼上正解,这字面意思就是找不到函数签名的引用(定义,实现), 一般可能是编译时没有链接到对应的模块(库或者源文件, 在c++中一般是cpp文件),这里明显是库中的函数找不到链接,那就在库里找下函数的定义在哪里,CMake配置文件加上就可以了

hsbyhub avatar Feb 18 '22 06:02 hsbyhub

哩噶来件已经被我收埋佐啦哈哈 ^ ^

hobby avatar Feb 18 '22 06:02 hobby