How to declare identifier JSON in a C++ file? - c++

I got a c++ Project that correctly compiles on Windows.
Now I try to run it on my Mac.
I changed all paths to my Mac paths.
After "make" command I get this error message:
error: use of undeclared identifier 'Json'
Json::Reader reader;
Of course I included my header file containing #include <json.h>
Are there any necessary elements I missed?
Thanks for any ideas!!

There was a wrong linking of json_lib
Reinstalled and problem got solved.

Related

Atom searching in wrong directory for c++ file for compilation, does anyone know how to fix it?

I have just downloaded and tested the MinGW's c++ compiler. In the terminal it works fine. Then I went to atom, downloaded gpp-compiler and tried compiling the same document I had compiled in the terminal. On atom however, I got this message:
g++: error: /mnt/c/Users/phfer/Desktop/cpp/new.cpp: No such file or directory
g++: fatal error: no input files
compilation terminated.
As you can see, atom is searching for the file new.cpp in the directory /mnt/c/, instead of searching for it in C:\Users...
Does anyone know how to fix this?

internal error in mingw32_gt_pch_use_address, at config/i386/host-mingw32.c:190: MapViewOfFileEx: Attempt to access invalid address

internal error in mingw32_gt_pch_use_address, at config/i386/host-mingw32.c:190: MapViewOfFileEx: Attempt to access invalid address.
I get this error while compiling a c++ program in sublime-text 3.
How to resolve this error?
In my case, this problem is due to #include<bits/stdc++.h>. Comment this line and get #include <iostream> to solve the problem.
If you have precompiled <stdc++.h> then you have stdc++.h.gch file in this path (path could be different on basis of where you installed MinGW and version) :
C:\MinGW\lib\gcc\mingw32\9.2.0\include\c++\mingw32\bits
So to solve this problem delete stdc++.h.gch file and paste these two commands in your terminal :
Go to the path having your precompiled header in command line
cd C:\MinGW\lib\gcc\mingw32\9.2.0\include\c++\mingw32\bits
Precompile header (mine version is c++17)
g++ -std=c++17 stdc++.h
I have found this solution on a codechef discussion and it works for me.
I got this problem after installing CodeBlocks, maybe it is because of codeblocks MINGW settings. My initial MinGW is from DEV-C++.
So what I did is this.
1.Delete "C:\...\GnuWin" from PATH.
2.Ensure that you have your old path to your compiler. In my case it was "C:\...\DevCPP\Mingw\bin"
For me, this error popped up right after I updated my SublimeText application to the latest version, so just restarting the system worked for me!
I'm not sure what caused this problem today, but I have seen it a few times before.
For me, a full clean and recompile solves it.
I got this same problem after pre-compiling the stdc++.h file, to get rid of this error, I removed the compiled version of this header that is stdc++.gch.
File path of stdc++.h and stdc++.gch is
C:\Users\UserName\Downloads\MinGW\include\c++\9.2.0\x86_64-w64-mingw32\bits

Mosquitto.h not such file or directory

I am working on a c++ project using mosquitto library on github. I am trying to compile the C++ on a windows computer on the command line; however I keep getting error
Fatal error: mosquitto.h: no such file or directory
include "mosquitto.h"
I have installed the mosquitto library in the windows system, underneath:
C:\Program Files\mosquitto\devel\mosquitto.h
Is there something else that I have to do as well in order to compile the cpp from the command line. How do I tell g++ the whereabout of the mosquitto.h file. So I can compile on the command line
Thank for your help I am new to C++.
I managed to solve this question, I had o copy the mosquitto.h into
C:\cygwin64\usr\include
Then when I type g++ nameOfFile it compiled

Type 'FILE' has not been declared jpeglib.h

Im using eclipse neon2, Windows 10 and i have compiled jpeglib as following the instructions ( using MinGW) (first answer):
Compiling libjpeg
But in my program after compiling and building im facing this error:
Description Resource Path Location Type 'FILE' has not been
declared MyBilliards line 974, external location:
c:\mingw\include\jpeglib.h C/C++ Problem
Description Resource Path Location Type 'FILE' has not been
declared MyBilliards line 975, external location:
c:\mingw\include\jpeglib.h C/C++ Problem
But if i skip and launch the project with these errors, it seems to work fine...
Also if someone has a tutorial how to make mingw and jpeglib work in eclipse and windows10 would be great.
Thanks
Well if someone has the same problem i solved it including stdio.h BEFORE jpeglib.h ( which is strange as in the main.cpp i didnt get any dependency or syntax error). Then clean project and then Build All....
So
#include<stdio.h>
#include<jpeglib.h>

While Compiling "strlcpy.h" is not found

I'm trying to compile C++ Code using g++ and using the CERN ROOT Framework. I've got the folowing error message, while compiling.
In file included from /usr/include/root/TObject.h:31:0,
from /usr/include/root/TNamed.h:26,
from /usr/include/root/TDirectory.h:25,
from /usr/include/root/TDirectoryFile.h:25,
from /usr/include/root/TFile.h:25,
from neutralino_root.cpp:13:
/usr/include/root/Rtypes.h:36:68: fatal error: strlcpy.h: No such file or directory
#include <strlcpy.h> // part of string.h on systems that have it
^
compilation terminated.
Has anyone an idea, why "strlcpy.h" is not found?
Thanks for help,
Simon