6

I've upgraded from Ubuntu 18.04 to 20.04 and besides some nasty grub issues most things worked out of the box. But my QtCreator (Qt Creator 4.11.0, Based on Qt 5.12.8 (GCC 9.3.0, 64 bit)) is facing problems recognizing included libraries. It's showing thousands of error messages in projects that have worked perfectly fine before the update. The error messages all look like linker error messages. Some examples:

 error: 'std::string' (aka 'int') is not a class, namespace, or enumeration
 error: no matching function for call to 'getline'
 error: member reference base type 'std::ifstream' (aka 'int') is not a structure or union
 error: no template named 'vector' in namespace 'std'
 error: unknown type name 'SystemCallFactory' //this class is from the same  project

And even some errors in the qt and std libraries:

/usr/include/x86_64-linux-gnu/qt5/QtCore/qstring.h:1374: passing argument to parameter 's' here 
/usr/include/c++/8/ostream:41: candidate found by name lookup is 'std'
  • The problem occurs in both cmake and qmake projects
  • I do have (and need) different gcc and g++ versions installed (9 and 8) (reinstalled both after the update as the update-alternatives settings were broken and one dependency was upgraded from 6 to 8)

When I create a new project in QtCreator without changing anything from the default code, it's the same:

/home/$me/src/untitled/main.cpp:7: error: variable has incomplete type 'QApplication'`
/home/$me/src/untitled/main.cpp:8: error: unknown type name 'MainWindow'

Installed compilers:

update-alternatives --display gcc
gcc - auto mode link best version is /usr/bin/gcc-8 link currently points to /usr/bin/gcc-8 link gcc is /usr/bin/gcc /usr/bin/gcc-8 - priority 30 /usr/bin/gcc-9 - priority 20

update-alternatives --display g++ g++ - auto mode link best version is /usr/bin/g++-8 link currently points to /usr/bin/g++-8 link g++ is /usr/bin/g++ /usr/bin/g++-8 - priority 30 /usr/bin/g++-9 - priority 20

I can still build all projects manually, again both cmake and qmake work here. Also, when I have a complete build in the build directory that's set in QtCreator, QtCreator will build my projects, even when I change something. It will still show the errors all over my code and in the issues section, but will build and run anyways, so the build commands should be fine. But when the build directory is empty, it will fail.
How can I approach this problem further?

1
  • I don't have a solution but switched to the QtUnified version that's provided on their homepage as an online installer from the Ubuntu repository one which worked. So I can't verify any potential upcoming solutions. May 6, 2020 at 9:59

3 Answers 3

9

Same issue here, same solution as @nou. QtCreator 4.11 still relies on clang-8, but on Ubuntu 20.04 apt will install clang-10. The following solved the problem for me:

Install clang 8

sudo apt install clang-8

Update the alternatives

sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-8 100
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-8 100

I had no need to re-install QtCreator.

6
+50

I am not 100% sure that this is same problem but I solved it by installing clang-8 package. I think problem is that qtcreator code model plugin use libclang1-8 but clang-10 get installed by default.

1
  • This solved it. Thank you! I accepted the other answer because it involves a full solution, but issued the bounty to you as you were the first to come up with a solution! May 11, 2020 at 15:55
2

It seems like Qt Creator 4.15.1 is again conflicting with it's default configured kits.

So I have made a custom one by:

  • I have installed clang 10 from ubuntu.
  • sudo apt install clang
  • tools>options>Kits>Kits
  • select the default Desktop QT 5.15.2 64 bit (default)
  • Press Clone button
  • In compiler section
  • For C : Clang 10(C, x86 64bit in /usr/bin)
  • For c++ Clang 10(C++, x86 64bit in /usr/bin)
  • (Image attached)

Using this kit cmake and Qmake is working and also missing stl and std paths are fixed.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.