SFML community forums

Help => Graphics => Topic started by: TrapAlice on January 31, 2012, 08:11:24 pm

Title: Access violation with sf::Text in SFML2.0
Post by: TrapAlice on January 31, 2012, 08:11:24 pm
I keep getting the error 0xC0000005: Access violation reading location 0xcccccccc.
Minimal example:
Code: [Select]
#include <SFML/Graphics.hpp>

int main(){
  sf::Font font;
  font.LoadFromFile("lucon.ttf");
  sf::Text text("Test", font, 30);
}
Title: Access violation with sf::Text in SFML2.0
Post by: Laurent on January 31, 2012, 08:18:57 pm
http://www.sfml-dev.org/forum/viewtopic.php?t=5559
Title: Access violation with sf::Text in SFML2.0
Post by: TrapAlice on January 31, 2012, 09:01:58 pm
Callstack
Quote
sfml-system-d-2.dll!std::_Char_traits<unsigned int,long>::assign(unsigned int & _Left, const unsigned int & _Right)  Line 215 + 0x6 bytes   C++
    sfml-system-d-2.dll!std::_Char_traits<unsigned int,long>::copy(unsigned int * _First1, const unsigned int * _First2, unsigned int _Count)  Line 167 + 0xd bytes   C++
    sfml-system-d-2.dll!std::basic_string<unsigned int,std::char_traits<unsigned int>,std::allocator<unsigned int> >::assign(const std::basic_string<unsigned int,std::char_traits<unsigned int>,std::allocator<unsigned int> > & _Right, unsigned int _Roff, unsigned int _Count)  Line 903 + 0x21 bytes   C++
    sfml-system-d-2.dll!std::basic_string<unsigned int,std::char_traits<unsigned int>,std::allocator<unsigned int> >::basic_string<unsigned int,std::char_traits<unsigned int>,std::allocator<unsigned int> >(const std::basic_string<unsigned int,std::char_traits<unsigned int>,std::allocator<unsigned int> > & _Right)  Line 546   C++
    sfml-system-d-2.dll!sf::String::String(const sf::String & copy)  Line 132   C++
    sfml-graphics-d-2.dll!sf::Text::Text(const sf::String & string, const sf::Font & font, unsigned int characterSize)  Line 59 + 0x74 bytes   C++
    MoonEnginev2.exe!moon::Draw::DrawText(moon::Window * pTarget, std::basic_string<char,std::char_traits<char>,std::allocator<char> > pText, int pX, int pY, moon::Colour pCol)  Line 33 + 0x61 bytes   C++


Running on Windows 7 with a Nvidia graphics card, using the latest revision off github.
Title: Access violation with sf::Text in SFML2.0
Post by: Laurent on January 31, 2012, 11:03:35 pm
Which CMake options did you use to compile SFML?
Title: Access violation with sf::Text in SFML2.0
Post by: TrapAlice on February 01, 2012, 10:19:55 pm
What I have in CMake is:
(http://i44.tinypic.com/2wfn0k6.png)
Title: Access violation with sf::Text in SFML2.0
Post by: Laurent on February 02, 2012, 07:52:38 am
Hmm... your screenshot shows "Release" but the DLL name (sfml-system-d-2.dll) implies Debug.
Title: Access violation with sf::Text in SFML2.0
Post by: TrapAlice on February 02, 2012, 11:45:02 am
Tried changing it from Release to Debug, still has the same problem.
Title: Access violation with sf::Text in SFML2.0
Post by: Laurent on February 02, 2012, 11:54:33 am
My point was that your CMake settings don't match the DLL that causes the error. So make sure that you're really using the DLLs that you recompiled, and not an older version that would be lost somewhere on your hard drive.

Even your callstack doesn't match the code that you're showing.

Please provide consistent information, otherwise we won't be able to help you.
Title: Access violation with sf::Text in SFML2.0
Post by: TrapAlice on February 02, 2012, 02:01:51 pm
It was a complete screw up I've made, I was including the release libs but using the debug dlls..
Title: Access violation with sf::Text in SFML2.0
Post by: Laurent on February 02, 2012, 02:04:26 pm
Quote
It was a complete screw up I've made, I was including the release libs but using the debug dlls..

It is nearly impossible to mix the debug and release DLLs, they have a different name. The only way to screw up is to add/remove the "-d" suffix yourself.