How to run c++ program in codeblocks? - c++

i write a simple progrum in c++ and run using codeblocks(13:12). My code looks like -
#include <iostream>
using namespace std;
int main(){
cout << "hello" << end1;
return 0;
}
but it's don't build. it gives me an error message .
s Mine\c++ pro. . . 1 fetal error: No such file or directory
Why i am getting this issue ? Why the iostram file don't found . Whats the wrong with it and how to solve it ?

I am not sure about the error you wrote, but I think that your compiler might not be installed. I suggest you to unistall CodeBlocks and re-download the installer from http://www.codeblocks.org/downloads/26 that has the compiler already installed: codeblocks-16.01mingw-setup.exe from the link.
Good luck, pal!
EDIT 1: The script is fine, don't worry about it.
EDIT 2: Oops, I now see that you have a fault in your code. It's endl, not end1!

Related

How can I get VSCode to find gmp.h after it has been successfully installed on Windows 10?

After installing and following the instructions for GMP (using mingw64 since I am on windows) and verifying the installation was correct using make check I tried running the following code in VSCode using the command g++ -g \path\file.cpp -lgmpxx -lgmp -o \path\file.exe:
#include <gmp.h>
#include <iostream>
using namespace std;
int main()
{
mpz_class a,b,c;
cout << "Hello World\n";
a = 1234;
b = "5678";
c = a+b;
return 0;
}
But get the error error: 'mpz_class' was not declared in this scope. So the include path in VSCode is incorrectly set up or the installation was messed up. I am wondering how to fix this: is this VSCode's includePath (compilerPath is not set up), an installation issue (I could not determine the default install location for windows systems since everything I found was for Linux), or is there something else I missed? I saw a flag for ./configure that was --enable-cxx but I wanted to ask before running make clean and retrying with that flag turned on since it takes forever.
I feel like this is something dead simple since I cannot find any help from googling.
Thank you for any help!
EDIT: I have tried running the code not in VSCode and it still has the same issue so I am not so sure it's VSCode.
I don't know anything about GMP, but you seem to include the wrong header.
#include <gmpxx.h> worked for me.

Eclipse C++ Setup

I want to switch from Dev-C++ to Eclipse (Version 12/18, 4.10.0) , but I am not able to Compile in Eclipse. I installed MinGW, edited the Pathvariable, restared the PC, installed the C++ Eclipse IDE, created a new Project there I choosed MinGW as my Compiler, and wrote a Hello World.
The Code is:
#include<iosteam>
using namespace std;
int main(){
cout << "Hello World!";
return 0;
}
The Error Message I get is the following:
error: CreateProcess: No such file or directory
What do I need to do to be able to build/run Proramms?
Thanks in advance
You have everything you need to be able to build/run programs. Maybe something is flawed in the configuration. You should separate the tasks to find out the problem.
First try to compile your minimal example by executing g++ from a console like that:
g++ main.cpp. If you get the same error message then you have to fix your Mingw-w64 setup.
If this works, then something is wrong with eclipse. You might want to check different project types. When using Makefile projects, you perhaps have more possibilities to do checks on the console.

Run C++ program in Terminal

I'm trying to run this simple C++ code in Sublime Text on Terminal but it's not exactly working...
#include <iostream>
using namespace std;
int main() {
cout << "Hello world!" << endl;
return 0;
}
I'm getting this message instead:
"hello_world2.cpp:1:10: fatal error: 'iostream' file not found"
How can I fix this?
You most probably are missing development headers for your C++ standard library.
You didn't say anything about your environment, but if you were on Windows on Mac you would for sure get these together with your compiler, so let's assume Linux.
You need to install libstdc++-devel package or equivalent (libstdc++-4.8-dev etc.)

Trying to set up the GNU C++ COMPILER, but I get an error I don't understand when I try to compile hello.cpp

So I bought this book called C++ Programming In Easy Steps by Mike McGrath online.
In the instructions it specifies to create a source file written in C++, the infamous "helo world". So I created my cpp file through sublime text editor and moved it to a file called MyPrograms in my C directory.
The code is as follows:
#include <iostream>
using std::cout;
using std::endl;
int main()
{
cout << "hello world"<< endl ;
return 0 ;
}
I have also tried:
#include
using namespace std;
int main()
{
cout << "hello world"<< endl ;
return 0 ;
}
Ok so I saved this file as hello.cpp in C:\MyPrograms.
Then here is where the error occurs....
I open cmd.
I do "c++"
I receive the message "c++: no input files".Which is what I'm supposed to recieve according to the book.
I proceed to do "cd\myprograms" to enter into the MyPrograms directory.
Once in that directory I do "c++ hello.cpp". According to the book this is supposed to compile my source file and create an executable file next to it. Instead I get a long error message that end in collect 2: 1d returned 1 exit status.
When I visit MyPrograms no executable file has been made next to the original cpp file.
I have also tried to do "c++ hello.cpp -o hello.exe" but it gives me the error again. All of this is done on the command prompt.
Please help :(
It looks to me like MinGW isn't installed properly.
First, it looks like you are trying to use version 4.0.3 but it may be conflicting with a version 3.4.5 that you installed previously (one in c:\mingw and the other in e:\p\giaw\src\pkg).
The latest version of MinGW is 4.7.2.1 which you can install from here: http://www.mingw.org/wiki/InstallationHOWTOforMinGW
But it looks like you're just starting out and it may be better to work with something that's better optimized for Windows (unless you're trying to compile Free Software). You can get a copy of Visual Studio Express for free here:
http://www.visualstudio.com/downloads/download-visual-studio-vs#d-express-windows-desktop
There are older versions available as well if you scroll down (VSE 2010).

MS Visual C++ 2008 Express cannot find path

I'm trying to do something basic
#include <iostream>
using namespace std;
int main()
{
cout << "Hello, World!";
return 0;
}
After using F7 I get
1>mt.exe : general error c10100b1: Failed to load file "..\Debug\helloworld.exe". The system cannot find the path specified.
So it cant find the file that it'll eventually create?
What gives?
mt.exe is the manifest tool. The manifest tool shouldnt run if there is a build error. I dont think you will see mt.exe run if there is a build error. Go to your solution file, under the manifest tab, check if the path's in the settings are not hard coded to some wrong path.
#include <.iostream.>
Did your build really succeed? The above line looks suspicious - I'd have expected to see (note the missing periods):
#include <iostream>