问题描述
我目前正在创建一个共享库 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 位?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!