c++ - Getting an EXC_BAD_ACCES error running app template code -
preliminary details:
- os x 10.11
- xcode 7.2
- sfml 2.3.2
- clang c++11
- default sfml app template
problem:
i have done fresh install of sfml, double checked , triple checked of required files in correct places.
when build , run stock, sfml app template xcode, exc_bad_access on line 81 of file (line 81: window.draw(sprite); - commented clearly):
// // disclamer: // ---------- // // code work if selected window, graphics , audio. // // note "run script" build phase copy required frameworks // or dylibs application bundle can execute on os x // computer. // // resource files (images, sounds, fonts, ...) copied // application bundle. path these resource, use helper // method resourcepath() resourcepath.hpp // #include <sfml/audio.hpp> #include <sfml/graphics.hpp> // here small helper ! have look. #include "resourcepath.hpp" int main(int, char const**) { // create main window sf::renderwindow window(sf::videomode(800, 600), "sfml window"); // set icon sf::image icon; if (!icon.loadfromfile(resourcepath() + "icon.png")) { return exit_failure; } window.seticon(icon.getsize().x, icon.getsize().y, icon.getpixelsptr()); // load sprite display sf::texture texture; if (!texture.loadfromfile(resourcepath() + "cute_image.jpg")) { return exit_failure; } sf::sprite sprite(texture); // create graphical text display sf::font font; if (!font.loadfromfile(resourcepath() + "sansation.ttf")) { return exit_failure; } sf::text text("hello sfml", font, 50); text.setcolor(sf::color::black); // load music play sf::music music; if (!music.openfromfile(resourcepath() + "nice_music.ogg")) { return exit_failure; } // play music music.play(); // start game loop while (window.isopen()) { // process events sf::event event; while (window.pollevent(event)) { // close window: exit if (event.type == sf::event::closed) { window.close(); } // escape pressed: exit if (event.type == sf::event::keypressed && event.key.code == sf::keyboard::escape) { window.close(); } } // clear screen window.clear(); // draw sprite window.draw(sprite); // -------------- line 81 // draw string window.draw(text); // update window window.display(); } return exit_success; } what i've tried
i have searched online (including posts), common cause seems kind of stack overflow. can't see cause stack overflow in above program knowledge.
if kind of error of sfml's forums, you'll see due old header/binary files being present on system , being used instead of newer ones.
make sure removed all versions of sfml before installing latest one. per installing sfml tutorial, need in:
/usr/local/include/usr/local/lib/library/frameworks
Comments
Post a Comment