Skip to content

使用 cmake 编译出现 undefined exception 错误 #151

@jiaoqiyuan

Description

@jiaoqiyuan

硬件信息: Ubuntu 18.04.2 LTS (GNU/Linux 4.15.0-117-generic x86_64)

复现步骤:

mkdir build
cd build
cmake ../
make

错误信息:

$ make
Scanning dependencies of target colib_static
[  3%] Building CXX object CMakeFiles/colib_static.dir/co_epoll.cpp.o
[  6%] Building CXX object CMakeFiles/colib_static.dir/co_hook_sys_call.cpp.o
[ 10%] Building CXX object CMakeFiles/colib_static.dir/co_routine.cpp.o
[ 13%] Building CXX object CMakeFiles/colib_static.dir/coctx.cpp.o
[ 16%] Building ASM object CMakeFiles/colib_static.dir/coctx_swap.S.o
[ 20%] Linking CXX static library libcolib.a
[ 20%] Built target colib_static
Scanning dependencies of target example_thread
[ 23%] Building CXX object CMakeFiles/example_thread.dir/example_thread.cpp.o
[ 26%] Linking CXX executable example_thread
[ 26%] Built target example_thread
Scanning dependencies of target example_setenv
[ 30%] Building CXX object CMakeFiles/example_setenv.dir/example_setenv.cpp.o
[ 33%] Linking CXX executable example_setenv
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+0x1fca): undefined reference to `clsCoMutex::clsCoMutex()'
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()'
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
CMakeFiles/example_setenv.dir/build.make:95: recipe for target 'example_setenv' failed
make[2]: *** [example_setenv] Error 1
CMakeFiles/Makefile2:104: recipe for target 'CMakeFiles/example_setenv.dir/all' failed
make[1]: *** [CMakeFiles/example_setenv.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions