mingw32 problem mit c++11 option



  • Hi,

    ich verwende mingw32.
    leider weiss icht nicht warum die c++11 option im makefile nicht erkannt wird!?

    CC = g++
    CFLAGS = -g -Wall -std=c++11 -pthread
    DFLAGS = -DDEBUG
    LFLAGS = -Wall $(DEBUG) -lpthread
    LIBDIR =
    LIBS =
    SRC = main.cpp
    OBJ = main.o
    TARGET = main
    
    all: $(TARGET) $(OBJ)
    
    $(TARGET): $(OBJ)
    	$(CC) $(CFLAGS) $(DFLAGS) -o $@ $(OBJ) $(LFLAGS)
    # -L$(LIBDIR) $(LIBS)
    
    .c.o:
    	$(CC) $(CFLAGS) $(DFLAGS) -c $<
    
    clean:
    	rm -f $(OBJ) $(TARGET)
    

    problem hier:

    g++    -c -o main.o main.cpp
    In file included from c:\qt\qt5.1.1\tools\mingw48_32\lib\gcc\i686-w64-mingw32\4.
    8.0\include\c++\thread:35:0,
                     from main.cpp:7:
    c:\qt\qt5.1.1\tools\mingw48_32\lib\gcc\i686-w64-mingw32\4.8.0\include\c++\bits\c
    ++0x_warning.h:32:2: error: #error This file requires compiler and library suppo
    rt for the ISO C++ 2011 standard. This support is currently experimental, and mu
    st be enabled with the -std=c++11 or -std=gnu++11 compiler options.
     #error This file requires compiler and library support for the \
      ^
    <builtin>: recipe for target 'main.o' failed
    mingw32-make: *** [main.o] Error 1
    

    g++ version:

    C:\Users\Stanje\Desktop\parser\bare_metal>g++ -v
    Using built-in specs.
    COLLECT_GCC=g++
    COLLECT_LTO_WRAPPER=c:/qt/qt5.1.1/tools/mingw48_32/bin/../libexec/gcc/i686-w64-m
    ingw32/4.8.0/lto-wrapper.exe
    Target: i686-w64-mingw32
    Configured with: ../../../src/gcc-4.8.0/configure --host=i686-w64-mingw32 --buil
    d=i686-w64-mingw32 --target=i686-w64-mingw32 --prefix=/mingw32 --with-sysroot=/t
    emp/x32-480-posix-dwarf-r2/mingw32 --enable-shared --enable-static --disable-mul
    tilib --enable-languages=c,c++,fortran,lto --enable-libstdcxx-time=yes --enable-
    threads=posix --enable-libgomp --enable-lto --enable-graphite --enable-checking=
    release --enable-fully-dynamic-string --enable-version-specific-runtime-libs --d
    isable-sjlj-exceptions --with-dwarf2 --disable-isl-version-check --disable-cloog
    -version-check --disable-libstdcxx-pch --disable-libstdcxx-debug --disable-boots
    trap --disable-rpath --disable-win32-registry --disable-nls --disable-werror --d
    isable-symvers --with-gnu-as --with-gnu-ld --with-arch=i686 --with-tune=generic
    --with-host-libstdcxx='-static -lstdc++' --with-libiconv --with-system-zlib --wi
    th-gmp=/temp/mingw-prereq/i686-w64-mingw32-static --with-mpfr=/temp/mingw-prereq
    /i686-w64-mingw32-static --with-mpc=/temp/mingw-prereq/i686-w64-mingw32-static -
    -with-isl=/temp/mingw-prereq/i686-w64-mingw32-static --with-cloog=/temp/mingw-pr
    ereq/i686-w64-mingw32-static --enable-cloog-backend=isl --with-pkgversion='rev2,
     Built by MinGW-builds project' --with-bugurl=http://sourceforge.net/projects/mi
    ngwbuilds/ CFLAGS='-O2 -pipe -I/temp/x32-480-posix-dwarf-r2/libs/include -I/temp
    /mingw-prereq/x32-zlib/include -I/temp/mingw-prereq/i686-w64-mingw32-static/incl
    ude' CXXFLAGS='-O2 -pipe -I/temp/x32-480-posix-dwarf-r2/libs/include -I/temp/min
    gw-prereq/x32-zlib/include -I/temp/mingw-prereq/i686-w64-mingw32-static/include'
     CPPFLAGS= LDFLAGS='-pipe -L/temp/x32-480-posix-dwarf-r2/libs/lib -L/temp/mingw-
    prereq/x32-zlib/lib -L/temp/mingw-prereq/i686-w64-mingw32-static/lib -L/temp/x32
    -480-posix-dwarf-r2/mingw32/opt/lib'
    Thread model: posix
    gcc version 4.8.0 (rev2, Built by MinGW-builds project)
    


  • Wie hier steht https://www.gnu.org/software/make/manual/html_node/Implicit-Variables.html müsste es heissen:

    CXXFLAGS = -g -Wall -std=c++11 -pthread
    

    und das

    CC = g++
    

    nimm raus. Du willst ja nicht C mit dem g++ kompilieren.



  • ok danke! sonst noch verbesserungen zum makefile?

    CXX = g++
    CXXFLAGS = -g -Wall -std=c++11 -pthread
    DFLAGS = -DDEBUG
    LFLAGS = -Wall $(DEBUG) -lpthread
    LIBDIR =
    LIBS =
    SRC = main.cpp
    OBJ = main.o
    TARGET = main
    
    all: $(TARGET) $(OBJ)
    
    $(TARGET): $(OBJ)
    	$(CXX) $(CXXFLAGS) $(DFLAGS) -o $@ $(OBJ) $(LFLAGS) 
    #-L$(LIBDIR) $(LIBS)
    
    .c.o:
    	$(CXX) $(CXXFLAGS) $(DFLAGS) -c $<
    
    clean:
    	rm -f $(OBJ) $(TARGET)
    


  • Dieser Thread wurde von Moderator/in SeppJ aus dem Forum C++ (alle ISO-Standards) in das Forum Compiler- und IDE-Forum verschoben.

    Im Zweifelsfall bitte auch folgende Hinweise beachten:
    C/C++ Forum :: FAQ - Sonstiges :: Wohin mit meiner Frage?

    Dieses Posting wurde automatisch erzeugt.



  • ich hab noch ein problem mit dem threading support:

    g++ -g -Wall -std=c++11 -pthread -D_GLIBCXX_USE_NANOSLEEP -D_GLIBCXX_USE_SCHED_Y
    IELD   -c -o main.o main.cpp
    main.cpp: In member function 'void VirtualSampler::sample(Tree*)':
    main.cpp:272:9: error: 'std::this_thread' has not been declared
        std::this_thread::sleep_for(std::chrono::milliseconds(10));
             ^
    main.cpp: In function 'int main()':
    main.cpp:286:2: error: 'thread' is not a member of 'std'
      std::thread thread1(&VirtualSampler::sample, &s, &t);
      ^
    main.cpp:286:14: error: expected ';' before 'thread1'
      std::thread thread1(&VirtualSampler::sample, &s, &t);
                  ^
    main.cpp:287:2: error: 'thread1' was not declared in this scope
      thread1.join();
      ^
    
    Tree t;
    t.createTree();
    
    VirtualSampler s;
    
    std::thread thread1(&VirtualSampler::sample, &s, &t);
    thread1.join();
    

    hab g++ 4.8:

    $ g++ -v
    Using built-in specs.
    COLLECT_GCC=c:\mingw\bin\g++.exe
    COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/4.8.1/lto-wrapper.exe
    Target: mingw32
    Configured with: ../gcc-4.8.1/configure --prefix=/mingw --host=mingw32 --build=m
    ingw32 --without-pic --enable-shared --enable-static --with-gnu-ld --enable-lto
    --enable-libssp --disable-multilib --enable-languages=c,c++,fortran,objc,obj-c++
    ,ada --disable-sjlj-exceptions --with-dwarf2 --disable-win32-registry --enable-l
    ibstdcxx-debug --enable-version-specific-runtime-libs --with-gmp=/usr/src/pkg/gm
    p-5.1.2-1-mingw32-src/bld --with-mpc=/usr/src/pkg/mpc-1.0.1-1-mingw32-src/bld --
    with-mpfr= --with-system-zlib --with-gnu-as --enable-decimal-float=yes --enable-
    libgomp --enable-threads --with-libiconv-prefix=/mingw32 --with-libintl-prefix=/
    mingw --disable-bootstrap LDFLAGS=-s CFLAGS=-D_USE_32BIT_TIME_T
    Thread model: win32
    gcc version 4.8.1 (GCC)
    

Log in to reply