Thread: Problems compiling c++11

  1. #1
    Registered User
    Join Date
    May 2008
    Posts
    115

    Problems compiling c++11

    Dear all

    I wanted to check out the <random> library for the upcoming simulation project, but I get an error compiling this simple program taken from the very entertaining video by Stephan T. Lavavej. I cannot get C11 to work.

    Code:
    #include <iostream>
    #include <random>
    
    int main ( ) {
    	std::mt19937 mt( 1729 );
    	std::uniform_int_distribution<int> dist( 0 , 99 );
    	for ( int i = 1; i < 16; i++ ) {
    		std::cout << dist( mt ) << " ";
    	}
    	std::cout << std::endl;
    }
    Here is my make file:
    Code:
    BIN = myrand
    
    SRC = myrand.cpp
    OBJ = $(SRC:src/%.cpp=obj/%.o)
    
    CXX = g++
    
    CXXFLAGS = -std=c++0x
    CXXFLAGS += -Wall -Wextra
    
    .PHONY: all clean run
    
    all: $(BIN)
    
    $(BIN): $(SRC) 
    	$(CXX) $(CXXFLAGS) $(SRC) -o $(BIN)
    
    clean:
    	rm -f $(BIN)
    	rm -rf obj
    	
    run:
    	touch $(SRC)
    	make
    	./$(BIN)
    Compiler version:
    Code:
    g++ (GCC) 4.4.7 20120313 (Red Hat 4.4.7-11)
    Appreciate any help!

    Best wishes
    Serge

  2. #2
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    I suggest verifying that the Compiler you are using supports c++11
    If yes; then, I suggest finding the option needed to enable support of c++11.

    Edit: My guess was wrong; it has partial support.
    https://gcc.gnu.org/gcc-4.4/cxx0x_status.html

    I do NOT know whether it supports what you are trying to do; I have no idea which C++11 feature you are trying is in the URL link list I added.

    Tim S.
    Last edited by stahta01; 03-10-2015 at 06:57 AM.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  3. #3
    Registered User
    Join Date
    May 2008
    Posts
    115
    Quote Originally Posted by stahta01 View Post
    I suggest verifying that the Compiler you are using supports c++11
    If yes; then, I suggest finding the option needed to enable support of c++11.

    I would guess that GCC 4.4 likely does NOT support c++11.

    Tim S.
    Yes Tim, just figured that out myself (after looking at the https://gcc.gnu.org/projects/cxx0x.html ). Sorry for wasting everyone's time! Have a nice day. S

  4. #4
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    What version of RedHat/Fedora are you running?
    What can this strange device be?
    When I touch it, it gives forth a sound
    It's got wires that vibrate and give music
    What can this thing be that I found?

  5. #5
    Registered User
    Join Date
    May 2008
    Posts
    115
    Quote Originally Posted by Elkvis View Post
    What version of RedHat/Fedora are you running?
    Code:
    Red Hat Enterprise Linux Server release 6.6 (Santiago)

  6. #6
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    That's unfortunate. RedHat tends to be very, very slow to adopt updated versions of GCC. I understand that it's for the sake of security and stability, but it can be incredibly inconvenient for developers. Your only options will probably be to put up with the limited functionality of GCC 4.4, or build your own GCC, of a newer version, from source.
    What can this strange device be?
    When I touch it, it gives forth a sound
    It's got wires that vibrate and give music
    What can this thing be that I found?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Some Compiling Problems
    By mattnp12 in forum C Programming
    Replies: 9
    Last Post: 05-26-2010, 10:31 PM
  2. problems compiling in gcc
    By ra_mer in forum C Programming
    Replies: 6
    Last Post: 09-04-2006, 09:13 PM
  3. problems compiling
    By dnr72 in forum C Programming
    Replies: 3
    Last Post: 01-17-2005, 04:29 PM
  4. --> Compiling Problems -->
    By j0hnb1ank in forum C Programming
    Replies: 1
    Last Post: 01-28-2003, 06:41 AM
  5. Compiling Problems...
    By Hydro in forum C++ Programming
    Replies: 2
    Last Post: 01-23-2002, 06:49 PM