How do I compile for 64bit using G++ w/ CodeBlocks?(如何使用带 CodeBlocks 的 G++ 编译 64 位?)
问题描述
我目前正在创建一个共享库 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.
然后在 Toolchain executables 选项卡上,单击每个选项旁边的 Browse 按钮并浏览到您将 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.
这篇关于如何使用带 CodeBlocks 的 G++ 编译 64 位?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何使用带 CodeBlocks 的 G++ 编译 64 位?
基础教程推荐
- 为什么 typeid.name() 使用 GCC 返回奇怪的字符以及如 2022-09-16
- 我应该对 C++ 中的成员变量和函数参数使用相同的名称吗? 2021-01-01
- 为什么派生模板类不能访问基模板类的标识符? 2021-01-01
- 通过引用传递 C++ 迭代器有什么问题? 2022-01-01
- 非静态 const 成员,不能使用默认赋值运算符 2022-10-09
- GDB 显示调用堆栈上函数地址的当前编译二进制文 2022-09-05
- CString 到 char* 2021-01-01
- 为什么 RegOpenKeyEx() 在 Vista 64 位上返回错误代码 2021-01-01
- 初始化列表*参数*评估顺序 2021-01-01
- 如果我为无符号变量分配负值会发生什么? 2022-01-01
