Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
275 views
in Technique[技术] by (71.8m points)

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

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...