Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. C++ error detected
Forum Updated to NodeBB v4.3 + New Features

C++ error detected

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
7 Posts 4 Posters 513 Views 1 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.
  • R Offline
    R Offline
    Ran_Flora
    wrote on 20 May 2024, 22:40 last edited by Ran_Flora
    #1

    I have installed qt creator on ubuntu 20.04 using those commands line :

    sudo apt install qtcreator
    
    sudo apt install qt5-default
    
    sudo apt install build-essential
    

    Every time i use c++ it make errors like for example when i create a plain c++ application from the beginning of this main code

    #include <iostream>
    
    int main()
    {
        std::cout << "Hello World!" << std::endl;
        return 0;
    }
    

    it give those error :

    /work/QT project/PlainCppApp/main.cpp:2: error: expected a type      
    /work/QT project/PlainCppApp/main.cpp:2: error: expected unqualified-id 
    /work/QT project/PlainCppApp/main.cpp:2: error: expected '}'   /usr/include/c++/9/ostream:42: to match this '{'
      /work/QT project/PlainCppApp/main.cpp:5: error: no member named 'cout' in namespace 'std'   
    

    I want to use c++ 17 because i have some library from this version i have to use, and i want gcc compiler but it always use clang
    Thank you in advance.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 21 May 2024, 06:09 last edited by
      #2

      Hi,

      Since you want to use the C++17 standard, did you request it ?
      Are you using qmake or cmake ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • R Offline
        R Offline
        Ran_Flora
        wrote on 21 May 2024, 07:22 last edited by
        #3

        Hi, I am using CMake but even if i choose qmake i have the same errors for that simple code and i didn't find how to request c++17 standard

        J 1 Reply Last reply 21 May 2024, 07:56
        0
        • R Ran_Flora
          21 May 2024, 07:22

          Hi, I am using CMake but even if i choose qmake i have the same errors for that simple code and i didn't find how to request c++17 standard

          J Offline
          J Offline
          JonB
          wrote on 21 May 2024, 07:56 last edited by
          #4

          @Ran_Flora
          qmake: CONFIG += c++1z
          camke: Not sure, seems to vary by compiler, e.g. for gcc see https://stackoverflow.com/a/77408925/489865 ?

          1 Reply Last reply
          0
          • C Online
            C Online
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on 21 May 2024, 08:05 last edited by
            #5

            What puzzles me is the error in line 2 - are you sure your system headers are correct and not screwed up somehow? This looks not like a problem with your code you are showing.

            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
            Visit the Qt Academy at https://academy.qt.io/catalog

            1 Reply Last reply
            0
            • R Offline
              R Offline
              Ran_Flora
              wrote on 21 May 2024, 08:19 last edited by
              #6

              I have create a new project and i capture all the steps and i change the standard to 17 in the cmake here are the captures and you can see those errors.

              Screenshot from 2024-05-21 09-07-05.png

              Screenshot from 2024-05-21 09-07-47.png
              Screenshot from 2024-05-21 09-07-58.png
              Screenshot from 2024-05-21 09-11-35.png

              Screenshot from 2024-05-21 09-11-55.png

              from the beginning is the qt5-default stable and the installation is right or not for ubuntu 20.04

              J 1 Reply Last reply 21 May 2024, 08:32
              0
              • R Ran_Flora
                21 May 2024, 08:19

                I have create a new project and i capture all the steps and i change the standard to 17 in the cmake here are the captures and you can see those errors.

                Screenshot from 2024-05-21 09-07-05.png

                Screenshot from 2024-05-21 09-07-47.png
                Screenshot from 2024-05-21 09-07-58.png
                Screenshot from 2024-05-21 09-11-35.png

                Screenshot from 2024-05-21 09-11-55.png

                from the beginning is the qt5-default stable and the installation is right or not for ubuntu 20.04

                J Offline
                J Offline
                JonB
                wrote on 21 May 2024, 08:32 last edited by
                #7

                @Ran_Flora
                As @Christian-Ehrlicher has said, the error message about "missing } for {" immediately after #include <iostream> makes it seem like that file (or something it includes) is somehow incorrect.....

                1 Reply Last reply
                0

                1/7

                20 May 2024, 22:40

                • Login

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