Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Unresolved methods from included hpp file
Unresolved methods from included hpp file [message #1785079] Mon, 09 April 2018 08:44 Go to next message
Anne Vleeshouwers is currently offline Anne VleeshouwersFriend
Messages: 2
Registered: April 2018
Junior Member
I have been trying to work with the nlohmann/json library/project. (I would ling the url but I can't because this is my first post here)
For testing this library I made a new c++ project with my main.cpp and the json.hpp file in the root folder of the project.
But every json method (json::to_cbor(j) and j.size()) in this file is marked as unresolved.
#include "json.hpp"
#include <iostream>
using json = nlohmann::json;
int main(){

	json j = {1,2,3};
	json::to_cbor(j);
	std::cout << j.size() << "+" << j;

}


The project does build though (and runs correctly).
make all 
Building file: ../main.cpp
Invoking: GCC C++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -std=c++11 -MMD -MP -MF"main.d" -MT"main.d" -o "main.o" "../main.cpp"
Finished building: ../main.cpp
 
Building target: JSONTest
Invoking: GCC C++ Linker
g++  -o "JSONTest"  ./main.o   
Finished building target: JSONTest


I rebuild and re-indexed the project and restarted eclipse but all methods are still marked as unresolved.

The only thing I changed is adding the -std=c++11 flag for it to be able to compile.

In the github project someone else also posted the issue but it could not be reproduced by other users so it was marked closed and implied that it was an Eclipse issue. So now I'm asking here: Is there a way to index this file to be able to autocomplete and resolve the methods?

Re: Unresolved methods from included hpp file [message #1786054 is a reply to message #1785079] Wed, 25 April 2018 00:06 Go to previous messageGo to next message
Andrey Sotnikov is currently offline Andrey SotnikovFriend
Messages: 21
Registered: October 2014
Junior Member
It's normal. I've never seen the CDT indexer working properly. I see this any many other issues in my project all the time. There is no helpful diagnostic, posting here and filing bugs is useless. The only way is to install Eclipse for Committers and debug issues in the CDT indexer yourself.
Re: Unresolved methods from included hpp file [message #1786061 is a reply to message #1786054] Wed, 25 April 2018 04:15 Go to previous messageGo to next message
David VavraFriend
Messages: 805
Registered: October 2012
Senior Member
Works for me.
I cloned the github entries to /home/dvavra/proj/json.
Then added -I/home/dvavra/proj/json/include
I also placed a link to json.hpp in my project source.
Otherwise, i would have had to include "nlohmann/json.hpp" (as shown)
instead of simply "json.hpp"

After the first build it showed up in
Project --> Properties --> C/C++ General --> Preprocessor Include Paths, Macros etc. --> Entries tab --> CDT Managed Build Settings Entries
index.php/fa/32680/0/
If you want the indexer to work before any builds then add <path to git clone>/include as a User Entry.
index.php/fa/32679/0/


FWIW: I created the project with
File --> New --> C++ Project --> Hello World C++ Project


[Updated on: Wed, 25 April 2018 06:12]

Report message to a moderator

Re: Unresolved methods from included hpp file [message #1786066 is a reply to message #1786061] Wed, 25 April 2018 06:59 Go to previous message
Anne Vleeshouwers is currently offline Anne VleeshouwersFriend
Messages: 2
Registered: April 2018
Junior Member
That worked thanks. I also had to set the flag -std=c++0x to my cross compiler options. Thanks for the help!
Previous Topic:Eye detection using Haar cascades in c++
Next Topic:My plugin can't add to menu when right-clicking the editor
Goto Forum:
  


Current Time: Sun Nov 18 08:35:48 GMT 2018

Powered by FUDForum. Page generated in 0.02573 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top