This forum has been archived. All content is frozen. Please use KDE Discuss instead.

No member named 'string' in namespace 'std'

Tags: None
(comma "," separated)
User avatar
jeanv
Registered Member
Posts
10
Karma
0
I want to use KDevelop for C++ but I keep having these problems with the parser that won't find some includes or sometimes will find them but won't recognize it if I use a class from them.

Examples:
Code: Select all
#include <string>
using std::string;
Hovering over std::string gives me: no member named 'string' in namespace 'std'
Code: Select all
#include <stdint.h>
struct Pixel {
   uint8_t r;
   uint8_t g;
   uint8_t b;
};
Hovering over uint8_t: Unknown type name 'uint8_t'.

In Open configuration > Language support, I tried to add /usr/include/c++/5. Doing that, I can hover over #include <string> and have the correct infos, but I still get the errors with using std::string (or declaring an std::string variable).
This is a CMake project, here is my CMakeLists.txt if that's relevant, it's quite basic:
Code: Select all
cmake_minimum_required(VERSION 3.5)

add_library(stdc++fs UNKNOWN IMPORTED)
set_property(TARGET stdc++fs PROPERTY IMPORTED_LOCATION "/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++fs.a")

add_executable(clear clear.cpp sense_hat.cpp)
target_compile_features(clear PRIVATE cxx_auto_type)
target_link_libraries(clear stdc++fs)

Interestingly, with the exact same project that I imported from Qt Creator, KDevelop seems to find all the includes on its own.

I don't really want to go back to Qt Creator, but at least it works...
User avatar
scummos
Global Moderator
Posts
1175
Karma
7
OS
Hello!

Did you import your project in KDevelop as a cmake project? Make sure you did that -- otherwise KDevelop can't figure out the include paths. Try closing the project, then use Open/Import project again and make sure "CMake project manager" is selected.

Greetings,
Sven


I'm working on the KDevelop IDE.
User avatar
jeanv
Registered Member
Posts
10
Karma
0
Thank you for your help. I did import the project with Open / Import. Just to be sure, I retried closing and reimporting with CMake project manager but the problem is still here.

EDIT: Here is a test I just did:
Create a new project > Project type: Terminal CMake C++ > Finish > Leave everything default in the CMake configuration windows that appear > OK.
In this new hello world project, KDevelop can't find #include <iostream>.
User avatar
jeanv
Registered Member
Posts
10
Karma
0
I've seen a similar problem here and here with no solution. I'll go back to Qt Creator for now unfortunately.
User avatar
scummos
Global Moderator
Posts
1175
Karma
7
OS
This was broken starting from clang 5.0 and it is fixed with current master. You can either use kdevelop from the 5.2 or master branch, or download the AppImage from kdevelop.org/download which ships a version of clang it works with properly, in case you want to go back to KDevelop.


I'm working on the KDevelop IDE.
User avatar
scummos
Global Moderator
Posts
1175
Karma
7
OS
On second thought, maybe this is a different issue from what was fixed recently ... I'm not sure. Which version of KDevelop do you use, and where from? Did you try with the AppImage?


I'm working on the KDevelop IDE.
Xorlium
Registered Member
Posts
17
Karma
0
OS
I have the same problem under chakra linux, since kdevelop 5.2. clang version is 4.0.1. I see that kdevelop doesn't find my includes, like #include <iostream> or #include <string>. If I point kdevelop to /usr/include/c++/6.3.1/ for example, I see the files, but still std::string or std::cout or whatever doesn't work.
User avatar
scummos
Global Moderator
Posts
1175
Karma
7
OS
Can you go to your project settings, and under Language support -> C/C++ Parser select a different value in the "Compiler for path" combobox? Does that change anything?


I'm working on the KDevelop IDE.
Xorlium
Registered Member
Posts
17
Karma
0
OS
Yep, that worked! Changing clang for GCC worked.

Thanks!
User avatar
scummos
Global Moderator
Posts
1175
Karma
7
OS
Sorry, does it work with "clang" selected or with "gcc" selected? Just to be sure.


I'm working on the KDevelop IDE.
Xorlium
Registered Member
Posts
17
Karma
0
OS
It works with GCC selected.


Bookmarks



Who is online

Registered users: Bing [Bot], daret, Google [Bot], Sogou [Bot]