SFML community forums
Help => General => Topic started by: Filosof on November 16, 2021, 08:26:44 pm
-
Some strange exception are always thrown on Windows 10.
"Access violation reading location ".
I reduced it to problem code. Everything else, including graphics, sprites, music - working. All libraries are included. But once I put "window.draw(text)" - > I get this exception. It worth noticed that same project is working on Linux. But Windows got some issue.
Please help.
Source code:
#include <SFML/Graphics.hpp>
int main()
{
sf::RenderWindow window(sf::VideoMode(800, 600), "SFML window");
sf::Font font;
if (!font.loadFromFile("C:/Users/user/source/repos/BattleCity2/media/arial.ttf"))
return EXIT_FAILURE;
sf::Text text("Hello SFML", font, 50);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
window.clear();
window.draw(text);
window.display();
}
return EXIT_SUCCESS;
}
Call stack:
BattleCity2.exe!af_shaper_get_elem()
BattleCity2.exe!af_shaper_get_elem()
BattleCity2.exe!af_shaper_get_elem()
BattleCity2.exe!FT_Load_Glyph()
BattleCity2.exe!FT_Load_Char()
BattleCity2.exe!sf::Font::loadGlyph(unsigned int,unsigned int,bool,float)
BattleCity2.exe!sf::Font::getGlyph(unsigned int,unsigned int,bool,float)
BattleCity2.exe!sf::Text::ensureGeometryUpdate(void)
BattleCity2.exe!sf::Text::draw(class sf::RenderTarget &,class sf::RenderStates)
BattleCity2.exe!sf::RenderTarget::draw(class sf::Drawable const &,class sf::RenderStates const &)
BattleCity2.exe!main() Line 22
-
Are you linking release libraries in debug mode? (linking sfml-graphics.lib instead of sfml-graphics-d.lib)
-
Are you linking release libraries in debug mode? (linking sfml-graphics.lib instead of sfml-graphics-d.lib)
It is a good question. I build my project on CMake and get libraries from Conan.
Is there any way to distinguish release and debug package from conan?
Right now it is like:
conan_cmake_run(
REQUIRES
imgui-sfml/2.1@bincrafters/stable
BUILD
missing
)
...
target_link_libraries(
${PROJECT_NAME}
CONAN_PKG::imgui-sfml
)
I doubt if building CMake with release option will link right library. No?
-
Update:
- I have managed to build project with Conan release settings. Unfortunately it didn't help for Win10. On Ubuntu everything works both on debug and release build.
- sf::Glyph glyph = font.getGlyph('A', 20u, false); <- produce same exception.
-
The conan bit you showed was for imgui-sfml, do you also get SFML that way? Which package are you using?
Is Conan providing freetype as part of the SFML package or as a separate package?
-
The conan bit you showed was for imgui-sfml, do you also get SFML that way? Which package are you using?
Is Conan providing freetype as part of the SFML package or as a separate package?
Yes you are right. Updated Conan for correct library.
conan_cmake_run(
REQUIRES
sfml/2.5.1
OPTIONS
BASIC_SETUP
CMAKE_TARGETS
BUILD
missing
)
I see it links following libs:
sfml-audio-s-d.lib
sfml-graphics-s-d.lib
sfml-main-d.lib
sfml-network-s-d.lib
sfml-system-s-d.lib
sfml-window-s-d.lib
Conan: Settings= -s;arch=x86_64;-s;build_type=Debug;-s;compiler=Visual Studio;-s;compiler.version=16;-s;compiler.runtime=MDd
But still get same exception on Win10.