Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
625 views
in Technique[技术] by (71.8m points)

c++ - Reference error when attempting to build/link project with mingw-w64

I am trying to build my program and have been getting errors that I don't know how to resolve.

The errors are undefined reference to '__security_init_cookie' and undefined reference to '__mingw_init_ehandler'. I suspect it's something to do with linking but I am unsure how to solve this, I found no real resolutions on google.

My compilation args are below with the relevant error:

Compilation:

g++ -Wl,-subsystem,windows -mthreads -o debugWAMsoft.exe 
@object_script.WAMsoft.Debug  -LC:oost_1_75_0oost -LC:cygwin64usrx86_64-
w64-mingw32sys-rootmingwlib -Lusrinclude -Xlinker --verbose -w -lgmp -lm -
LC:UsersChrisFuscoDocumentsQTqt5-buildqtbaselib 
C:UsersChrisFuscoDocumentsQTqt5-buildqtbaseliblibQt5Widgetsd.a 
C:UsersChrisFuscoDocumentsQTqt5-buildqtbaseliblibQt5Guid.a 
C:UsersChrisFuscoDocumentsQTqt5-buildqtbaseliblibQt5Xmld.a 
C:UsersChrisFuscoDocumentsQTqt5-buildqtbaseliblibQt5XmlPatternsd.a 
C:UsersChrisFuscoDocumentsQTqt5-buildqtbaseliblibQt5Networkd.a 
C:UsersChrisFuscoDocumentsQTqt5-buildqtbaseliblibQt5Cored.a  "C:Program 
Filesmingw-w64x86_64-8.1.0-posix-seh-rt_v6-rev0mingw64x86_64-w64-
mingw32liblibglu32.a" "C:Program Filesmingw-w64x86_64-8.1.0-posix-seh-rt_v6-
rev0mingw64x86_64-w64-mingw32liblibopengl32.a" "C:Program Filesmingw-
w64x86_64-8.1.0-posix-seh-rt_v6-rev0mingw64x86_64-w64-mingw32liblibgdi32.a" 
"C:Program Filesmingw-w64x86_64-8.1.0-posix-seh-rt_v6-rev0mingw64x86_64-w64-
mingw32liblibuser32.a" -lmingw32 C:UsersChrisFuscoDocumentsQTqt5-
buildqtbaseliblibqtmaind.a -lshell32

Full Error:

attempt to open C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/crtend.o succeeded
C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/crtend.o
C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/../lib/crt2.o:crtexe.c:(.text+0x264): undefined reference to `__mingw_init_ehandler'      
C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/../lib/crt2.o:crtexe.c:(.text+0x4c2): undefined reference to `__security_init_cookie'     
C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/../lib/crt2.o:crtexe.c:(.text+0x4f2): undefined reference to `__security_init_cookie'     
collect2.exe: error: ld returned 1 exit status

Any help is very much appreciated; I've been at this for days and I just want to move on to coding!

question from:https://stackoverflow.com/questions/65932813/reference-error-when-attempting-to-build-link-project-with-mingw-w64

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Similar problems has happened to me before. When the following message shows, the problem usually would be the static library is not found

undefined reference to ....

My suggestion would be why not move your static libraries ".a" into the folder

/x86_64-w64-mingw32/lib/

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...