c++ - I can't compile example code, SFML -


i saw similiar problem, didn't solved me problem. can't compile example code http://www.sfml-dev.org/tutorials/2.3/start-linux.php . following instructions still have error:

in 1 before last step wrote : g++ sfml.o -o sfml-app -l /home/documents/sfml/sfml-2.1/lib -lsfml-graphics -lsfml-window -lsfml-system

and got this:

sfml.o: in function main': 

sfml.cpp:(.text+0x12d): undefined reference sf::renderwindow::renderwindow(sf::videomode, sf::string const&, unsigned int, sf::contextsettings const&)' collect2: ld returned 1 exit status

can me that?

it seems have't linked sfml libraries program. further down page (just after code snippet), page further describes:

you must link compiled file sfml libraries in order final executable. sfml made of 5 modules (system, window, graphics, network , audio), , there's 1 library each of them. link sfml library, must add "-lsfml-xxx" command line, example "-lsfml-graphics" graphics module (the "lib" prefix , ".so" extension of library file name must omitted).

g++ main.o -o sfml-app -lsfml-graphics -lsfml-window -lsfml-system

if installed sfml non-standard path, you'll need tell linker find sfml libraries (.so files):

g++ main.o -o sfml-app -l<sfml-install-path>/lib -lsfml-graphics -lsfml-window -lsfml-system

although have included linking in command line, best guess linker cannot find libraries still, why sf::renderwindow undefined (it's declared, compiler knows , compiles successfully, cannot link because linker can't find reference it)


Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -