C++ error detected
-
wrote on 20 May 2024, 22:40 last edited by Ran_Flora
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. -
Hi,
Since you want to use the C++17 standard, did you request it ?
Are you using qmake or cmake ? -
wrote on 21 May 2024, 07:22 last edited by
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
-
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
wrote on 21 May 2024, 07:56 last edited by@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 ? -
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.
-
wrote on 21 May 2024, 08:19 last edited by
-
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.
from the beginning is the qt5-default stable and the installation is right or not for ubuntu 20.04
wrote on 21 May 2024, 08:32 last edited by@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/7