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!
Related
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.
YCM autocompletes and highlights errors on C++ standard library. However, if I download another library such as OpenMPI and write code that imports <mpi.h> I can compile it with mpicc but YCM tells me that <mpi.h> file was not found and all it's provided functions seem to by marked invalid by YCM. Is there a way to fix this ? What changes should I make to ycm_extra_conf_py file to support other downloaded libraries?
I found this question while searching for an answer myself. The only solution I have found so far is to manually edit compile_commands.json and add the required mpi include dir, eg run
mpicc -showme
and append the relevant
-I/usr/lib/x86_64-linux-gnu/openmpi/include/openmpi
options to the conf file. I haven't seen the contents of ycm_extra_conf_py but I guess there is something similar to do. I hope this helps.
Here we have a question, an answer and some happy people.
But I've got a different situation,
I'm coding in C++ and I'm going to build MuPdf myself.
So, when i add fz_register_document_handlers function before fz_open_document_with_stream I'll get 5 unresolved external symbols for these
_opj_image_destroy (2 times)
_opj_copy_image_header
_opj_image_comp_header
_opj_image_create
I can get rid of 3 of them by linking openjpeg\libopenjpeg\image.c but _opj_image_destroy is stock on my compiling error list!
[UPDATE]
Mupdf version: 1.6
I don't know that it's a right way or not but I created a visual studio project, named Native and put Mupdf source in it and try to compile.
Then i'm using it's header in other c++ project (and using declare "C" in it) and linked Native to it.
It works fine until i trying to open a file as a stream and not file address.
So, my project failed with this error: "No document handlers registered".This error is caused by document.c file.
I searched and find the page which was linked above and I changed the source.
The compile errors appeared after that change!
Thanks for your help and sorry for my English...
Firstly, you haven't said what version of MuPDF you are using. I'm going to assume you're using the latest version from git (currently 1.6 as of 1 Feb 2015).
Secondly, you've not told us anything of use about how you're building MuPDF. Without knowing exactly what you've changed, it's hard to speculate what you're doing wrong.
If you're compiling vanilla .c files with a c++ compiler then you probably need to do some wrapping of files with extern "C" declarations.
Feel free to get in touch on the #ghostscript irc channel and tell us more.
[Update]
It sounds to me like you are missing the openjpeg decoder. You can't just add a single file from the openjpeg source and expect it to magically work.
Why are you creating your own Visual Studio project when we provide one for you already? platform/win32/mupdf.sln
I was bothered by the error
fatal error C1083: Cannot open include file: 'iostream.h': No such file or directory
for quite a while, I tried my best to search all the relevant cases but couldn't find a good answer for me.
My situation is, I have a simple piece of code with a couple of dependencies to build, after setting up all the include folders, I'm just experiencing this compiler error all the time. Two weird questions I cannot answer,
There is another win32 console project somebody else set up for this project, working! I'm trying to copy all of his settings (the command line options are exactly the same, all env variables are same, and I run two projects on same visual studio), but just have this 1083 error in my own project.
I was playing around with the settings, one time I changed the platform from Active(Win32) to Win32, then suddenly the compiling works, but after that time I couldn't reproduce it any more.
The thing is, I'm guessing VS in my project might go to a wrong directory
C:\Program Files\Microsoft Visual Studio 8\VC\include instead of C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include
not quite sure, and earlier I was trying to compiling using a building script and make files, same error happened because there people didn't update the correct VS directory.
Sorry I couldn't provide the source code here, and it won't be helpful either since it has a couple of levels of dependency. But I hope based on my description some one might give some idea which direction should I go or spend time on.
iostream.h is deprecated, it should be just iostream:
#include <iostream>
See <iostream> vs. <iostream.h> vs. "iostream.h"
In this version of visual studio (and also in any modern C++ IDE) standard library headers are named without any suffices (iostream instead of iostream.h, string instead of string.h, etc)
Also, C library headers are named like cxxx instead of xxx.h, for example, you should include cstdlib instead of stdlib.h
When you say that you ran your project and the other person's (working) project on the "same visual studio", do you mean the same installation or the same version? If they're not on the same installation, then even if the project settings are copied exactly, it could be that the installation settings are different and that that's what's causing the problem. This may be a long shot, but I'll do my best to explain.
I came across your question because I had a slightly similar problem. Even without dependencies, I couldn't get a simple "Hello, World" program to compile. I used iostream without ".h" as many people suggested and still got C1083. Then I realized that when I installed VS, I unchecked one of the basic features, called "Visual C++ Run-Time Libraries". So I modified the installation to include this feature. Afterwards compilation proceeded successfully and the problem was solved. Is it possible that your installation is missing something that the other person has? If you can get your project to work on this other person's installation, then that might help to pinpoint the problem. Hope this helps. Good luck!
Does a simple hello world program that uses <iostream> compile and run fine?
If so, the Visual Studio system settings are fine and there is something probably wrong in either the project settings or the source.
You can eliminate the source by checking to make sure that the code is actually using #include <iostream> as opposed to #include <iostream.h>. Once that is done, make sure your header search paths point to the right place (the same as the default values in your hello world project for a start)
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.