How to solve Unresolved inclusion: <iostream> in eclipse? - c++

I built a simple program in eclipse:
#include <iostream>
using namespace std;
int main()
{
cout << "TEST" << endl;
return 0;
}
It worked in Visual Studio and CodeBlocks, but eclipse is acting weird. it says:
Unresolved inclusion: <iostream>
I read here:
C++ - Unresolved inclusion: <iostream>
and here: Unresolved <iostream> in Eclipse, Ubuntu
and neither of them worked.
Here are screenshots of project properties:
edit:
I downloaded MinGW and now i have this under Settings:
How should i proceed?
Maybe now i don't need #include <iostream> because it's now included in the project?
I found iostream under Includes.
So i tried deleting #include <iostream>, but when i try to run the program i get:
Launch Failed. Binary not found. error:
Thanks
edit:
Seems like if i compile in some other program (say CodeBlocks) and create the exe file, then eclipse can run it. But it can't build its own exe.
Why?

This answer did not help me either. My issue was solved with the following steps:
You might try changing your source files from *.c to *.cpp. This will provoke gcc to think of the files as C++ and search the proper paths. Might need to make small modifications to the Makefile as well, like on the OBJ: line. Instead of:
OBJS = YourFile.o
try
OBJS = YourFile.cpp

I've searched for a few hours and tried a lot solutions.
Envirment: windows, Eclipse IDE for C/C++ Developers
Version: Kepler Service Release 2
CDT: 8.3.0
Following steps works for me:
make sure the envirement is clear. => I suggest delete the eclipse and unzip it again from your orginal download.
make sure the workspace is clear. => Delete .metadata folder in your workspace folder.
use valid MinGW. => the one using download tool is slow and I'm not sure which one to select. I suggest download MinGWStudio from http://vaultec.mbnet.fi/mingwstudio.php
This is a IDE tool like eclipse contains a downloaded unzip MinGW. Make sure you download the one plus MinGW compiler which is about 20M. You can use this studio if you want or copy the MinGW folder to C:/ if you still prefer eclipse. Copy /MinGW inside /MinGWStudio to C:/.
close your eclipse and reopen it, create a new project, you should able to see MinGW section for new project option, and it will auto map g++, gcc and include files under C:/MinGW folder. Just make sure you copy MinGW folder from MinGWStudio to the root of C:/.
You will able to see your include after these steps.
includes_screen_cast

right click your project click properties goto C/C++ Build > settings click on Misc. under GCC C++ Compiler and the other flags code should have this after it -std=c++11 then go to Misc. under GCC C Compiler and add this to the other flags code -std=gnu11 apply save your project build your project and it should work

Related

wxWidgets with MinGW, "wx/wx.h: No such file or directory"

I am new to C++ and wxWidgets. During the last couple of days, I have followed a tutorial with Visual Studio into how to build wxWidgets desktop applications (https://www.youtube.com/watch?v=FOIbK4bJKS8&t=800s).
Now, because I am not familiar with Visual Studio, I wanted to move to edit the code with Atom and compile with MinGW from Windows command prompt.
The app has the following files:
cMake.h
AnalogRead.h
cMake.cpp
AnalogRead.cpp
In Visual Studio, you need to include two directories and one library in the project, which are the following:
Paths:
/wxWidgets/include
/wxWidgets/include/msvc
Libraries:
/wxWidgets/lib/vc_lib
Relative to the path where the the C++ code is.
So I have tried to create the compile line, without success:
c++ -I/wxWidgets/include -I/wxWidgets/include/msvc -L/wxWidgets/lib/vc_lib cMake.cpp AnalogRead.cpp -o test
But I get the following error:
In file included from AnalogRead.cpp:1:0:
AnalogRead.h:3:19: fatal error: wx/wx.h: No such file or directory
#include <wx/wx.h>
^
compilation terminated.
The thing is, I am including that path in the compilation. wx/wx.h is inside the path /wxWidgets/include/.
Is there a way to fix this? Thanks in advance.
You can't compile the library with one compiler and then compile the application using it with another, this is just not going to work. You should decide which compiler you want to use (or maybe try using both of them, but not both at the same time!) and follow the official build instructions in the file docs/msw/install.md.
/wxWidgets/include is not a relative path. This is an absolute path in the current disk. Do you have C:\wxWidgets\include? Try -IwxWidgets/include or -I./wxWidgets/include, without the leading /. This path should work if you have the wxWidgets directory in your app sources.
If you want to use MinGW, you need to build the library with MinGW compiler and then use EXACTLY THE SAME command to buid your software.
Or use an IDE (CodeBlocks, CodeLite).
HTH.

Problem to run a plugin to gcc in Windows 10

Im working in Windows 10 OS. I want to run a simple gcc plugin, so first i installed Mingw. Then I compile a simple hellowrd.c and works fine. But when I tried to simulate a plugin that uses "gcc-pugin.h" include, an error ocurrs because gcc-plugin.h "no such file or directory".
Apparently the mingw installation did not install everything I need.
Is it a problem that Windows does not work?
#include "gcc-plugin.h"
#include "plugin-version.h"
...
That means wherever that header file is, it was not found in the default include directory. You can try typing the full path to the .h file in the #include directive.

What causes the Eclipse CDT Unresolved inclusion: <iostream>

Just installed the latest Eclipse IDE and am following the included C++ User Guide right from 'Before you begin' section.
The simple application was successfully completed but once I got to the makefile project and the C++ file tutorials, I got the "Unresolved inclusion: <iostream>" error and a bunch of others related to "cout, cin, endl" because of it.
I followed the tutorials exactly as instructed and am not sure why this occurred. I have since corrected it by following this answer, but now want to know why this happens, especially since I am following the official tutorial and do I have to add the C++ include path for every project on Eclipse?
Related Question
That first error in the screenshot linked in the comments provides a clue to the problem.
If you go to the preference page mentioned in the error's "Location", you'll see that there is a field called "Command to get compiler specs" with the contents something like:
${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"
This is a command that Eclipse tries to run to get your compiler to output its built-in include paths and other similar information.
The fact that you're getting the error Program "-E" not found in PATH suggests that the variables ${COMMAND} and ${FLAGS} are evaluating to empty strings, so that the first actual token in the command (which the shell then tries to interpret as the program name) is -E.
I'm not sure why those variables are evaluating to empty, but you should be able to work around the issue by replacing ${COMMAND} with g++ (presumably g++ is in your PATH).
I've searched for a few hours and tried a lot solutions.
Envirment: windows, Eclipse IDE for C/C++ Developers
Version: Kepler Service Release 2
CDT: 8.3.0
Following steps works for me:
make sure the envirement is clear. => I suggest delete the eclipse and unzip it again from your orginal download. Remove all variable relatated to eclipse and MinGW you set to PATH of envirment variables.
make sure the workspace is clear. => Delete .metadata folder in your workspace folder.
use valid MinGW. => the one using download tool is slow and I'm not sure which one to select. I suggest download MinGWStudio which contains an unzip MinGW from http://vaultec.mbnet.fi/mingwstudio.php This is a IDE tool like eclipse contains a downloaded unzip MinGW. Make sure you download the one plus MinGW compiler which is about 20M. You can use this studio if you want or copy the MinGW folder to C:/ if you still prefer eclipse. Copy /MinGW inside /MinGWStudio to C:/.
close your eclipse and reopen it, create a new project, you should able to see MinGW section for new project option, and it will auto map g++, gcc and include files under C:/MinGW folder. Just make sure you copy MinGW folder from MinGWStudio to the root of C:/.
You will able to see your include after these steps. Build your project, everything should goes well even there may some warning hint.
Hope it helps.

No such directory or file in C++ [Codeblocks/Visual Studio]

I'm currently working on a project that will download a file from a website using the cURL library, but I'm currently getting an error when the compiler reaches the #include "curlpp/cURLpp.hpp" line. The IDE I'm using is Codeblocks with MinGW gcc compiler but I've also tried Visual Studio and I'm running into the same problem. The curl folder is located in the same folder as the source code.
Thanks in advance!
I had similar "path" issue. Try to change from:
#include "curlpp/cURLpp.hpp"
to:
#include "./curlpp/cURLpp.hpp"
In Visual Studio is also sometimes issue if your include directory is specified in VC++ Directories, put it rather into C++ -> General -> Additional Include Directories.

libgmp-10.dll is missing

I recently installed MinGW on my 64-bit Windows 7 computer and when I attempt to compile the most basic of c++ programs, for example
#include<iostream>
using namespace std;
int main()
{
cout << "Hello World" << endl;
return 0;
}
I get the error that "The program can't start because libgmp-10.dll is missing from your computer."
Have you tried adding C:\MinGW\bin as a System variable Path (not PATH) in Settings->System Properties->Environment Variables?
I saw this solution on this page: Missing libgmp-10.dll
Go to the mingw download page and browse the following directories:
MinGW / Base / gmp / gmp-5.0.1-1
Currently you end up with the following link:
http://sourceforge.net/projects/mingw/files/MinGW/Base/gmp/gmp-5.0.1-1/libgmp-5.0.1-1-mingw32-dll-10.tar.lzma/download
and it contains the needed file.
I know there are automated methods for installing mingw gcc, but when one uses single mingw packages, then gmp is one of obligatory downloads.
added
c:/MinGW/bin to PATH
and restarted CMake-gui
worked for me
I came upon this question when I started CodeBlocks and then clicked on my project. After the project notes appeared and I pressed OK, the error appeared:
"System Error: The program can't start because libgmp-10.dll is missing from your computer.
Please reinstall the application to fix this problem."
I presse OK a bunch of times and then was able to do normal compile, link, etc. but that error showed up everytime I started C::B and went to the project. Then I noticed that the LLVM Clang compiler was my default compiler in the compiler settings, though GCC was set as the compiler specific to the project I was working on.
The solution was to set the compiler in the compiler settings to GCC (mingw) and also set it as the default compiler. After that this system error stopped popping up every time I started the project.
The reason I posted this answer is because it answers the OP's question and other people with the same question may have a similar reason for this irritation, and my personal experience in this matter may prove useful to those people.
If you did not find this file in your installation directory, and then went to the site [Click here] to download the file, and then extract it to your installation directory.enjoy:-)
Caution - removing stuff from your path can compromise your system!
Interestingly, you not only need to add the MinGW bin to your Path, but also you need to make sure that certain things are not on your path*. In my case, I saved my entire path variable as a backup, deleted everything non-system from my path except for MinGW and CMake, leaving:
C:\MinGW\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files (x86)\CMake\bin
You should use the appropriate elements from your system path.
I first tried to do this with a batch job that launched CMake, but it seems that the CMake GUI was reaching back and grabbing the System 'Path' variable instead of the command prompt 'Path' variable, which I had printed and confirmed was as listed above before launching CMake.
Incidentally, I backed up the entire Windows VM before starting!
* For instance: various references, including known issues, mention sh.exe. I inherited this VM from my client and hacked it up further, so it's easier for me to use a clean path for my cross-compiling task and return afterward...
In just installed MinGW using the mingw-get-setup.exe v0.6.2beta-20131004-1 installer. Even though during the install I selected the gcc package, the installer didn't include the "mingw32-gmp" package, which includes libgmp-10.dll. I had to rerun the installer, chose the "Reinstall" option, and manually select the "mingw32-gmp dev" package.
If you don't have the permission modifying your global path, you can also change the active directory of your cmd shell.
How to do it (in the cmd shell):
C:\> cd C:\MINGW\bin
C:\MINGW\bin> gpp.exe C:\Users\James\Desktop\Program.cpp
How it doesn't work:
C:\>C:\MINGW\bin\gpp.exe C:\Users\James\Desktop\Program.cpp
Note: you have to change "C:\Users\James\Desktop\Programm.cpp" to wherever your program lays
How it works: windows looks for needed DLLs while in the same directory and if it can't find it there it'll look in the PATH variables (so it will search system32 by default), if you add any missing DLLs to the directory from where you run it, windows looks and uses them (even before it looks in the PATH).
A very simple fix to this problem of having missing driver file/s is to select and copy all the dll files from C:\MinGW\Bin and paste them into your C:\MyPrograms or whereever else your folder for created c++ (.cpp) files are being located.
Just search google for the dll file and download it. Then paste it into the folder in this path
C:\MinGW\libexec\gcc\mingw32\9.2.0