简体   繁体   English

代码::块链接不起作用,提示时确实起作用

[英]Code::Blocks linking not working, on prompt it does

I'm having quite a bit of trouble linking a test project of FLTK I'm doing on Code::Blocks, Windows 7. 我在Windows 7的Code :: Blocks上链接正在进行的FLTK测试项目时遇到了很多麻烦。

After spending quite a lot of time understanding how to put the libraries in the correct order, I managed to get the project nearly done. 在花了很多时间了解如何按照正确的顺序放置库之后,我设法使项目接近完成。 However there's still a linking problem: 但是仍然存在链接问题:

mingw32-g++.exe -Wall -fexceptions  -IC:\Users\Svalorzen\Documents\Projects\fltk-1.3.0 -mwindows -DWIN32 -DUSE_OPENGL32 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE     -c C:\Users\Svalorzen\Documents\Projects\test\main.cpp -o obj\Debug\main.o
mingw32-g++.exe  -o bin\Debug\test.exe obj\Debug\main.o   -LC:\Users\Svalorzen\Documents\Projects\fltk-1.3.0\lib -mwindows -lfltk -lole32 -luuid -lcomctl32  
C:\Users\Svalorzen\Documents\Projects\fltk-1.3.0\lib/libfltk.a(Fl_Native_File_Chooser.o):Fl_Native_File_Chooser.cxx:(.text+0x1556): undefined reference to `__chkstk_ms'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 1 seconds)
1 errors, 0 warnings

However, using the same exact script that Code::Blocks shows, executed on command prompt ( or even msys for what matters ), correctly compiles and links everything. 但是,使用与Code :: Blocks显示的相同脚本,并在命令提示符下执行(甚至重要的是msys),即可正确编译并链接所有内容。 The resulting exe also works. 生成的exe也可以使用。

C:\Users\Svalorzen\Documents\Projects\test>mingw32-g++ -Wall -fexceptions -IC:\Users\Svalorzen\Documents\Projects\fltk-1.3.0 -mwindows -DWIN32 -DUSE_OPENGL32 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -c C:\Users\Svalorzen\Documents\Projects\test\main.cpp -o obj\Debug\main.o

C:\Users\Svalorzen\Documents\Projects\test>mingw32-g++ -o bin\Debug\test.exe obj\Debug\main.o -LC:\Users\Svalorzen\Documents\Projects\fltk-1.3.0\lib -mwindows -lfltk -lole32 -luuid -lcomctl32

C:\Users\Svalorzen\Documents\Projects\test>dir bin\Debug\test.exe
   Volume in drive C has no label.
   Volume Serial Number is 00E8-6659

Directory of C:\Users\Svalorzen\Documents\Projects\test\bin\Debug

10/05/2012  19:01           661.087 test.exe
           1 File(s)        661.087 bytes
           0 Dir(s)  66.016.849.920 bytes free

The paths in the instruction are all absolute, so I don't really understand why this is. 指令中的路径都是绝对的,所以我真的不明白为什么会这样。

What am I doing wrong? 我究竟做错了什么? What I should check? 我应该检查什么?

EDIT: It turned out that I had a MinGW installation I didn't remember about and Code::Blocks was using that one. 编辑:原来我安装了一个我不记得的MinGW,而Code :: Blocks正在使用那个。 I changed it and now everything is fixed. 我更改了它,现在一切都固定了。

如果您的MinGW是最新的,请尝试添加-no-vcproj-no-dsp ,然后运行mingw32-make confclean

It turned out that I had a MinGW installation I didn't remember about and Code::Blocks was using that one. 原来,我安装了一个我不记得的MinGW,而Code :: Blocks正在使用该安装。

I setup Code::Blocks with the same compiler that created the library and now everything is fine. 我使用创建该库的相同编译器设置了Code :: Blocks,现在一切正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM