Netbeans and MinGW-w64

I am trying to configure my NetBeans on win7 64bit to work with MinGW-w64.
Therefore, I put% PATH% in the following compiler paths:
C: \ MinGW-w64-bin_i686 \ MinGW \ bin
C: \ MinGW-MSYS \ MSYS \ bin
C: \ MinGW-w64-bin_i686 \ libexec \ NKU \ x86_64-w64-mingw32 \ 4.7.0

Then I opened NetBeans and this was configured:

Configuration in NetBeans

I tried to compile a small test program, but I got this error:

g ++. exe: fatal error: -fuse-linker-plugin, but liblto_plugin-0.dll not found compilation completed. make [2]: * [dist / Debug / MinGW-Windows / test.exe] Error 1 make 1 : [.build-conf] Error 2: ** [.build-impl] Error 2

BUILD FAILED (output value 2, total time: 1 s)

I have this file in C: \ mingw-w64-bin_i686 \ libexec \ gcc \ x86_64-w64-mingw32 \ 4.7.0

What am I missing?

+4
source share
3 answers

Really, after months of putting this in, I finally sat down and did it. I will probably make a more detailed post on my blog with beautiful photos, but here's a cut-out SO version that we hope will be enough for you (and everyone else) to get started.

Prerequisites

Remove MinGW, MSYS and CMake if you have them and you can lose them (we will reinstall MinGW (obv.) And MSYS, but not CMake, because it does not seem necessary.)

  • Netbeans or other suitable IDE
  • 64-bit Windows.
  • EnvMan (optional, but convenient for managing Windows environment variables.)

Installation

MinGW-W64 C compiler and MSYS

Customization

  • Add 'C: \ MinGW-W64 \ bin' to the Windows PATH variable.
  • Add 'C: \ MSys \ msys \ bin' to the Windows PATH variable.
  • Launch Netbeans and go to Tools -> Options -> C / C ++.
    • Click "Add" to the "Tool Collection" and select the base directory MinGW-W64 (C: \ MinGW-W64 \ bin).
    • Select "MinGW" from the "Collection Collection Family" if it is not automatically detected and click "OK."
    • Install the C compiler in C: \ MinGW-W64 \ bin \ x86_64-w64-mingw32-gcc.exe.
    • Install the 'C ++ Compiler in C: \ MinGW-W64 \ bin \ x86_64-w64-mingw32-g ++. exe.
    • Install the Make Command command on C: \ MSys \ msys \ bin \ make.exe.

And it must be!

I should note that I use the system to compile the library file that will be used through JNI, so you have a few extra steps for what I skipped because they are not needed here. However, I did a quick Hello World program, and it compiled and worked out beautifully.

Happy coding!

+11
source

I just downloaded the latest automatic build , unpacked it, added the main bin directory to the path, and ran:

x86_64-w64-mingw32-gcc test.cpp -o test.exe 

and

 x86_64-w64-mingw32-gcc -fuse-linker-plugin test.cpp -o test.exe 

and it works. The same goes for the i686 variant. Your IDE is doing something wrong. Or you shouldn't have messed up the files. Or you should not remove prefixes. Really.

PS: you need to add the main "bin" directory to PATH, everything else is wrong.

0
source

When searching through your favorite search engine on the Internet, I came up with a better approach to quickly add MinGW-x64 to 64-bit Windows. At Sourceforge MSYS2 .

Following the installation instructions and getting the latest packages, there may be a timeout on the source mirror site Sourceforge. If so, follow the mirrored site updates and update the three pacman text files in the appropriate MSYS2 directory (for example, / etc / pacman.d). Then, proceed to complete the package upgrade from the MSYS2 installation instructions .

MSYS2 packages have things like gcc, llvm, make, dmake, etc. The following is a command used from the MSYS2 command line (for example, bash) to install the GNU make utility:

 $ pacman -S msys/make 

The location of the executable to be located will be: /usr/bin inside the MSYS2 command shell. As for setting up Netbeans for the location of make.exe, the path to Windows is:

 MSYS2 installation directory\usr\bin\make.exe 

(e.g. C:\msys64\usr\bin\make.exe ).

To successfully create C ++ with Netbeans, I used the GNU make package (e.g. msys / make). Then, in order to use the default files that Netbeans manages and not interfere with other C ++ compilers in your Windows installation (e.g. Visual Studio, Intel, CLang from Visual Studio, etc.), run Netbeans from the MinGW- shell x64 provided by MSYS2. So environment variables and other things like:

ls
rm
mkdir

will indicate success and compilation in the Netbeans internal terminal window. I opened the Win64 MinGW-w64 shell by going to the installed shortcut from the MSYS2 installation. Then inserted into the command line of the MinGW-x64 shell, the value of the Target property from the Windows Netbeans desktop shortcut:

 $ "C:\Program Files (x86)\NetBeans 7.4\bin\netbeans.exe" 

And then, finally, it can create the appropriate debug and release object and executable files. I also changed the output of the Netbeans project to the MSYS2 directory structure. Then run the executable file in the MSYS2 MinGW-x64 shell. Starting from NetBeans IDE causes this error message:

Unable to start pty process: application terminated with exit code -1073741515 (0xc0000135).

If the MSYS2 path was in the PATH environment variable of the computer system, this error may not have occurred.

0
source

Source: https://habr.com/ru/post/1385949/


All Articles