How do I compile for 64bit using G++ w/ CodeBlocks?

↘锁芯ラ 提交于 2019-12-17 18:24:36

问题


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.

How can I compile 64bit dlls from code blocks using g++ ?

I've tried compiler options like -m64 but none seem to work.


回答1:


To compile 64-bit programs on windows using g++, you need MinGW64. I believe that Code::Blocks comes with MinGW32.

To install it onto Code::Blocks, extract the zip file to a folder without spaces, such as C:\MinGW64

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.

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:

Compiler's installation directory: The path you specified( C:\MinGW64 )

C compiler: gcc.exe

C++ compiler: g++.exe (If you used my link above it will be g++64.exe, thanks Super Cat for reminding me)

Linker for dynamic libs: g++.exe (g++64.exe if you used my link)

Linker for static libs: ar.exe

Debugger: There isn't one for MinGW64 yet, clear this and leave it blank

Resource compiler: windres.exe

Make program: make.exe

Once you have the compiler set up, compile your DLL with the same settings, only using the 64 bit compiler.



来源:https://stackoverflow.com/questions/26414511/how-do-i-compile-for-64bit-using-g-w-codeblocks

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!