Edit:
This program compiles. It's only when run does it fail to find iostream. I'm using the libclang.dylib that is bundled with Xcode.
I've written a small tool to begin working with libclang. I'm trying to parse TranslationUnits. The following program is saved in the file tool.cpp. Once compiled and run, it tries to parse tool.cpp as a TU. It's failing to get a clean run with default headers as it cannot find iostream on my Mac. After several attempts to supply arguments that point to the file, it still doesn't work. Any ideas?
#include "tool.h"
#include <iostream>
int main(int argc, char* argv[]) {
CXIndex index = clang_createIndex(0,0);
const char *args[] = {
"-I/usr/include",
"-I/usr/local/include",
"-I.",
"-I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include",
//Should be here
"-I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/4.2.1"
}
;
Output:
tool.cpp 6:10: 'iostream' file not found
I've got the same issue. I am trying to add CPP to iOS Objective-C. It's not working. I found that this is about next "pain" from Apple because they do not use standard C++ library anymore. I've tried everything that mentioned on this site but haven't found any solution:
I'm currently working on a class assignment that requires the use of the CImg library. To be clear, the assignment is not linking the library into the program; The class is using it access the pixel data for later use in the heart of the assignment.
I'm working in Xcode (OS X 10.10). CImg (2.2.2) is installed from homebrew, and I've managed to navigate the weird way Xcode deals with search paths (added the header to the section), and have successfully-ish included CImg.
my full code is as below.
#include <iostream>
#define cimg_display 0 //I don't need X11 at all
#include "CImg.h"
using namespace cimg_library;
int main(int argc, const char * argv[]) {
// insert code here...
std::cout << "Hello, World!\n";
return 0;
}
However, I get 17 Compile-time errors from CImg.h, which are very unusual, and all of the form:
"No member named 't_normal' in the global namespace; did you mean simply 't_normal'?"
Thinking I might have received a bad download, I have attempted to redownload CImg, with no luck. I have also gotten to this same point with non-homebrew versions of CImg.
To verify the download, I also compiled the examples from the command line and they ran perfectly.
Is there a problem with CImg that I'm not aware of, a problem with Xcode that I'm not aware of, or is there something fundamental that I'm missing (definitely an option, my C-style programming is a little rusty) ?
halp pls.
Your code runs fine if you do this:
Create a new Xcode project, with:
type = "Command Line Tool"
language = "C++"
Then go to "Build Settings" and add the path to the directory containing CImg.h to your "User Header Search Paths"
I'm new to Qt creator. Yesterday, I followed the official instructions to configure OpenCV library but it failed. I tried everything on the Internet but it just didn't work. Detailed are listed as belows:
test code is simple, I only want to ensure whether the library works:
#include <iostream>
#include <opencv2/opencv.hpp>
using namespace std;
int main(int argc, char *argv[])
{
cout << "Hello World!" << endl;
return 0;
}
My project configuration is like below :
I thought there might be a problem in debugger. I configure the debugger and I'm quite sure it's ok. The picture is here:
But it just doesn't work. When I click build and run, it says:
C1083: cannot open containing files: "opencv2/opencv.hpp": No such
file or directory.
What's strange is when I include <files> in the editor, the automatic code completion can detect the existence of the OpenCV library and hint after <opencv2/> that there are opencv.hpp, core.hpp .etc. and in the Include Hierarchy, the opencv.hpp exists.
So what might be the problem?
I got a .h and .cpp codes on a website and I am trying to compile them. This is the website that contains the codes: http://raphaelcruzeiro.com/blog/implementing-a-sha1-algorithm-in-c/
I am creating a new project, selecting "console application" and adding the .h and the .cpp files to the project, but when I try to compile I always get this error "undefined reference to `WinMain#16".
I tried DevC++ and Codeblocks both of them got the same error.
Please I want all details on how to compile these files, is there a #include to use? If you guys please make a simple step by step I would be very glad.
On this website http://raphaelcruzeiro.com/blog/implementing-a-sha1-algorithm-in-c/ you will find the .h and the .cpp codes.
Thanks in advance
All C++ programs require some sort of main() function, which is where they start executing. The code on the website has no main(), causing the compiler to complain (and rightly so - the program wouldn't know where to start).
You'll need to add something like the following to your .cpp file:
int main(int argc, char **argv) {
/* code to do SHA1 stuff */
return 0;
}
I downloaded Code::Blocks from here: http://www.codeblocks.org/downloads/26
I'm learning c programming. When I run the following program, I get error:
iostream: No such file or directory
error: syntax error before "namespace"
warning: type defaults to `int' in declaration of `std'
warning: data definition has no type or storage class
In function `main':
error: `cout' undeclared (first use in this function)
error: (Each undeclared identifier is reported only once
error: for each function it appears in.)
error: `cin' undeclared (first use in this function)
I'm running the following program:
#include <iostream>
using namespace std;
int main()
{
int x;
x = 0;
do {
// "Hello, world!" is printed at least one time
// even though the condition is false
cout<<"Hello, world!\n";
} while ( x != 0 );
cin.get();
}
I tried Dev-C++, I get the same error.
How to fix this?
Is this in a file like "program.c" or "program.cpp"? If it's a .c file, then your compiler may be interpreting it as C, and not C++. This could easily cause such an error. It's possible to "force" the compiler to treat either such extension as the other, but by default, .c files are for C, and .cpp files are compiled as C++.
It's either this, or somehow your default "include" directories for the standard library are not set up right, but I don't know how you'd fix that, as that'd be compiler/environment dependent.
I also had that problem when trying to run my first program in Code::Blocks. My file was saved with '.c' extension as 'test.c' and when I saved it as 'test.cpp', it worked fine.
It is also worth mentioning that I had to restart Code::Blocks before new 'test.cpp' file was compiled successfully.
While saving your source code before compiling just save the name with extension ".cpp". You wont get the error..
I got the same problem.
Change #include < iostream.h >
to #incude < iostream >
Consequently, in your program, change every keyword related to iostream, such as cin cout and endl to std::cout, std::cin and std::endl
That'll do the trick
Use <iostream> instead of <iostream.h>
and add std:: before cout, cin etc
Use std::cout << "Welcome";
instead of cout << "Welcome";
Save the file with .cpp extension
you have missing iostream.h file in you mingw directory folder placed inside codeblocks/devc++. what you have to do is just download the file from link given below and replace with your previous mingw folder in codeblocks/devc++.
http://www.4shared.com/rar/owp-D0Km/mingw.html
I found the problem was cause by having a previous version of cgg and cpp in a Perl installation. The Perl structure did not have the correct library files. When I added C:\MinGW\bin and C:\MinGW\MSYS\1.0\bin to the path, I added them at the end so it picked up the Perl install first. I moved the path variable entries to the beginning and reopened my cmd window and it now works because it finds the MinGW version first.
Type path to see your path environment varialble. Mine now looks like:
C:\MinGW>path
PATH=C:\MinGW\bin;C:\MinGW\MSYS\1.0\bin;C:\Perl\site\bin;C:\Perl\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\WIDCOMM\BluetoothSoftware\;
Apparently you want to create a c++ file. But you allowed your computer to auto provide the file extension C/C++. When it does that it automatically provides a file extension of ".c". Which is not corect. You want ".cpp".
Solution: Rename your file with a ".cpp" extension, or else explicitly state your extension when saving new files by putting ".cpp" (without quotes of course) after your intended file name; i.e. specify your file extension.
I tried in Dev-C++ . Instead of iostream.h use iostream also write the using namespace std;
#include<iostream>
using namespace std;
int main()
{
cout<<"Hello World\n";
return 0;
}
you written your program in C++ code use c code then your program run correctly
in first line use it
#include <Io stream.h>
main ()
{
in ending line use it
system (pause");
You are trying to make a C game right? If you are your code is C++ not C. So if you are trying to make a C game than you should change your code. This might help.
Just put "Using namespace std;" before main() to define the scope of identifiers you are using. This will handle your problem easily.
Try including iostream.h instead of iostream.