Netbeans and MinGW-w64
Right, after months of putting this off I've finally sat down and done it. I'll probably make a more detailed post on my blog with pretty pictures but here is a trimmed down SO version which will hopefully be enough for you (and everyone else) to get going with.
Prerequisites
Remove MinGW, MSYS and CMake if you have them and can afford to lose them (we will reinstall MinGW (obv.) and MSYS but not CMake as it doesn't appear to be needed.)
- Netbeans or other suitable IDE
- 64bit Windows.
- EnvMan (optional but handy for managing Windows Environment variables.)
Installation
MinGW-W64 C compiler and MSYS
- Download and install MinGW-W64
- http://mingw-w64.sourceforge.net/ (link is on the left menu with a hyperlink called 'WIN64 Downloads'.)
- There are a lot of versions which can be a bit complicated. We are going with mingw-w64-bin_i686-mingw_20111220 (although the numbers at the end may be different) which basically says we want the version with the windows binaries.
- Once the download is complete (about 300mb so 10min or so) extract to C:\MinGW-W64 or similar. Make sure there aren't any spaces in the path!
- Download MSYS for MinGW-W64
- Took a bit of searching http://sourceforge.net/apps/trac/mingw-w64/wiki/MSYS is the wiki for it and http://sourceforge.net/projects/mingw-w64/files/External%20binary%20packages%20%28Win64%20hosted%29/MSYS%20%2832-bit%29/ is where I found the download and the version I went with was MSYS-20111123
- Once the download is complete extract the files to C:\MSys or similar. Make sure there aren't any spaces in the path!
Setup
- Add 'C:\MinGW-W64\bin' to your Windows PATH variable.
- Add 'C:\MSys\msys\bin' to your Windows PATH variable.
- Start Netbeans and go to Tools -> Options -> C/C++.
- Click 'Add' under 'Tool Collection' and select the base directory of MinGW-W64 (C:\MinGW-W64\bin).
- Select 'MinGW' from 'Tool Collection Family' if it isn't auto-detected and click 'OK'.
- Set the 'C Compiler to C:\MinGW-W64\bin\x86_64-w64-mingw32-gcc.exe.
- Set the 'C++ Compiler to C:\MinGW-W64\bin\x86_64-w64-mingw32-g++.exe.
- Set the 'Make Command' to C:\MSys\msys\bin\make.exe.
And that should be it!
I should note that I am using the system to compile a library file to be use via JNI so have some additional steps for that which I missed out as they weren't needed here. However I made a quick 'Hello World' program and it compiled and ran nicely.
Happy coding!
Idov
Updated on June 04, 2022Comments
-
Idov almost 2 years
I'm trying to configure my NetBeans on win7 64bit, to work with the MinGW-w64.
So I put in the %PATH% variable the following paths of the compiler:
C:\mingw-w64-bin_i686\mingw\bin
C:\minGw-MSYS\msys\bin
C:\mingw-w64-bin_i686\libexec\gcc\x86_64-w64-mingw32\4.7.0Then I opened NetBeans and this was configured:
I tried to compile a little test program but I received this error:
g++.exe: fatal error: -fuse-linker-plugin, but liblto_plugin-0.dll not found compilation terminated. make[2]: * [dist/Debug/MinGW-Windows/test.exe] Error 1 make1: [.build-conf] Error 2 make: ** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 1s)
I do have this file in C:\mingw-w64-bin_i686\libexec\gcc\x86_64-w64-mingw32\4.7.0
what am I missing?
-
Idov over 12 yearshmmm... If i don't put "C:\minGw-MSYS\msys\bin" in the path, It doesn't find MKDIR. and I've seen an example in which they did change the names of the directories.
-
rubenvb over 12 yearsIdov: yes, sorry, that one is not what I meant. I meant for the toolchain (gcc, ld) only. Nothing under
mingw*/libexec
ormingw*/i686-w64-mingw32
should be in PATH if you can help it. -
Keugyeol almost 10 yearsVery helpful, thank you. One minor thing: it will be better to use EnvMan 1.4 if were to be used: env-man.blogspot.kr/…
-
RyanfaeScotland almost 10 yearsI think it is safe to assume you should use the latest version available for any software unless it explicitly states you have to use a specific version, I just happened to link to 1.3 as that is the one I knew about. Cheers for the update, have replaced the link completely.
-
Jerome almost 10 yearsEven though we supply the full paths to the toolchain in Netbeans, it is still mandatory to add the MinGW bin directory to your Windows path (as shown in this answer). The reason I think has to do with msys.
-
eeze almost 6 yearsCould you please link your blog?
-
RyanfaeScotland almost 6 yearsSure @eeze, here you go (although I never did write this up there, however this post describes the issues I was having that led me to the solution and there may be other posts of use on it: workingwithcomputervision.blogspot.com/2012/08/…)
-
Jafar Zuabi over 2 yearsThis was very helpful