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

进程(调用Debug版版本库)退出时异常 #207

Open
dyzyrax opened this issue Jan 24, 2024 · 9 comments
Open

进程(调用Debug版版本库)退出时异常 #207

dyzyrax opened this issue Jan 24, 2024 · 9 comments

Comments

@dyzyrax
Copy link

dyzyrax commented Jan 24, 2024

进程Debug版本退出时异常

@xia-chu
Copy link
Member

xia-chu commented Jan 26, 2024

看不出什么有效信息 代码git hash是多少?

@dyzyrax
Copy link
Author

dyzyrax commented Jan 26, 2024

ZLToolKit-master.zip
上面这个版本

@dyzyrax
Copy link
Author

dyzyrax commented Jan 26, 2024

采用Visual studio 2015,将ZLToolKit编译为动态库,进行调用动态库时出现上图异常。
注,采用静态库时,与项目的其他代码存在冲突,编译报错

@dyzyrax
Copy link
Author

dyzyrax commented Jan 26, 2024

这个异常是否与我的使用方法有关。我的使用方法:我在动态库sampled.dll中调用了静态库ZLToolKit,然后进程sampled.exe中调用了sampled.dll
我看到CMakeLists.txt中禁止将ZLToolKit编译为WIndows下的DLL,是什么原因呢?有无解决措施?

@xia-chu
Copy link
Member

xia-chu commented Jan 28, 2024

把zltoolkit编译成dll 建议还是c封装下比较好 因为c++的abi是不兼容的。
从你debug信息看 是ZLToolkit的socket被系统回收了或者被同进程代码关闭了 不得而知。

1 similar comment
@xia-chu
Copy link
Member

xia-chu commented Jan 28, 2024

把zltoolkit编译成dll 建议还是c封装下比较好 因为c++的abi是不兼容的。
从你debug信息看 是ZLToolkit的socket被系统回收了或者被同进程代码关闭了 不得而知。

@dyzyrax
Copy link
Author

dyzyrax commented Jan 29, 2024 via email

@dyzyrax
Copy link
Author

dyzyrax commented Jan 30, 2024 via email

@dyzyrax
Copy link
Author

dyzyrax commented Jan 31, 2024

我尝试将test_tcpClient.cpp中的main函数改名并已C接口导出,运行正常,进程销毁时也存在异常。我分享下问题复现方式:

ZLToolKitDLL.zip
① 将附件压缩包解药至ZLToolKit-master目录
② ZLToolKit-master/CMakeLists.txt中尾部增加以下内容,将test_tcpClient示例功能封装为动态库ZLToolKitDLL.dll的接口ZLToolKitDLL_test,并在测试程序ZLToolKitDLL_test.cpp调用
# ZLToolKit动态库编译及调用
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
add_library(ZLToolKitDLL SHARED ${CMAKE_CURRENT_SOURCE_DIR}/ZLToolKitDLL/ZLToolKitDLL.cpp ${CMAKE_CURRENT_SOURCE_DIR}/ZLToolKitDLL/ZLToolKitDLL.h)
if(ANDROID OR IOS OR WIN32)
target_link_libraries(ZLToolKitDLL ${PROJECT_NAME}_static ${LINK_LIB_LIST})
else()
target_link_libraries(ZLToolKitDLL ${PROJECT_NAME}_static ${LINK_LIB_LIST} pthread)
endif()

    add_executable(ZLToolKitDLL_test ${CMAKE_CURRENT_SOURCE_DIR}/ZLToolKitDLL/ZLToolKitDLL_test.cpp )
    target_link_libraries(ZLToolKitDLL_test ZLToolKitDLL)

③ 构建Visual Studio 2015 64位工程,编译测试程序ZLToolKitDLL_test,程序运行后,按‘esc’或'q'键退出,退出过程中就会报异常

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

2 participants