Click here to Skip to main content
15,946,320 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In my some VS2022 codes solution explorer,

[Header Files]
- Controller.h
- sshell.h
- ScrollWindow.h
- some more .h....

[Source Files]
- Controller.cpp
- main.cpp
- sshell.h
- some more .h...

And for the external directory, setted
Project Property -> C/C++ -> Additional Include Directories : C:\SFML-2.0\include

Project Property -> Linker -> Additional Library Directories : C:\SFML-2.0\lib
in my VS2022.

But errors~
#include "atomic"
#include <SFML/Graphics.hpp>
#include <memory>

in my ScrollWinodw.h,
#include <SFML/Graphics.hpp>

Error	C1083	Cannot open include file: 'SFML/Graphics.hpp': No such file or directory	xxxxx	C:\Users\User\source\test\viewer\Wrapper\ScrollWindow.h	


What's the problem? Maybe header #include sequence problem?
It's not #include recursive problem because there is no same header file
name dupicated.
Actually it's a little bit unfamiliar with me for #include hpp header file
in ~~~.h header file.
And the SFML is well installed and well detected path.

What I have tried:

I've tried to add "Project Property" set (lib, include)
and then compile, cpp error (
#include <SFML/Graphics.hpp>
) is cleared
but header file's header is still problem.

And failed to change from
#include <SFML/Graphics.hpp>
to
#include "SFML/Graphics.hpp"
Posted
Updated 5 days ago
v3

I think your include statements do not match with your additional directories. In your additional directories you have added: "Additional Include Directories : C:\SFML-2.0\include", and in your code you have "#include <SFML\Graphics.hpp>". So the preprocessor will construct the path "C:\SFML-2.0\include\SFML\Graphics.hpp". But I suspect that there is no "SFML" subdirectory under the "C:\SFML-2.0\include" directory; something that it is easy to check. Also when you changed the include statement to use double quotes instead of angle brackets the preprocessor would be looking for a directory named "SFML" under the directory containing the source files. See #include directive (C/C++) | Microsoft Learn[^] for details about search paths.
 
Share this answer
 
Comments
merano99 4 days ago    
The assumption that something is wrong with the path is obviously correct, but the subdirectory “SFML” under “C:\SFML-2.0\include” would be there if you have not renamed it or moved files. What surprises me more is the outdated SMFL version from 2013, which may not fit well with current compilers.
Richard MacCutchan 4 days ago    
I know nothing about SFML which is why I told the OP that it is easy to check if it exists.
Member 16143694 yesterday    
Thank you for your advice.
Of course in my local PC,
C:\SFML-2.0\include\SFML exist~
And the Graphic.hpp is located in C:\SFML-2.0\include\Graphics.hpp.
But other header files are located in C:\SFML-2.0\include\ and C:\SFML-2.0\include\SFML.
So how should I do?
Richard MacCutchan yesterday    
If what you say is true then the compiler (pre-processor) will find the file and include it in the build. If you are still getting the error message shown in your original question then you must have a mis-spelling in one of the statements. Either the #include, or in the additional include directories in your project. But you need to provide the actual details before anyone here can help to resolve it.
Member 16143694 yesterday    
Thank you for your advice.
But..I've already known that SMFL is old..Not updated from 2013.
And SMFL 2.6 is also unstable code I think.

Anyway, I should correct "C:\SFML-2.0\include\SFML" and "C:\SFML-2.0\include" both in my "Additional Include Directories"?
The compiler probably doesn't know where to look for the SFML header files. Try the -I flag in the compiler options:
CompilerOptions
-I/path_to_SFML_headers_folder
 
Share this answer
 
Comments
Member 16143694 yesterday    
Thank you for your answer but..
Where is "CompilerOptions" in VS2022 Community?
https://learn.microsoft.com/en-us/cpp/build/working-with-project-properties?view=msvc-170
I can not find it out after refer the above link.
Your procedure corresponds to the current tutorial. Something must have gone wrong during the installation of SFML. I would check whether the path actually exists and whether the access rights are correct. Unfortunately I don't have the time to try it out quickly, but I would assume that the tutorial works. Alternatively, you could copy SFML into the current project folder and write the include with quotation marks, then you can save yourself the include path in the project settings.

I wonder why the very outdated SFML version 2.0 from 2013 is still being used. It may not be a good fit for current compilers.

To be on the safe side, here is the link to the tutorial:

SFML and Visual Studio (SFML / Learn / 2.6 Tutorials)[^]

// edit:
Perhaps it is not a good idea to use the latest version 2.6.1 of SFML at this time. Obviously many parameters of the functions have been changed without affecting the tutorials and examples. The problems already start when creating the window. Here are the two versions for comparison:
C++
#include <SFML/Graphics.hpp>

int main()
{
// Create the main window

// SFML 2.5.0: RenderWindow (VideoMode mode, const String &title)
sf::RenderWindow window(sf::VideoMode(800, 600), "SFML window");

// SFML 2.6.1: 
// const sf::Vector2u vsize(200, 200);
// sf::RenderWindow window(sf::VideoMode(vsize), "SFML window");

...
}
 
Share this answer
 
v4
Comments
Member 16143694 yesterday    
Thank you for your reply.
Sure.
Your recommend is goes well (Maybe).
But the header #include are so many exist in my code~
Try the "External Include Directories" property in VS2022:
/external (External headers diagnostics) | Microsoft Learn[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900