Additional Include Directories Difficulties - c++

I'm trying to include the FTGL library into my graphics project, but I keep getting c1083 error whenever I try to include the main header file:
#include <include/FTGL/ftgl.h>
I have added the path $(Project1)include\FTGL to "Additional Include Directories" and VC++ Include Directories to no avail. Project1 is the main solution folder and "include" is the folder where the headers for glew and whatnot are.
What am I doing wrong? Thanks for the help.

The rules here are very simple. Say you have a file on your hard drive:
C:\abc\def\include\FTGL\ftgl.h
Then you need to add an include path C:\abc\def to your project and the include statement:
#include <include/FTGL/ftgl.h>
This was tested 1000 times. Works fine! Once you will make this working, start experimenting with $(Project1) and other VS variables.

Related

#include not finding files while the Visual Studio autocomplete suggestions can find the files

I am trying to include Glad (generated from here with the GL3.3 api (having similar include problem with GLFW as well)) as such
#include <glad/glad.h>
I feel like this should work since I have my additional include directories for the file in the project as
vendor\Glad\include
where my VS solution has the file structure of
-solutionName
--projectName
---src
----projectname.h <- Where I am including from for now, latter I want to include from elsewhere under the src directory.
---vendor (same level as src)
----Glad
-----include
------glad
-------glad.h
------KHR
-------khrplatform.h
I have been able to get the include to work by including the file as
#include <../vendor/Glad/include/glad/glad.h>
but when I do this I get an error ("C1083" "Cannot open include file: 'KHR/khrplatform.h':No such file or directory") because an include in glad.h can't find khrplatform.h when it includes like so
#include <KHR/khrplatform.h>
I could change that line in glad.h but I really don't want to have to change a library's code to make mine work.
This also happens with GLFW which has mirroring additional include directories and file paths but with glad replaced with GLFW where applicable.
In addition Visual studio will offer the
<glad/glad.h>
file path as a suggestion when I am typing out the include line in projectName.h but I still get the error "C1083" "Cannot open include file: 'glad/glad.h': No such file or directory".
Another quirk is that I am using spdlog file the additional include directory
vendor\spdlog\include
and am able to include headers in the src directory as such:
#include <spdlog/spdlog.h>
which works and doesn't throw and problems.
The file structure for this is
-solutionName
--projectName
---src
----Utilities
-----Logger.h <- Where I am including from.
---vendor (same level as src)
----spdlog
-----include
------spdlog
-------spdlog.h <- file I am including just fine.
This makes it feel like only some of the additional include directories are actually working and I'm not sure why is this happening or how can I fix it after spending a couple hours playing guess and check. I want to include the libraries like
#include <glad/glad.h>
#include <GLFW/glfw3.h>
How can I make this work?
Thanks for your time,
-Michael
Use "glad/glad.h" instead of <glad/glad.h>.
With the angle brackets the compiler searches only the standard paths for includes, with the quotation marks it also searches the additional include paths that you defined.
Alright so I figured it out finally, I'm not happy with how I had to do it but I guess it works so I'll move on unless anyone has suggestions. So, the problem came down to that I was including the headers in a static lib I was making then used that static lib elsewhere. (I hadn't realized this was a problem otherwise I would have mentioned that in my original question, sorry everyone.) I included my lib by a header that includes all the dependencies that I want to have access to and later down the line these 3rd party static libs will git more and more abstracted but for the time being what I had to do was also tell my other "sandbox" (non library) project to also have additional include directories like
$(SolutionDir)MyLibName\vendor\Glad\include
and
$(SolutionDir)MyLibName\vendor\GLFW\include
Ideally I didn't want to include anything except MyLib but I guess this is my work around for now. Thank you to everyone who offered suggestions!

Dlib Error: error C1083: Cannot open include file:'type_safe_union/type_safe_union_kernel.h'

I'd like to use the image processing package of Dlib (C++ library) in Visual Studio 2013.
I created an empty project and added "dlib-18.16\dlib\all\source.cpp" to my Source Files in the Solution Explorer. Then, I added the path to dlib-18.16 to my Include Directories in VC++ Directories and I also added the path to dlib-18.16\dlib to my Additional Include Directories in C/C++ General of Visual Studio.
I can run the file matrix_ex.cpp which is one of the examples of Dlib, but I can't run the file face_detection_ex.cpp because of the error " Cannot open include file:'type_safe_union/type_safe_union_kernel.h' " which is actually caused by the line #include <dlib/image_processing/frontal_face_detector.h>
How can I resolve this issue? Why the program finds some header files but it can't find the others while they are all located in the same folder?
You need to add the dlib folder itself to the Include Directories in VC++ Directories, you instead added the folder above it.
By extension that would mean your include directive needs to be #include <image_processing/frontal_face_detector.h>.
Let me list a hypothetical example to explain better. You downloaded dlib-18.16.tar.bz2 and extracted it to c:\projects. This creates a folder named c:\projects\dlib-18.16. Within VC++ Directories you added c:\projects\dlib-18.16 to the Include Directories.
However this isn't correct, you should remove that directory and instead add c:\projects\dlib-18.16\dlib as that is the include directory for the project.
That will cause #include <type_safe_union/type_safe_union_kernel.h> to load C:\projects\dlib-18.16\dlib\type_safe_union\type_safe_union_kernel.h as well as similar internal links between files.

Cannot open include file error but able to locate file

I'm getting the following error :
"fatal error C1083: Cannot open include file"
for one of my header files being #included in stdafx.h. I have set the include and library paths in the project dependencies, Tried to include them in additional include section. On top of that when I right click the
#include <BCGCBProInc.h>
it is able to open the file and show it to me. So it can find and open the file but instead gives me the error. I am using VS2012 on Windows 7 and the header is in a different location then the project.
What am I doing wrong / not doing right?
1.
#include <BCGCBProInc.h>
is not the same as
2.
#include "BCGCBProInc.h"
Different search pathes apply to both variants of including a file.
The pathes looked up when using variant 1. are those defined as default search pathes like
/usr/include for IXish systems
$(VCInstallDir)include also called VC++ Directories for VC
The pathes used when using 2. are those added via the option -I (/I for VC).
In Visual Studio, right-click your project and choose Properties. Select the VC++ Directories option in the left pane, and then look at the Include Directories and Library Directories in the right pane. Make sure they are using relative paths and not absolute paths. If they must be absolute paths, then every machine you run this project on will have to have the exact same path. Absolute paths look like this:
D:/Development/MyProject/includes
Relative paths can be done using $(ProjectDir) to make it relative to the project, or $(SolutionDir) to make it relative to the solution (if different from project), and would look something like this:
$(ProjectDir)../includes
or
$(SolutionDir)includes
What I had to do to get it to compile was change
#include "BCGCBProInc.h"
to this
#include "C:\Program Files (x86)\BCGSoft\BCGControlBar Professional Evaluation\BCGCBPro\BCGCBProInc.h"
I'm not sure why because I included the path in the VC++ Directories. When I browse for the path it changes (x86) to %29x86%29 which is what I thoght was screwing it up but that is not the case because I manually changed it back to (x86).
My plan is when I eventually get what i need to get done, I will bring the libs and includes into the project locally and make the paths relative

file not found in xcode 4

Hi i made a command line tool but when compiling i get this error :
which is rather strange because the file is in the right folder in the project :
I already tried removing it and then adding it again , but it didn't help.
Did i forget to include something etc ... ?
I'm not really familiar with xcode so any help would be greatly appreciated.
You don't need the GL folder.
#include <OpenGL/OpenGL.h>
Within OpenGL.framework is gl.h, glext.h, and whatnot, and it's adapted for mac.
If you insist on GL/gl.h, you need to add it to the project's header search path. To do this, go to your project's settings->build rules, and search "Include Paths". When you find the "Header Include Paths" section, type in "${SRCROOT}/". This assumes that GL/gl.h is in the same project as your folder.

using header files from another project (directory)

I am using Visual Studio 2008, and I need to use certain header files from another project. I have tried to add the path in "Additional Include Directories" in C/C++ General properties pane, but my project still puts out the same errors
(fatal error C1083: Cannot open include file: 'tools/rcobject.h'.
All the other cpp and header files I am using I added as existing files from another directory, and for some headers it puts out an error and for others it doesn't. There was no change in errors after adding additional include directories.
Can someone help me, I am stuck as I need to Debug...
In the "Additional Include "Directories", did you put the path to the "tools" directory, or the path to the directory that includes the "tools" directory? It needs to be the latter.
How the preprocessor works to resolve #include directives, is to take the path specified in the #include and then append it to each of the paths specified in the "Additional Include Directories" (and some other places specific for the project). So, you need to make sure that the path specified in the "Additional Include Directories" plus the path you gave to the #include exactly matches the path to the file you are trying to include.
For example, suppose you have the following file you want to include:
c:\blah\bletch\foo\bar.txt
Then you did this:
#include "bar.txt"
Then you would need to make sure that "c:\blah\bletch\foo" was in the "Additional Include Directories".
Or if you had done this:
#include "foo\bar.txt"
Then you would need to make sure that "c:\blah\bletch" was in the "Additional Include Directories".
Enable the build log (I don't know from the top of my head where it is, shouldn't be too hard to find) and see if the paths you specify appear in the compiler command line. If not you're probably doing something wrong. Using additional include directories should just work. Just make sure you're using the right directory separator and you fill them in under the correct configuration (Release/Debug).
Regards,
Sebastiaan