I have been seeing this occasionally, but this project in particular is causing me to tear my hair out.
I have my .cpp.
#include <nppi.h>
#include <cuda.h>
#include <device_functions.h>
#include <cuda_runtime.h>
The Headers are in My project directory, in:
<Project file>\Thirdparty\CUDA\v8.0\include
my Additional includes are:
$(ProjectDir)Thirdparty\CUDA\v8.0\include
i have also tried:
Thirdparty\CUDA\v8.0\include
The includes are not found by intellisense, and i cannot open them with a right click. What am i doing wrong? or is this a bug?
Even with a hardcoded path in the Additional includes, the files are not found.
I am in Release mode. If i switch to Debug mode, some of the files are found, but some are not. The Additional includes seem to stay the same when I switch, this seems odd. (I have not added additional includes for Debug).
Thank you for your help, this is driving me mad.
Create a new folder named "include" in your project directory.
Right-click on the project and then on Properties.
CUDA C/C++ -> Additional Include Directories. Type into the upper half $(ProjectDir)include. it should evaluate this path correctly. Check that!
In your kernel.cu that includes your main-function, type in #include "include\mycode.cu". That worked for me. Good luck!
Related
I previously had all of my source files in the same folder just scattered about, but I was getting tired of the disorder, so I created a folder hierarchy and organized my headers and .cpp files in those folders, and changed the ClInclude tags in the projects .vcxproj file accordingly. I then changed all the #include rows in the source headers to match the new location of the headers.
Now when I compile I get a heap of errors saying that the namespace "math" can't be found. The namespace could be found before the file organizing, so the problem should be something with that, but that #includes works fine.
If I write
using namespace
the autocomplete finds the namespace just fine, and no red wiggly lines show up in the text interface.
I'm using VS17 Community.
There are actually two ways to resolve your issue. You've already noted the first, that you can always use relative paths (relative to the source file).
#include "..\Math\math.h"
This will work just fine. You can also modify your C++ Project Properties to add a list of include directories. This will be very useful for you when you begin working on projects that use a lot of libraries To add include directories you need to:
right-click on your project in the solution explorer and select Properties.
In the left pane, click on the C/C++ > General tab.
On the property that says Additional Include Directories, click the drop down arrow (you may need to click inside the text first) and select Edit...
From here, you can add a list of include directories that you will be using with your project. You can use:
Absolute Paths
C:\Path\to\Math
Relative Paths (relative to your .vcxproj file)
..\..\relative\path\to\Math
Macros (Visual Studio will list your available macros)
($SolutionDir)..\path\to\Math
You'll see the use of the macros a lot when it comes to C++ and other Visual Studio projects not just for include directories, but for build events as well.
Once you've added a list of include directories, you can go back to including your headers in the source code as normal:
#include "math.h"
In the event you need to use a relative path from one of your included folders, you can do that as well.
// some directory inside of Math
#include "MoreMath\moremath.h"
// some directory above Math
#include "..\AboveMath\abovemath.h"
Hope this helps!
I solved it...
Remove this question if necessary. The problem was that I didn't backtrack the filepath in my #include "math.h". They should instead have said #include "..\Math\math.h".
I was trying to re-use an available source code for my own project, it can be found here:
https://github.com/TadasBaltrusaitis/OpenFace
I tried compiling project FeatureExtraction of the original code, everything was fine. Then I created a new empty project and added the following #include:
#include "LandmarkCoreIncludes.h"
#include <Face_utils.h>
#include <FaceAnalyser.h>
#include <GazeEstimation.h>
These are exactly the same as in project FeatureExtraction in the provided source code. I've already changed the additional include directories in C/C++ general tab into:
$(SolutionDir)\lib\local\FaceAnalyser\include
$(SolutionDir)\lib\local\LandmarkDetector\include
However, it still gave me "cannot open source file error".
Update: If I put the absolute path of the header file directly to the code it is OK, however if I put the absolute path to the Additional Include Directories, the error remained.
Use #include "header.h" instead of the one with diamonds (< and >) which looks in another directory.
After that, check if the header files really are in these directories. If they are, you should check the $(SolutionDir) ( I don't use a '\' after the $(SolutionDir) but it may work out as well).
Try to locate and delete the .suo file and restart VS
Looks like I had same "bug" as mentioned in this post here:
Visual Studio does not honor include directories
After having changed the Additional Include Directories for all platforms instead, the code was compiled without any errors.
First of all I'm still new here and therefore have no idea how to format the code so it looks neat in this question, I hope this is acceptable.
I am following the programming principles and practice from Stroustrup. You might guess what the problem is...yes FLTK instalation. I have followed all the steps carefully to build the project in VS C++ 2013; pages 1204-1206. (I've done appendix C successfully, having to do with std_lib_facilities.h).
I was trying to build the following win32 project, as shown in the book:
#include <FL/Fl.h>
#include <FL/Fl_Box.h>
#include <FL/Fl_Window.h>
int main()
{
Fl_Window window(200, 200, "Window title");
Fl_Box box(0, 0, 200, 200, "Hey, I mean, Hello, World!");
window.show();
return Fl::run();
}
After building solution, I receive an error which reads: Error 1 error C1083: Cannot open include file: 'FL/Fl.h': No such file or directory
I have also followed the steps to copy across some lib files from the FLTK lib directory into c:\users\pablo\desktop\c++ course files\visual c++\win32project1\source.cpp which is the file I created for Visual Studio Express 2013.
Can somebody help me? Where do I find this missing file? Is the problem perhaps having to do with the fact that the FLTK version is a bit outdated to be used in VS 2013? (When I compiled the FLTK library, I got some errors having to do with backup file and some warnings.)
I have researched this long an hard. I found some questions having to do with this in this forum but not exactly related to the above mentioned problem. Thanks very much in advance.
PS Well, there was one question having to do with the same error. I've followed some of the tricks mentioned as an answer to the same question but to no avail.
("A neat trick you can do for these types of errors is to place your cursor into the file name of the #include statement and press Ctrl+Shift+G. It will fail and display a message box showing what the include paths are. The solution is to simply add additional include paths to the SDK by right clicking your project and going to Properties>C/C++>General and setting "Additional Include Directories".")
The other suggestion shown didn't work either: ("Make sure the include directory is not the FL directory, but its parent. The reason for this is when you say #include "FL/Fl.h", you're asking the compiler to step into a folder called FL to find Fl.h, which will reside in FL's parent. If you specify FL as an include directory then you need only say #include "Fl.h"").
The other answer isn't remotely true (I have literally just compiled an FLTK program with all headers in the form #include <FL/xxx.H>). When you download FLTK you get a directory (say fltk-1.3.2) which has this structure
/fltk-1.3.2/
FL/
GL/
src/
lib/
examples/
+ other stuff
The sub directory FL contains all the header files. As such if wherever you've placed the fltk-1.3.2 directory is located at \foo\ then you need to add \foo\fltk-1.3.2\ to your additional include headers field. Do be careful, you might have accidentally chosen the wrong directory (it happens) or you might have extracted the contents of a zipped version of the file into a nested version of itself meaning you might have something like \foo\fltk-1.3.2\fltk-1.3.2\ So have a look.
If it can't find the headers you almost certainly have got the additional include directories field looking in the wrong place or in the wrong format. Click on the drop down button, click edit and manually click the new folder button and navigate to it.
What you will find next is that you have to point the linker in the right direction. In the above the default place to install the library files (.lib static should be default for FLTK) so you need to add \foo\fltk-1.3.2\lib\ to configuration properties -> Linker -> General -> Additional library directories
THEN you need to link to the specific libraries. Since the linker now knows where to look you down need to specify the path, but just name them. To do so go to configuration properties -> Linker -> Input -> Additional dependencies, click the drop down option, click edit and add on separate lines (and without these commas) fltkd.lib, fltkformsd.lib, fltkzlib.lib,wsock32.lib
This is because there is no header file named #include <FL/Fl.h> what they mean by this is to include either #include <FL> or #include <FL.h> depending on what program your making, but the former is most likely what you want to do since it's the standard version. #include <FL.h> is an old library, and is not even included in the standard. It is also not even included in every platform. You should not use the .h version in this example.
The same can be said for the other two header files as well.
The original question was about Windows, and the direct answer to the question is to add the directory above the FL directory (note: uppercase) to the include paths of the Visual Studio settings.
Since this is about windows, spelling of the header files may not matter, but such programs as shown by the OP are not portable because other systems use case sensitive file systems. For portability almost all FLTK header files must be written with uppercase ".H" to be found on case sensitive file systems (there are some exceptions). The correct example program - tested on case sensitive Linux with current development version FLTK 1.4.0 - would be:
#include <FL/Fl.H>
#include <FL/Fl_Box.H>
#include <FL/Fl_Window.H>
int main() {
Fl_Window window(200, 200, "Window title");
Fl_Box box(0, 0, 200, 200, "Hey, I mean, Hello, World!");
window.show();
return Fl::run();
}
Note that this still needs the correct include path to compile and build.
this works !!!
On your own Linux/Mac: Download the source for fltk 1.1.10 and unpack it in a directory of your choice. You should be able to execute "configure", "make", and "sudo make install" to install fltk in /usr/local/lib and /usr/local/include.
I'm using VS2010 (downloaded via dreamspark) and although I can open the #include file by right clicking on it and pressing on Open Document, it complains "Error can not open source file "..."" which seems rather absurd. I'm using Qwt with Qt this time around and I'm specifically having the problem for:
#include <qwt_counter.h>
#include <qwt_plot.h>
(And I am using the "<>"); not sure how to make those appear properly in the code above.
Thanks in advance.
As Neil indicated, try using quotes instead of the <> characters around the filename. When using the quotes, MSVC will look in the same directory as the file the #include is in for the specified file, then if it's not found there will look in the directories specified by the include path. When the filename is surrounded by <> characters, the current file's directory isn't looked at - the compiler goes right to the include path.
See http://msdn.microsoft.com/en-us/library/36k2cdd4.aspx for details.
Note that this is an implementation dependent behavior - it might not apply to other compilers.
If that doesn't help, make sure that your include path contains the directory that the file is located in by setting the "Include Directories" property appropriately:
http://msdn.microsoft.com/en-us/library/t9az1d21.aspx
Finally, you might be using a makefile project (I'm not sure how common it is for Qt projects to continue to use qmake when built from VS) , in which case you'll need to perform whatever configuration is necessary in the make file(s) or parameters passed on the command line that invokes the makefiles.
Is the path where these files are located either the same as that of this source file, or included in the "additional include directories" in your project settings?
Project -> properties -> c/c++ section -> additional include directories.
If they are located in a subdirectory of the source file you're editing or of one of the additional include directories (I think) you can also include them with:
#include <path_to_file_1/qwt_counter.h>
#include <path_to_file_2/qwt_plot.h>
[edit]
or of course what neil says
[/edit]
It turned out there was a circular linking happening and I had all my code in a .h file. I split it up and added the corresponding .cpp file, now everything works fine.
I'm trying to get Xcode to import the header file for Irrlicht.
#include <irrlicht.h>
It says "Irrlicht.h. No such file or directory". Yes Irrlicht.h with a capital I, even though the #include is lowercase.
Anyway I added "/lib/irrlicht-1.6/include" in the header search paths for the Xcode project, yet it still doesn't find it.
The only thing I've tried that does work is:
#include "/lib/irrlicht-1.6/include/irrlicht.h"
This is a bit ridiculous though, #include should work, I don't understand why it isn't working.
Update (here are more details on the error):
/lib/PAL/pal_benchmark/palBenchmark/main.h:31:0
/lib/PAL/pal_benchmark/palBenchmark/main.h:31:22: error: irrlicht.h: No such file or directory
I figured this out. Perhaps someone can comment as to why this is the case.
The Header was located in this directory:
/lib/irrlicht-1.6/include/
If I added that path to: "Header Search Paths" Xcode still wouldn't find the path when I built the project.
Solution: Add the header path to: "User Header Search Paths" instead.
It boggles me why I had to do this, as I frequently add my header paths to "Header Search Paths" and then #includes just work. Hopefully this can help someone else who gets this same issue.
Both
#include <irrlicht.h>
#include "irrlicht.h"
should work as long as the "-I" argument to gcc includes the path of the directory enclosing the header file. If irrlicht.h is part of /usr/include the "-I" option is no longer required.
Rather than explicitly adding include paths to your project settings, an easier and more convenient solution for this kind of situation is to just drag the directory containing your .h files (/lib/irrlicht-1.6/include in this case) into the project files pane. This adds the headers to your project of course, and makes it easy to browse them and search for symbols, etc, and it also adds the directory path to gcc compiles, so that you don't have to manage include paths explicitly.
and furthermore, a flat file hierarchy isn't what you want. Dragging files into Xcode flattens your hierarchy. What about for example when you want to have multiple Targets, with a "TargetName/settings.h" file for that target. you'll have many settings.h files that you need to keep unique via its folder name.
I understand that this is an old post, but it does rank quite high on Google, so I thought I would add some information
Under XCode 3.2.6, I had an issue where XCode could not find a header file. It turns out that one of the filepaths included a space in it, and XCode interpreted it improperly.
For example: With a path like "Users/Username/Desktop/Project/Some Headers"
Here was the excerpt from the GCC Commandline: "-I/Users/Username/Desktop/Project/Some" "-I/Headers"
To see your build log provided by XCode, there is a good tutorial here: How do you show Xcode's build log? (Trying to verify if iPhone distribution build zip was created correctly.)