[英]Cygwin compiling error: “this application has requested the runtime to terminate it in an unusual way”
[英]MinGW - Application terminates in unusual way (after finishing) once a .dll was loaded
使用Cygwin的MinGW進行編譯時,我在Windows上動態加載共享庫時遇到問題。
該應用程序包括6個部分:2個靜態庫,3個共享庫和1個使用靜態庫並在運行時加載共享庫的可執行文件。
我在Cygwin中使用i686-pc-mingw32-g++
。 所有源文件都使用-std=c++11
標志進行編譯,它們的鏈接方式如下:
Static libraries:
i686-pc-mingw32-ar rcs libxxx.a bin/*.o
i686-pc-mingw32-ar rcs libyyy.a bin/*.o
Each shared library:
i686-pc-mingw32-g++ -fPIC -shared -o ###.dll bin/*.o -lxxx -L../xxx -lyyy -L../yyy
Executable:
i686-pc-mingw32-g++ -o program.exe bin/*.o -lxxx -L../xxx -lyyy -L../yyy -static
該應用程序可以正常運行,並且可以完成預期的工作,但是一旦程序完成執行並從main方法返回,我將收到以下消息:
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
僅當我加載共享庫之一時才會發生這種情況。 如果我不這樣做,則應用程序將終止而不顯示該消息。
我懷疑該程序與Windows的LoadLibrary
; 我還嘗試過手動釋放每個庫,然后再從main返回,但是發生相同的問題。
注意:使用Cygwin的GCC使用相同的代碼進行編譯時,不會出現該消息,並且一切都會按預期工作。
任何幫助是極大的贊賞。
編輯:發現了另一件事:當我鏈接沒有“ -static”的二進制文件時,它不會崩潰。
我見過類似的東西,之前曾報道過: http : //thread.gmane.org/gmane.comp.gnu.mingw.user/41724
這是否適用於您的情況? 特別是: http : //thread.gmane.org/gmane.comp.gnu.mingw.user/41724/focus=41738
及其后續行動?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.