playing with GCC 4.6 on windows

2020-05-25 18:05发布

I am very pleased to find out that GCC 4.6 supports the range-based for loop. I found an experimental release of MinGW 4.6 on xvidvideo.ru, is that a well-known, reliable website? What other options do I have (besides compiling myself from source code)?

标签: c++ gcc g++ mingw
2条回答
姐就是有狂的资本
2楼-- · 2020-05-25 18:15

I wanted to try out GCC 4.7 using the latest Code::Blocks under Windows 7.

Here's how I did it for myself, YMMV:

  1. I downloaded the latest Equation GCC file at: ftp://ftp.equation.com/gcc/ and installed it under the directory C:\gcc\ on my local machine. The installer makes the necessary changes to the path environment variable. Logging off and on will pick them up.

  2. I downloaded the Code::Blocks latest nightly build at: http://forums.codeblocks.org/index.php?board=20.0 and followed the setup instructions.

  3. After following the setup instructions (including about the needed DLL files), and starting C::B for the first time;

    I chose 'GNU GCC Compiler', and 'Set as default' for the 'Compilers auto-detection' window.

    Under the 'Settings > Compiler... > Compiler settings' tab: I ticked the 'Have g++ follow the coming C++0x ISO C++ language standard [-std=c++0x]' checkbox on.

    Under the 'Settings > Compiler... > Toolchain executables' tab: I changed the 'Compiler's installation directory' entry field to C:\gcc\bin\.

  4. I changed the names of these files physically located in the C:\gcc\bin\ directory

    i686-pc-mingw32-gcc.exe  -=to=-  mingw32-gcc.exe
    
    i686-pc-mingw32-g++.exe  -=to=-  mingw32-g++.exe
    
    make.exe                 -=to=-  mingw32-make.exe
    

    to match the listed name requirements in Code::Blocks. You can simply browse to set the correct files (I just personally preferred renaming to match C::B's entries).

If everything went correctly, you should be able to create this program:

#include <iostream>
#include <vector>

int main() {
    using namespace std;

    vector<int> my_vec = { 1, 2, 3, 4, 5 };
    for (auto x : my_vec) {
        cout << x << endl;
    }
}

and run it OK under Code::Blocks with F9.

Thanks to everyone for all the excellent work put into bringing this great new language to us. Happy C++0x computing!

Bud Alverson (sorry for the very basic nature of this post) :)

查看更多
啃猪蹄的小仙女
3楼-- · 2020-05-25 18:29

I'm not really familiar with the site you linked as it's in Russian. The only other place I've found that offers current snapshots of GCC's build is from Equation Solution. I downloaded gcc4.5.1 from there and it's been working fairly well for me. I haven't tried the 4.6.x release yet however. Rumor has it that gcc 4.6.x is slower than its predecessors.

Please do report back what kind of results you're seeing if you do decide experimenting. I'm curious about what improvements they've done in the 4.6.x series.

查看更多
登录 后发表回答