Netbeans C++ Application won't build [duplicate] - c++

This question already has an answer here:
How to add a library include path for NetBeans and gcc on Windows?
(1 answer)
Closed 8 years ago.
I recently installed the MiniGW compiler so that I can start learning C++. But when I go to create a new project and have it include main, I get two error messages from the start(after the project has been created) Cannot Find Include File <cstdlib> and Unable to resolve identifier std and when I try and 'Clean and Build' the project, the clean is successful and the build is not. I have done a google search and ran across this post Netbeans 7.2 shows "Unable to resolve identifier" , although build is successful , but I'm not sure my problem is exactly the same since my project won't build (or maybe it is, I don't know), and I'm also not sure I understand the accepted answer. Can this be multiple problems or just one? I want to get this fixed so I can learn!
/*
* File: main.cpp
* Author: Zf
*
* Created on December 16, 2014, 1:50 PM
*/
#include <cstdlib>
using namespace std;
/*
*
*/
int main(int argc, char** argv) {
return 0;
}
Edit: Lines 7 and 8 are where the error messages are.

Have you Tool Collection set properly ?
for example
<cstdlib> is found in C:\minGW\lib\gcc\mingw32\4.8.1\include\c++

Sounds like you need to tell the compiler where to find cstdlib. See this: How to add a library include path for NetBeans and gcc on Windows?
Cstdlib contains C functions, they are not wrapped in a namespace. Remove the using namespace std; line

Related

Undefined reference when using "Hello world" of Irrlicht library [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 years ago.
Improve this question
I'm trying to compile the very first code given by Irrlicht library website.
As said in the title, I get an undefined reference. I'm using 8.2 netbeans IDE.
This is what I've done so far :
Installed Irrlicht library from the Linux repository (I'm using Ubuntu 18.04).
Using these command lines : sudo apt-get install libirrlicht1.8 libirrlicht1.8-dbg libirrlicht-dev libirrlicht-doc
In the "project properties", I've added the include directory, as well as the include headers (e.g all the files contained in /usr/include/irrlicht. Also, in the "Additional Options" (the linker part, I guess ?) , I've seen online that I should add -lIrrlicht command line, and it still got me the undefined reference.
I've tried also the following command line : -L /usr/include/irrlicht -lIrrlicht, still got me the undefined reference.
I know that the compiler finds the library, as it does not make a compilation error saying that it doesn't know "irrlicht.h", so the problem is coming from the linker. What command line does the linker expects ?
Note : I'm not able to make any update. Talking about irrlicht, it seems that I have 363 packages outdated. Could the problem be from there ?
Edit : Here is the minimum code, as requested. There is no point showing it, as the error comes from the linker command line :
#include <cstdlib>
#include <iostream>
#include <irrlicht.h>
using namespace std;
using namespace irr;
using namespace core;
int main(int argc, char** argv) {
IrrlichtDevice *device=createDevice(video::EDT_SOFTWARE,dimension2d<u32>(640,480),16,false,false,false,0);
return 0;
}
I had a similar problem with another library. I fixed it by changing the path in the linker?
according to https://de.wikibooks.org/wiki/Irrlicht_-_from_Noob_to_Pro:_C%2B%2B_f%C3%BCr_Irrlicht_einrichten
you have to link lIrrlicht like:
LIBS += -L/.../Irrlicht/irrlicht-1.7.1/lib/Linux
LIBS += -lIrrlicht
instead of -L /usr/include/irrlicht -lIrrlicht (for unix).
Did you try that?

libclang not finding headers in <> brackets on Mac with Xcode

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:

c++ win32 console application is not recognized as an internal or external command operable program or batch file

so I just installed vs2015, and I'm having issues starting a project. For my intro school programming class, we are learning with the win32 console. I started up my own project at home so I could work on my projects at home, but I'm having issues starting. Thanks in advance for any help. Link to image
Your issue is annoying yet simple to fix, before I answer it you're using visual studio 2015 which means by default you would have been "given " a header file and your main would have looked like the following.
#include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}
You can modify the main function, as in remove every thing but int main() but I would suggest not doing this.
The answer to your question is, your program will not compile because you are not using #include "stdafx.h"
simply put that in and your projects will work assuming you code them right...
Also after looking at your picture more closely ( next time post your code here)
I see that your only source file showing is named R4.Que? Rename it R4.cpp

Why does "cout" keep giving me error C1083?

I was using Visual C++ 6.0 just now, and I keep getting this error:
fatal error C1083: Cannot open include file: 'streambuf': No such file or directory
My code is just a simple hello world program.
#include "stdafx.h"
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
cout<<"Hello World.";
return 1;
}
Then I went and checked my INCLUDE folder and found a file called STREAMBF, but the compiler was looking for STREAMBUF. Notice that the file that is present is missing the U, between the B and the F. This was from a good copy of VC++6.0, directly from the actual CD, not a pirated copy. So there should be all the files needed. But it appears that a file is missing! Is this MS being stupid again, and yet making another big mistake, and forgetting to include an important file on their CDs? I'd hate to think that every single CD for VC++6.0 that was pressed that came out of MS factories had this problem. And I know that it is a missing file, not just a misnamed file, as renaming STREAMBF to STREAMBUF just led to more errors.
Anybody know where I can find a copy of the file STREAMBUF? Or am I just overlooking something here? Is this exact error a known problem with running old copies of VC++ on modern OS's like Windows 7? Is it possible that the only reason that it's looking for STREAMBUF is that this is a newer file associated with Win7, and that if it was running in a different environment (an older OS), it would actually be looking for the correct file, STREAMBF? Can somebody help me here?
Your installation is either broken, deprecated or interpretes your code in wrong way.
You should only use older compiles if you are trying to build project developed entirely for this version.
Try to compile same code with new compiler, if you want to use VS then you should look for Visual Studio Express 2013.
Your code does not have any errors.
Modify your program to, you should be able to see it okay.
#include <iostream.h>
using namespace std;
int main()
{
cout<<"Hello World.";
return 1;
}
However,
your compiler is pretty old. You need to an upgrade.
There are C++ compilers for Windows from Microsoft Express Visual Studios Link and Info VS2013 to
some other non-Microsoft like GCC for Windows.
If you don't have installation access there are some portable c++ compilers.
Finally there are some online compilers for simple test. web based online compilers.
For my win 10 installation of VC 6.0, I had the same problem ... fatal error C1083: Cannot open include file: 'streambuf': No such file or directory
Replacing with <iostream.h> does not solve the problem.
I have checked the header file installation folder (Program files\VS98\VC98\INCLUDE). For some (unknown) reason, some file names have been changed during installation. Restoring the original name has solved the problem, in my case, in example:
Turn STREAMBF into STREAMBUF, STDXCEPT into STDEXCEPT, XCEPTION into EXCEPTION, FCTIONAL into FUNCTIONAL.
Notice: other header file names might be wrong. I have listed above the file names wrong in my installation.
I hope this may help.

Eclipse CDT does not resolve variables initialized in #include files

The problem occurs when trying to use CDT for editing files in OpenFOAM, a popular computational fluid dynamics software package. I am using Eclipse Kepler SR2 Build id: 20140224-0627 and CDT 8.3.0.201402142303 The following is a simplified version of the problem.
Given the following hello.cpp
#include <iostream>
#include <string>
int main(){
#include "hello.H"
std::cout << hello << std::endl;
}
and the following hello.H
std::string hello("Hello world!");
Indexing can't resolve hello in hello.cpp. However, if I change hello.H to hello.inc it does work. This isn't a feasible solution for OpenFOAM. How could I make the indexing and autocomplete work with the given structure?
Note: I did try Eclipse Luna too, and the same happened.
Edit: I think this might be a bug. After more experimenting, the following happened. When I named the hello.H to hello.inc, the hello in hello.cpp was recognized. However, when I rebuild index it wasn't. Then I resaved hello.inc without functional changes, and behold, it was recognized again. However, if I turned off automatic indexing it no longer got resolved after rebuilding the index.
Edit 2: After further research on the problem, I found the following duplicates, without the random behavior:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=418085
and to my shame:
#include inside function body doesn't work (CDT/Eclipse C++)
Thus this question can be closed as a duplicate. To those interested, CDT indexer is not actually designed to do this, as this is bad coding style. The main message to me was that I should use some other IDE with OpenFoam.