Note that there are some explanatory texts on larger screens.

plurals
  1. POLinking is not working properly
    primarykey
    data
    text
    <pre><code>project (2dplatformer) cmake_minimum_required (VERSION 2.8) set(CMAKE_MODULE_PATH ${sfmle_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH}) find_package(SFML 2.0 REQUIRED audio graphics network system window) include_directories (${SFML_INCLUDE_DIR}) link_libraries (${SFML_LIBRARIES}) add_library (Tilemap.o src/Tilemap.cpp) add_library (State.o src/State.cpp) add_library (TitleState.o src/TitleState.cpp) add_library (PlayState.o src/PlayState.cpp) add_library (Player.o src/Player.cpp) add_executable (2dplatformer src/Game.cpp) target_link_libraries (2dplatformer sfml-audio sfml-system sfml-graphics sfml-window Player.o PlayState.o Tilemap.o State.o TitleState.o) </code></pre> <p>That is my CMakeLists.txt, which I'm using to build my project.</p> <pre><code>[ 16%] Built target TitleState.o [ 33%] Built target Tilemap.o [ 50%] Built target Player.o [ 66%] Built target PlayState.o [ 83%] Built target State.o Linking CXX executable 2dplatformer libPlayState.o.a(PlayState.cpp.o): In function `PlayState::PlayState(Game*)': PlayState.cpp:(.text+0x286): undefined reference to `Player::Player(Game*, Tilemap*)' libPlayState.o.a(PlayState.cpp.o): In function `PlayState::update()': PlayState.cpp:(.text+0x378): undefined reference to `Player::update()' libPlayState.o.a(PlayState.cpp.o): In function `PlayState::draw()': PlayState.cpp:(.text+0x44f): undefined reference to `Player::draw()' collect2: error: ld returned 1 exit status make[2]: *** [2dplatformer] Error 1 make[1]: *** [CMakeFiles/2dplatformer.dir/all] Error 2 make: *** [all] Error 2 </code></pre> <p>My game works just fine when I use this very badly written Makefile:</p> <pre><code>LIBS=-lsfml-graphics -lsfml-window -lsfml-system all: @echo "*** Building the game" g++ -c "src/Tilemap.cpp" -o "build/Tilemap.o" g++ -c "src/State.cpp" -o "build/State.o" g++ -c "src/TitleState.cpp" -o "build/TitleState.o" g++ -c "src/PlayState.cpp" -o "build/PlayState.o" g++ -c "src/Game.cpp" -o "build/Game.o" g++ -c "src/Player.cpp" -o "build/Player.o" g++ -o 2dplatformer build/Tilemap.o build/Game.o build/State.o build/Player.o build/TitleState.o build/PlayState.o $(LIBS) map_editor: @echo "*** Building the level editor" g++ -c "src/Tilemap.cpp" -o "build/Tilemap.o" g++ -c "src/Editor.cpp" -o "build/Editor.o" g++ -o editor build/Tilemap.o build/Editor.o $(LIBS) clean: @echo "*** Removing object files and executable..." rm -rf build/* rm -f 2dplatformer </code></pre> <p>I am linking the libraries, so I can't tell why it can't find them.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload