Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
dylu6699 opened this issue Apr 29, 2021 · 3 comments
Open

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

dylu6699 opened this issue Apr 29, 2021 · 3 comments

Comments

@dylu6699
Copy link

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

@erban-xiao
Copy link

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)

添加了就能编译过了

@hsbyhub
Copy link

hsbyhub commented Feb 18, 2022

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

@hobby
Copy link

hobby commented Feb 18, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants