I'm trying to generate code metrics for a C++ project which is not a Visual Studio one, rather it was written on Linux.
I tried the Project Maker and followed the steps except for the last part (After adding the source files, you can specify the project properties). I did not know what to input. So, I proceeded and when starting the Analysis it gives so many clang parsing errors such as
"string" file not found at "path/xyx.hpp"
fstream file not found at "path/ii.hpp"
though I can see in xyx.hpp that there is a line #include <string>
From the projectmaker configuration you have to specify the include path where the stl library exists. For that right click the project in projectmaker choose properties and added the include path directories separated by ;
Related
I am a C# developer, and spoiled rotten when it comes to references and dependencies. I am working on a small project now in Visual C++ (Visuial Studio 2017), where I want to use the libtomcrypt and libtommath libraries. I've created a small project and added the 2 projects to my solution:
I have also added my includes:
And I added the dependencies:
However, I still can't build:
Error C1083 Cannot open include file: 'tomcrypt.h': No such file or directory
I am not sure what else I need to do to get the references working and the code to compile. Any pointers is appreciated!
The error message indicates that the compiler can't find the file tomcrypt.h while compiling one of your source files. From the message I would guess that you have a line like the following in your source file:
#include <tomcrypt.h>
(...or perhaps with quotes instead of brackets.) From your screenshot I can see that you've added "...\repos\libtomcrypt-develop\src\headers" to your include path. Is the file tomcrypt.h found directly in that folder, or is it perhaps in a subfolder instead?
Your #include directive will basically append whatever path you give it to each entry in your include path when looking for the file, so if there are subfolders in between, you'll have to expand your #include directive to include those folders.
If this doesn't solve your problem, perhaps try posting the actual full path of where this header file exists on your filesystem, as well as your complete include path value! (The full compiler command from the build log would be useful, as well as the complete error message(s) related to this source file.)
Edit:
The original poster posted a separate answer indicating that the actual problem was that the Visual Studio Project Properties were set correctly, but that he was accidentally trying to build a different Configuration. :(
I was building the project under x86. Once I changed it to x64, it built just fine.
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.
I'm trying to write a program using flex++, however everytime I try to compile I receive the error message:
FlexLexer.h: No such file or directory
However that header is found on the include folder of flex. I don't have problems compiling lex programs for c, however for c++ with flex++ I can't seem to find a way.
I already downloaded flex various times and I don't know if there is a problem with my OS or something like that. My OS is Windows 10.
Thank you
Including should be pretty straightforward once you understand how it works.
Let's look at some different ways you can include a file:
#include "FlexLexer.h"
The quotes tell the compiler to look for the file FlexLexer.h in the same folder as the file being compiled. That is it, it won't look anywhere else.
Now if we change the quotes to brackets:
#include <FlexLexer.h>
This tells the compiler to look for FlexLexer.h in the same folder first, but then if it isn't found it will go through the list of include paths looking for it there, too.
Assuming you are using VisualStudio, there is both a system list of include paths (see Tools > Options > Projects and Solutions > VC++ Directories) and a project list of include paths (right click on the Project in the Solution Explorer, Properties > VC++ Directories). Both of these lists are traversed.
Finally, you can also add subdirectory qualifies to the include, e.g.:
#include "Win\FlexLexer.h"
or
#include <Win\FlexLexer.h>
As you might guess, it looks for the path under either the current directory in the both examples and also under the include path list in the later example. Regardless, the first time the file is found the search will stop and the compiler will use it. So be careful if there are headers will duplicate names in different libraries!
I want to include a header file. I am working in a C++ environment, (C++11, Windows OS, Netbeans 7.3.1 IDE, Cygwin_4.x tool collection). I do not know how I setup the environment/IDE (I did it 6 months ago). I do not understand the fundamentals of the C++ build process or Cygwin related issues either, so I might have to fill in the gaps with some other references/documentation (on what specifically, I'm not sure).
My ultimate objective is to be able to include header files using a syntax that does not require the full file path. I want to write something terse, like:
#include "src\stuff\blah.h" //or even better: #include "blah.h"
The only way I can get my program to compile at all is by using the full file path, like this:
#include "C:\NetBeansProjects\Project1\src\stuff\blah.h"
And, I can only compile once using the full path. If I try to rebuild, it will bomb with the *** multiple target patterns. Stop. error. There are workarounds for this error; those being either 1) deleting the build and dist folders between each rebuild (yikes?), or 2) following this 16 step setup process.
I do not want to follow either of those workarounds because they do not appear to deliver what I want. How can I setup my environment to achieve what I want...of being able to include header files without using full paths?
Thanks to DanielKO for this answer.
In my case, I was able to include with the syntax:
#include "../stuff/blah.h"
I did not have to configure anything under the "Code Assistance" section for the C++ compiler.
All of my code is under "src" as the parent directory in my NetBeans project. It seems that the full path of the file is not required, and the only directory that must be referenced is the lowest level subdirectory (in my case, "stuff").
In NetBeans I've added the path to the list of libraries:
Go to Properties->Select C++->Select 'include libraries'->'Add'
Now: Add the path of the project folder with option "absolute"
Go to Properties->Select C++->Select 'Additional library directories'->'Add'
Now: Add the path of the project folder with option "absolute"
It's very obscure to me why the project doesn't recognize "own" header files.
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.