MinGW completely bugged on NetBeans

前端 未结 2 1395
耶瑟儿~
耶瑟儿~ 2021-01-26 04:52

The following code shoudn\'t produce an error:

    #include 
    #include 
    #include 

    using namespace std ;
         


        
相关标签:
2条回答
  • 2021-01-26 05:34

    I recommend using MinGW Distro if you want to develop C++ under a Microsoft Windows operating system. It ships with a pretty new GCC version and with the Boost libraries.

    NetBeans IDE is pretty picky regarding the build environment settings. E.g. It doesn't work together with all versions of make (we have to distinct make.exe from MSYS and mingw32-make.exe from MinGW for example) and there are problems regarding the used Java Runtime Enviroment (JRE).

    With the settings shown in the following screenshot you should be able to build your example with MinGW Distro and NetBeans 8. I recommend to not configure a absolute path to the make.exe file but add that path to your Microsoft Windows environment variable PATH. Otherwise you may get build errors.

    MinGW Build Tools Settings in NetBeans IDE 8.0

    Maybe these two blog posts help if you want to use the "default" MinGW distribution:

    1. Installing Minimum GNU for Windows (MinGW)
    2. Configure NetBeans IDE for Minimum GNU for Windows (MinGW)

    I hope this helps others as well.


    Not related to your question: Don't use using namespace std:

    #include <iostream>
    
    int main(int argc, char** argv) {
      int n;
      std::cin >> n;
      std::cout << n;
    
      return 0;
    }
    
    0 讨论(0)
  • 2021-01-26 05:52

    I ran into this same issue (with exit code -1,073,741,511), so though a dated question, I'm posting this here for anyone else who runs into the problem.

    1. Run the executable for the program manually. You might get an error such as "the procedure entry point __gx_personality_v0 coud not be located in the dynamic library libstdc++-6.dll". (OP has confirmed this in a comment.)
    2. The .dll file referred to in the error message above is either not being linked, or linked incorrectly. The correct version of the .dll that needs to be linked is the one in the ...\MinGW\bin directory. In Windows, you can check the .dll file being linked by typing where libstdc++-6.dll in a command prompt; the first result that is listed will be the file that is linked. If you already see ...\MinGW\bin\libstdc++-6.dll as the first result here, my fix below will not help you.
    3. If you see a message "INFO: Could not find files for the given pattern(s).", then ...\MinGW\bin needs to be added to your %PATH% variable. (OP has already confirmed this was not the issue.)
    4. The issue I was having was that a program I had installed had its own (likely outdated) version of libstdc++-6.dll, which was in a folder also included in my %PATH% variable, ahead of ...\MinGW\bin. This meant that this other .dll file was being picked up and linked to during execution. This can be fixed by editing your %PATH% variable to make sure the ...\MinGW\bin entry is ahead of all other directories that also have a version of the .dll file.

    Edit: The other option is to statically link the .dll at program compilation, or place a copy of the correct .dll in the program executable directory. However, neither of these fixes is 'global', and needs to be done for each project individually.

    Hope this helps!

    0 讨论(0)
提交回复
热议问题