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

2019-01-17 13:06发布

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条回答
唯我独甜
2楼-- · 2019-01-17 13:52

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.

查看更多
登录 后发表回答