I'm including files from another project in the same solution - it's all worked fine in it's current configuration but I added a new method, and now it can't find any of the include files.
Here's the header file dems_gridmanagement.h:
#ifndef dems_gridmanager_h
#define dems_gridmanager_h 1
//## begin module%500EBD96007C.includes preserve=yes
#pragma once
#include <QObject>
#include <QTime>
#include <QString>
#include "common_StringUtility.h"
#include "common_SharedMemory.h"
#include "common_QtThread.h"
#include "common_QtThreadable.h"
#include "sma_Maps.h"
#include "dems_Types.h"
...
#include "MQTTs_UDP_Multicast.h"
...
And in the additional include directory:
.\GeneratedFiles;$(QTDIR)\include;.\GeneratedFiles\$(Configuration);$(QTDIR)\include\qtmain;$(QTDIR)\include\QtCore;$(QTDIR)\include\QtSql;.\;..\Common;..\DemsCommon;..\Ethernet;..\SMA;..\ModbusTCPIP;..\MQTTs;%(AdditionalIncludeDirectories)
Crucially, it includes the "..\SMA", which should allow the "sma_Maps.h" to be found, but I'm getting:
Error 3 error C1083: Cannot open include file: 'sma_Maps.h': No such file or directory c:\users...\solution\projects\DemsGridManagement\dems_GridManager.h 33
I tried changing it to:
#include "../SMA/sma_Maps.h"
which get's rid of the error, but then introduces a new error:
Error 59 error C1083: Cannot open include file: 'MQTTs_UDP_Multicast.h': No such file or directory c:\users...\solution\projects\DemsGridManagement\dems_GridManager.h 39
And also a similar error for an include in a project file that is in a completely different project within the solution, and I haven't even opened or changed anything in.
For some reason, it's like the solution is just selectively ignoring the include directory information with some of the project files, but not others (QT includes work fine, so do the "common" project includes...
Does anyone have any ideas what could be causing this? It was all working fine yesterday!
Edit: Narrowed it down. I added a reference to GridManager from another project:
#include "../DemsGridManagement/dems_gridmanager.h"
If I remove this, there's no problems in the dems_gridmanager.h file. If it's here, the includes in gridManager go crazy and break.
When including with #include "filename" it always search the same directory as the current file. To get the files you have included in "additional include directories" you should include with #include <filename>
Related
I have a Hello World program that uses
#include <boost/process.hpp>
I set the Additional Include Directories and this file is found. Its first include file is
#include <boost/process/args.hpp>
and that is found O.K. It in turn has an include file
#include <include/boost/process/detail/basic_cmd.hpp>
that throws an error
C1083: Cannot open include file: 'include/boost/process/detail/basic_cmd.hpp'
which is correct in its way - there is no lower level include file!
Manually changing this to
#include <boost/process/detail/basic_cmd.hpp>
allows that file to be found, but its child then throws the same type of error. What Visual Studio setting handles these nested includes automatically?
I too had include-file trouble with with the .zip file download.
boost/static_assert.hpp includes itself
Install boost using the .7z archive instead of the .zip. (Advice applies to 1.65 only.)
Imagine the following source files:
src/StdAfx.h
src/moresrc/MyFile.cpp
In MyFile.cpp, I need to include the precompiled header file StdAfx.h.
If I do this:
#include "../StdAfx.h"
then I will get the compiler error:
warning C4627: '#include "../stdafx.h"': skipped when looking for precompiled header use
fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source?
So that doesn't work. If I do just
#include "StdAfx.h"
then that compiles correctly, but I get the annoying error highlighting in Visual Studio 2013 that looks like this:
So, like I said, this compiles, but it is annoying.
How can I include "StdAfx.h" without the underlining, but so that it will compile?
You can add $(ProjectDir) (project root directory) to directories list in project options (C++ -> General -> Additional Include directories). Then you'll be able to specify paths relative to project root in includes. For instance if you have utils/a.h and want to use it from foo/bar/b.h you can write #include "utils/a.h" instead of #include "../../utils/a.h". And if you have stdafx.h in project root you can include it with just #include "stdafx.h".
I have a header file called simpio.h, which is in the same folder as the file which is including it in its header. However, I keep on getting the error "Cannot open include file: 'simpio.h': No such file or directory." I am using Visual C++ 2008 Express Edition. Help would be appreciated.
Thanks
You need to use double quotes:
#include "simpio.h"
You have to know that you should use <> when you are trying to include a standard library header or when you want to include a file for which the path is contained in the Additional include directories option.
You have to use "" when you whant to include a file who doesn't satified the previous explanation, let's say that it is almost always file specific to your project.
Some example :
#include <iostream> // library file
#include <boost/thread.hpp> // there is "C:\SDKS\boost in my Additional include directories
#include "MyHeader.h" // Local file, at the same place of my .vcproj
#include "Header/AnotherHeader.h" // Local file in a folder named "Header"
In your case, we can think that you are in the second case. You just have to do :
#include "simpio.h"
Or if your file is in another folder :
#include "SomeFolders/simpio.h"
I am trying to build gtest in Visual Studio, but seem to be having some problems getting the references and includes specified correctly for the project.
error C1083: Cannot open include file: 'gtest/gtest.h': No such file or directory c:\gtest-1.6.0\src\gtest-all.cc
1>InitializeBuildStatus:
1> Touching "Debug\GTestBuild.unsuccessfulbuild".
1>ClCompile:
1> gtest-all.cc
1>c:\gtest-1.6.0\src\gtest-all.cc(40): fatal error C1083: Cannot open include file: 'gtest/gtest.h': No such file or directory
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:01.61
To the Project, I added in the Project Project Pages > C/C++>Additional Include Directories list references to the following:
c:\gtest-1.6.0
c:\gtest-1.6.0\src
c:\gtest-1.6.0\include
c:\gtest-1.6.0\include\gtest
but I seem to be missing some other includes or probably did not set this right and would appreciate some help in solving this, and learning how to do this for future as well.
PS. Switching from
#include "gtest/gtest.h"
// The following lines pull in the real gtest *.cc files.
#include "src/gtest.cc"
#include "src/gtest-death-test.cc"
#include "src/gtest-filepath.cc"
#include "src/gtest-port.cc"
#include "src/gtest-printers.cc"
#include "src/gtest-test-part.cc"
#include "src/gtest-typed-test.cc"
To
#include <gtest/gtest.h>
// The following lines pull in the real gtest *.cc files.
#include <src/gtest.cc>
#include <src/gtest-death-test.cc>
#include <src/gtest-filepath.cc>
#include <src/gtest-port.cc>
#include <src/gtest-printers.cc>
#include <src/gtest-test-part.cc>
#include <src/gtest-typed-test.cc>
is not a solution. I have tried this and it does not work.
Check the full compilation output to see whether these include directories are being incorporated into the compilation. It should look something like:
...
-Ic:\gtest-1.6.0 -Ic:\gtest-1.6.0\src -Ic:\gtest-1.6.0\include -Ic:\gtest-1.6.0\include\gtest
...
Have you also looked for the file in these directories? Don't forget that as you're including it with a directory, you'll have to look for gtest.h in the following directories:
c:\gtest-1.6.0\gtest
c:\gtest-1.6.0\src\gtest
c:\gtest-1.6.0\include\gtest
c:\gtest-1.6.0\include\gtest\gtest
(Note the gtest subdirectory as you using #include "gtest/gtest.h")
If you look in the Property Pages for the file gtest-all.cc, its Additional Include Directories field should show:
..;..\include;%(AdditionalIncludeDirectories)
if you used the provided msvc\gtest.sln, or else:
C:/gtest-1.6.0/include;C:/gtest-1.6.0;%(AdditionalIncludeDirectories)
if you used CMake to create a VS solution.
If the field is empty, then it is not getting the directories you set for the full project, since they are applied via the %(AdditionalIncludeDirectories) variable. If this is the case, it may be worth getting a fresh download and starting again, since the build is no longer in good shape.
I'm having some problems with JRTPLIB c++ win32 version, compiling in visual studio2010.(http://research.edm.uhasselt.be/~jori/page/index.php?n=CS.Jrtplib). I've emailed the author but have yet to received a reply. The problem I am experiencing is this:
error C1083: Cannot open include file: 'rtpconfig_unix.h': No such file or directory c:\users\johan-bar\desktop\developer tools\3rd party software\jrtplib-3.8.1\src\rtpconfig.h
The two .h files I have are these:
MAIN.h:
enter code here
#include <WinSock2.h>
#include <Windows.h>
#include <WindowsX.h>
#include <stdlib.h>
#include <string>
#include <Richedit.h>
#include "jrtlibtest.h"
#include "resource.h"
jrtlibtest.h:
#include "rtpsession.h"
So I reason that I need to #include windows.h in jrtlibtest.h for it to recognise WIN32 to be defined (so it does not include unix .h files) but that in turn gives me about 100 redifinition errors.
I am unsure how to solve this problem and I can't find any information on the library homepage itself or on the internet. Has anyone else encountered this problem?
Cheers
I have not seen JRTPLIB c++ lib, but based on information that you provided ('rtpconfig_unix.h'can not be opened), it seems that it is taking default file for unix port? Look for something like a config file in the JRTPLIB folder and run it (./config on cygwin or something). That should generate the windows config files that you would be able to #include in your code.
Good luck!!
EDIT:
The fact that you are getting the error:
error C1083: Cannot open include file: 'rtpconfig_unix.h':
means: in your rtpconfig.h, the WIN32 macro is not enabled:
#ifndef RTPCONFIG_H
#define RTPCONFIG_H
#if (defined(WIN32) || defined(_WIN32_WCE))
#include "rtpconfig_win.h"
#else
#include "rtpconfig_unix.h"
#endif // WIN32
//#define RTPDEBUG
#endif // RTPCONFIG_H
And thatÅ› why it says it cant open rtpconfig_unix.h file.
Did you try #defining win32 macro in rtpconfig.h directly? (or do it in your project settings).
Include ws2_32.lib in your project. Had the same problem.
(And remove if you already include it, wsock32.lib and winsock.h header file to avoid colissions)
What are the redefinition errors?
If they are from winsock, removing winsock2.h from your includes might help.