Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. compile c++11 file in qtcreator? problem with g++
Forum Updated to NodeBB v4.3 + New Features

compile c++11 file in qtcreator? problem with g++

Scheduled Pinned Locked Moved Solved General and Desktop
15 Posts 5 Posters 6.3k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mrjj
    Lifetime Qt Champion
    wrote on 14 Jun 2016, 13:13 last edited by
    #4

    hi
    can you try with
    QMAKE_CXXFLAGS += -std=c++11

    Q 1 Reply Last reply 14 Jun 2016, 13:20
    0
    • Q qtpi
      14 Jun 2016, 12:31

      hey folks. the problem is as described in title. I added the CONFIG += C++11 in the .pro file. and it still cannot compile the file with c++11.
      I am not sure if there is problem with gcc cause when I checked the qmake command in the project option, it shows: qmake xxx.pro -r -spec linux-g++
      and my gcc is 4.9.2 so I think it is new enough to recognize c++11.
      my qt version is 5.3.2.

      what could be the problem?
      Thanks in advance!

      M Offline
      M Offline
      micland
      wrote on 14 Jun 2016, 13:17 last edited by
      #5

      @qtpi said:

      hey folks. the problem is as described in title. I added the CONFIG += C++11 in the .pro file. and it still cannot compile the file with c++11.

      I'm not sure if the config values are case sensitive but I always used CONFIG += c++11 (with a lower cased C) which worked for me... give it a try?

      Q 1 Reply Last reply 14 Jun 2016, 13:21
      1
      • M mrjj
        14 Jun 2016, 13:13

        hi
        can you try with
        QMAKE_CXXFLAGS += -std=c++11

        Q Offline
        Q Offline
        qtpi
        wrote on 14 Jun 2016, 13:20 last edited by
        #6

        @mrjj

        hi. actually both configurations are in my .pro file. still shows it's c++98 mode. -.-

        1 Reply Last reply
        0
        • M micland
          14 Jun 2016, 13:17

          @qtpi said:

          hey folks. the problem is as described in title. I added the CONFIG += C++11 in the .pro file. and it still cannot compile the file with c++11.

          I'm not sure if the config values are case sensitive but I always used CONFIG += c++11 (with a lower cased C) which worked for me... give it a try?

          Q Offline
          Q Offline
          qtpi
          wrote on 14 Jun 2016, 13:21 last edited by
          #7

          @micland thanks for the help. actually I tried these 2 different cases already. seems still not working.

          1 Reply Last reply
          0
          • ? Offline
            ? Offline
            A Former User
            wrote on 14 Jun 2016, 15:28 last edited by
            #8

            Did you try to manually clean the project and run qmake again?

            Q 2 Replies Last reply 14 Jun 2016, 17:11
            0
            • ? A Former User
              14 Jun 2016, 15:28

              Did you try to manually clean the project and run qmake again?

              Q Offline
              Q Offline
              qtpi
              wrote on 14 Jun 2016, 17:11 last edited by
              #9

              @Wieland that's a option. I will try to do it tmr.

              M 1 Reply Last reply 14 Jun 2016, 19:18
              0
              • Q qtpi
                14 Jun 2016, 17:11

                @Wieland that's a option. I will try to do it tmr.

                M Offline
                M Offline
                medyakovvit
                wrote on 14 Jun 2016, 19:18 last edited by
                #10

                @qtpi
                Another places to check:
                Check that you use correct gcc. There are a few versions of gcc can be installed. For example, i have gcc-4.8, gcc-4.9 and gcc-5. You can choose version to use with simple "gcc"(without mentioning any version) through
                update-alternatives.

                Another option, if you use Qt Creator you can manually compiler in Options->Build&Run in Compilers tab. In Compiler path you can point to concrete version, for example /usr/bin/g++-5.

                Also, you can check compiler version and c++ standart at runtime, with:

                std::cout << __GNUC__ << "." << __GNUC_MINOR__ << "." << __GNUC_PATCHLEVEL__ << std::endl;
                std::cout << __cplusplus << std::endl;
                

                Here you can find values returned by __cplusplus macro

                Q 1 Reply Last reply 15 Jun 2016, 09:31
                2
                • M medyakovvit
                  14 Jun 2016, 19:18

                  @qtpi
                  Another places to check:
                  Check that you use correct gcc. There are a few versions of gcc can be installed. For example, i have gcc-4.8, gcc-4.9 and gcc-5. You can choose version to use with simple "gcc"(without mentioning any version) through
                  update-alternatives.

                  Another option, if you use Qt Creator you can manually compiler in Options->Build&Run in Compilers tab. In Compiler path you can point to concrete version, for example /usr/bin/g++-5.

                  Also, you can check compiler version and c++ standart at runtime, with:

                  std::cout << __GNUC__ << "." << __GNUC_MINOR__ << "." << __GNUC_PATCHLEVEL__ << std::endl;
                  std::cout << __cplusplus << std::endl;
                  

                  Here you can find values returned by __cplusplus macro

                  Q Offline
                  Q Offline
                  qtpi
                  wrote on 15 Jun 2016, 09:31 last edited by
                  #11

                  @medyakovvit
                  hi. thanks for the help. the gcc is 4.9 and the macro __cplusplus shows 199711.

                  -.- this is rly weird.

                  M 1 Reply Last reply 15 Jun 2016, 09:38
                  0
                  • ? A Former User
                    14 Jun 2016, 15:28

                    Did you try to manually clean the project and run qmake again?

                    Q Offline
                    Q Offline
                    qtpi
                    wrote on 15 Jun 2016, 09:31 last edited by
                    #12

                    @Wieland I tried it and it still not working...-.-

                    1 Reply Last reply
                    0
                    • Q Offline
                      Q Offline
                      qtpi
                      wrote on 15 Jun 2016, 09:38 last edited by qtpi
                      #13

                      update: I just solved the problem. I have included my source .pro as a sub .pro file in another .pro file: mySoftware.pro and I only changed the setting in mySoftware.pro.

                      After I changed the setting in the source.pro, everything works.

                      1 Reply Last reply
                      0
                      • Q qtpi
                        15 Jun 2016, 09:31

                        @medyakovvit
                        hi. thanks for the help. the gcc is 4.9 and the macro __cplusplus shows 199711.

                        -.- this is rly weird.

                        M Offline
                        M Offline
                        medyakovvit
                        wrote on 15 Jun 2016, 09:38 last edited by
                        #14

                        @qtpi
                        You tried to run this code:

                        std::cout << __GNUC__ << "." << __GNUC_MINOR__ << "." << __GNUC_PATCHLEVEL__ << std::endl;
                        std::cout << __cplusplus << std::endl;
                        

                        or you just look at cpluplus value from prompt?

                        Q 1 Reply Last reply 15 Jun 2016, 09:43
                        0
                        • M medyakovvit
                          15 Jun 2016, 09:38

                          @qtpi
                          You tried to run this code:

                          std::cout << __GNUC__ << "." << __GNUC_MINOR__ << "." << __GNUC_PATCHLEVEL__ << std::endl;
                          std::cout << __cplusplus << std::endl;
                          

                          or you just look at cpluplus value from prompt?

                          Q Offline
                          Q Offline
                          qtpi
                          wrote on 15 Jun 2016, 09:43 last edited by
                          #15

                          @medyakovvit said:

                          I dont have the macro GNUC_PATCHLEVEL . So i only tried to check GNU MINOR and cplusplus.
                          but the problem is solved, it seems if the pro file is placed on each other. it might be sometimes problematic with this setting.

                          1 Reply Last reply
                          0

                          13/15

                          15 Jun 2016, 09:38

                          • Login

                          • Login or register to search.
                          13 out of 15
                          • First post
                            13/15
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • Users
                          • Groups
                          • Search
                          • Get Qt Extensions
                          • Unsolved