Code::Blocks not being able to find standard library headers? - c++

I recently switched from Bloodshed to Code::Blocks. I wrote a simple input/output program to get a feel for it, and when I tried to compile it I got errors for all of the headers I had included, saying that there was no such directory.
I took a look at the file and saw that the file was saved as a C file rather than a C++ file, how do I change this? (I know this is why because the C++ files I transferred over from Bloodshed work fine.)

As #nagul said in the comments, saving the file as <file>.cpp instead of <file> fixed the no such directory error when compiling.

Related

Problem using libxml2 with VS Code under Windows (g++)

I'm not new to programming, but pretty new to C++. I successfully loaded some other 3rd party libraries like curl or sqlite, but I'm having a problem with libxml2 (Platform Windows; IDE VS Code; Compiler g++). I downloaded the binary from zlatkovic.com (x86_x64 if it matters).
After including one or two header files and typing a few lines I wanted to see what the result would be and I tried to compile my code. I added the libxml2-2.dll in my vs code task file under the '-g' flag of the compiler, just like I did it with the others. But this time I received the following message:
"path/to/src/libxml/xmlreader.h:16:10: fatal error: libxml/xmlversion.h: No such file or directory"
Like you can see in the message, the header files are in the "libxml" directory and I also checked they exist.
I guess it's something really basic I'm missing out here, but help would be really appreciated, thanks!
I finally got it. I needed the '-I' flag to the directory with the header files. Thanks everyone!

Trying to compile Qt/C++ code in Code Blocks

I am new with QT, so I am not sure how this works. Im trying to compile some C++ code that includes QT code for graphics. I am using the GNU compiler in Code blocks, but whenever I compile it, It gives this error:
fatal error: QGraphicsRectItem: No such file or directory
So how do I fix this? Is there a different compiler I need?
My include statement is:
#include <QGraphicsRectItem>
It is hard to tell from the info you provided. There are several problems that yield this error, not configured the files correctly, there is no such header file, ..., etc. The error is clear though.
Qt is a big library that is why we need qmake to take care of configuring the files, so theoretically speaking, you can generate Makefile and copy-paste the related data to your code-blocks project. As far as I know, qmake supports Visual Studio and Xcode projects but not sure if there is a tool for code-blocks.

g++: 'vector' file not found

I'm trying to compile a cpp file using llvm-g++-4.2 on Mac OSX 10.8.
Yes, I know those are old, but I'm trying to develop a plugin for a software that only supports plugins developed in that old environment, sadly.
Anyway, when I try to compile my .cpp file it gives me the error:
'vector' file not found
After it tried to include it (#include <vector>).
I checked in my local include folder (/usr/include) and the vector header file is really not there.
What should I do?
The CAPlayThrough example I was looking at compiled just fine, but the project I had created did not.
To tell the compiler to look for the C++ include file, the top level file AppDelegate.m in my case had to be renamed to AppDelegate.mm. This is telling the compiler to treat the source as a C++ file with all the appropriate includes.

Xcode and Objective-C++ can't find <cstdio>

I'm writing Cocoa code that uses some classes defined in a C++ library. I give the filename the extension .mm, and things are usually fine.
But not always. Sometimes Xcode 4 disappoints me with: "Lexical or Preprocessor issue: 'cstdio' not found". I can't figure out how to make Xcode find it. Nor can I figure out why it works sometimes, but not others. What do you think?
Edit: Noise. My filename extension was not .mm, but rather .m. :( There is not, and there never was, a problem. See below.
It still should be able to find <stdio.h> just fine.
Edit: The .mm file should work fine all the time. Make sure in your build settings that Compile Source As is set to According to File Type

Code::Blocks cannot find vector header

EDIT: I have solved this problem, with Tomalak's help. It appears that I mistakenly uninstalled libstdc++6-4.4-dev_4.4.3 when I was making space to install code::blocks into, thus removing the STL headers. Code::Blocks now works perfectly fine.
Hey everyone, I'm back yet again to bug you.
I have recently installed Code::Blocks in order to follow along with a SDL tutorial, mainly to make it easier with the file creation process (i.e. not having to deal with makefiles for the time being)
I have been compiling/running the examples (so far) just fine, but I've now hit a snag.
On the tutorial for entities, the header file includes <vector> - yet code::blocks is stating it cannot find said header file. It's a .h header file, but it's recognizing it as C++ (I think, judging from the project options) - all my headers are .h, all my sources are .cpp...
I have searched Google for a solution, and many people state that this error occurs when they try to use in a .c file by mistake. This is not the case, unless Code::Blocks is recognizing my .h as a C-header.
In case you're wondering, I am running Lucid Puppy Linux 5.2 (aka LuPu), a Ubuntu derivative. (Installed Code::Blocks from the Ubuntu repositories)
In advance, thank you very much for the help.
As it turns out, it was not a Code::Blocks issue - I had mistakenly un-installed the libstdc++6-4.4-dev_4.4.3 package.
So, if any of you all get this same problem make sure the libstdc++ development files are installed! LOL