yyzybb537 / libgo

Go-style concurrency in C++11
MIT License
3.22k stars 757 forks source link

linux下编译错误 undefined reference to 'libgo_jump_fcontext' #299

Closed dx12346789 closed 1 year ago

dx12346789 commented 1 year ago

cmake运行时报错

--> select asm source file, please wait about 5 seconds ...
/home/x/Desktop/libgo_test/otherlib/libgo-master/third_party/select_asm.sh: line 8: ./b2: No such file or directory
basename: missing operand
Try 'basename --help' for more information.
cp: cannot stat ‘/home/x/Desktop/libgo_test/otherlib/libgo-master/third_party/boost.context/libs/context/src/asm/.S’: No such file or directory
/home/x/Desktop/libgo_test/otherlib/libgo-master/third_party/select_asm.sh: line 8: ./b2: No such file or directory
basename: missing operand
Try 'basename --help' for more information.
cp: cannot stat ‘/home/x/Desktop/libgo_test/otherlib/libgo-master/third_party/boost.context/libs/context/src/asm/.S’: No such file or directory

make时报错

/home/x/Desktop/libgo_test/out/build/linux/liblibgo.a(processer.cpp.o): In function `co::Context::SwapIn()':
/home/x/Desktop/libgo_test/otherlib/libgo-master/libgo/scheduler/../task/../context/context.h:39: undefined reference to `libgo_jump_fcontext'
/home/x/Desktop/libgo_test/out/build/linux/liblibgo.a(task.cpp.o): In function `co::Context::Context(void (*)(long), long, unsigned long)':
/home/x/Desktop/libgo_test/otherlib/libgo-master/libgo/task/../context/context.h:20: undefined reference to `libgo_make_fcontext'
/home/x/Desktop/libgo_test/out/build/linux/liblibgo.a(task.cpp.o): In function `co::Context::SwapOut()':
/home/x/Desktop/libgo_test/otherlib/libgo-master/libgo/task/../context/context.h:49: undefined reference to `libgo_jump_fcontext'
/home/x/Desktop/libgo_test/otherlib/libgo-master/libgo/task/../context/context.h:49: undefined reference to `libgo_jump_fcontext'
/home/x/Desktop/libgo_test/out/build/linux/liblibgo.a(hook.cpp.o): In function `doInitHook':
/home/x/Desktop/libgo_test/otherlib/libgo-master/libgo/netio/unix/hook.cpp:1121: undefined reference to `dlsym'
/home/x/Desktop/libgo_test/otherlib/libgo-master/libgo/netio/unix/hook.cpp:1123: undefined reference to `dlsym'
/home/x/Desktop/libgo_test/otherlib/libgo-master/libgo/netio/unix/hook.cpp:1124: undefined reference to `dlsym'
/home/x/Desktop/libgo_test/otherlib/libgo-master/libgo/netio/unix/hook.cpp:1125: undefined reference to `dlsym'
/home/x/Desktop/libgo_test/otherlib/libgo-master/libgo/netio/unix/hook.cpp:1126: undefined reference to `dlsym'
/home/x/Desktop/libgo_test/out/build/linux/liblibgo.a(hook.cpp.o):/home/x/Desktop/libgo_test/otherlib/libgo-master/libgo/netio/unix/hook.cpp:1127: more undefined references to `dlsym' follow
/home/x/Desktop/libgo_test/out/build/linux/liblibgo.a(hook.cpp.o): In function `co::Context::SwapOut()':
/home/x/Desktop/libgo_test/otherlib/libgo-master/libgo/netio/unix/../../scheduler/../task/../context/context.h:49: undefined reference to `libgo_jump_fcontext'
/home/x/Desktop/libgo_test/otherlib/libgo-master/libgo/netio/unix/../../scheduler/../task/../context/context.h:49: undefined reference to `libgo_jump_fcontext'
/home/x/Desktop/libgo_test/otherlib/libgo-master/libgo/netio/unix/../../scheduler/../task/../context/context.h:49: undefined reference to `libgo_jump_fcontext'
/home/x/Desktop/libgo_test/otherlib/libgo-master/libgo/netio/unix/../../scheduler/../task/../context/context.h:49: undefined reference to `libgo_jump_fcontext'
/home/x/Desktop/libgo_test/otherlib/libgo-master/libgo/netio/unix/../../scheduler/../task/../context/context.h:49: undefined reference to `libgo_jump_fcontext'
/home/x/Desktop/libgo_test/out/build/linux/liblibgo.a(hook.cpp.o):/home/x/Desktop/libgo_test/otherlib/libgo-master/libgo/netio/unix/../../scheduler/../task/../context/context.h:49: more undefined references to `libgo_jump_fcontext' follow
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/libgo_test.dir/build.make:97: /home/x/Desktop/libgo_test/out/build/linux/libgo_test] Error 1
make[1]: *** [CMakeFiles/Makefile2:106: CMakeFiles/libgo_test.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

检索了一下 好像没有看到libgo_jump_fcontext函数的实现? 可以帮忙指出步骤那里出错了吗

cmakelists.txt

set(BOOST_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/../console/otherlib/Boost/linux")
set(Boost_LIBRARY_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../console/otherlib/Boost/linux/lib")
set(Boost_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../console/otherlib/Boost/linux/inlude/boost-1_76")
find_package(Boost 1.76 COMPONENTS thread regex system REQUIRED)

include_directories(${Boost_INCLUDE_DIR})
link_directories(${Boost_LIBRARY_DIR})

set(BOOST_LIBS thread regex system)

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/otherlib/libgo-master/libgo)
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/otherlib/libgo-master" "libgo")

link_directories(${CMAKE_LIBRARY_OUTPUT_DIRECTORY})

add_executable(${PROJECT_NAME} src/main.cpp)

target_link_libraries(${PROJECT_NAME} pthread libgo)
dx12346789 commented 1 year ago

解决了,我linux下cp命令出问题无法拷贝导致bootstrap.sh执行失败