如何使用带有代码块的 G++ 为 64 位编译? [英] How do I compile for 64bit using G++ w/ CodeBlocks?
问题描述
我目前正在创建一个共享的 lib DLL,但我需要在 64 位环境中在运行时加载它,所以它目前不起作用.
I'm currently working on creating a shared lib DLL but I need to load it at runtime in a 64 bit environment so it currently doesn't work.
如何使用 g++ 从代码块编译 64 位 dll?
How can I compile 64bit dlls from code blocks using g++ ?
我尝试过像 -m64 这样的编译器选项,但似乎都不起作用.
I've tried compiler options like -m64 but none seem to work.
推荐答案
要在 windows 上使用 g++ 编译 64 位程序,您需要 MinGW64.我相信 Code::Blocks 带有 MinGW32.
To compile 64-bit programs on windows using g++, you need MinGW64. I believe that Code::Blocks comes with MinGW32.
要将其安装到 Code::Blocks,请将 zip 文件解压缩到一个没有空格的文件夹,例如 C:MinGW64
To install it onto Code::Blocks, extract the zip file to a folder without spaces, such as C:MinGW64
打开 Code::Blocks 并点击 Settings -> Compiler and debugger.在所选编译器下,单击复制.在下一个框中,键入MinGW 64-bit Compiler"之类的内容,然后单击确定".
Open Code::Blocks and click on Settings -> Compiler and debugger. Under Selected Compiler, click Copy. In the next box, type something like "MinGW 64-bit Compiler" and click OK.
然后在工具链可执行文件选项卡上,单击每个选项旁边的浏览按钮并浏览到您将 MinGW64 复制到的文件夹(C:MinGW64
)并进入 bin
文件夹.将每个选项设置如下:
Then on the Toolchain executables tab, click the Browse button beside each option and browse to the folder you copied MinGW64 to ( C:MinGW64
) and go into the bin
folder. Set each option as follows:
编译器的安装目录:你指定的路径(C:MinGW64
)
Compiler's installation directory: The path you specified( C:MinGW64
)
C 编译器:gcc.exe
C++ 编译器:g++.exe
(如果你用我上面的链接就是g++64.exe
,谢谢超级猫提醒)
C++ compiler: g++.exe
(If you used my link above it will be g++64.exe
, thanks Super Cat for reminding me)
动态库的链接器:g++.exe
(g++64.exe
,如果你使用了我的链接)
Linker for dynamic libs: g++.exe
(g++64.exe
if you used my link)
静态库的链接器:ar.exe
调试器:MinGW64 还没有调试器,清除它并留空
Debugger: There isn't one for MinGW64 yet, clear this and leave it blank
资源编译器:windres.exe
制作程序:make.exe
设置编译器后,使用相同的设置编译 DLL,仅使用 64 位编译器.
Once you have the compiler set up, compile your DLL with the same settings, only using the 64 bit compiler.
这篇关于如何使用带有代码块的 G++ 为 64 位编译?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!