Finally completed section 6 of my C++ course. It was rough. I ran into several issues that the instructor did not explain, because he is using Windows Microsoft Visual Studio, and I am using Geany on Linux.

I guess there are some things that just get taken for granted when you are building on Windows. Essentially, when you include header files in Visual Studio, it auto-magically (yes, it’s a word) links everything together. I could do the same in Linux, if I set up a proper Makefile.

Due to my niavete, I had to search the web a lot for this one. Figured it out, so I can let you in on the secret:

#!/bin/bash

# You need libsfml installed on your system!

g++ -I./ -fpermissive -Wall -Wextra -g -c -std=c++11 Player.cpp -o Player.o
g++ -I./ -fpermissive -Wall -Wextra -g -c -std=c++11 JelloStorm.cpp -o JelloStorm.o

g++ JelloStorm.o Player.o -o JelloStorm-app -lsfml-graphics -lsfml-window -lsfml-system -lsfml-audio

./JelloStorm-app

echo “type ./JelloStorm-app to launch”
exit

If you use header files in Linux, you need to include them with the -I option. That solved my first problem, then I needed to fix two more.

The second problem seems to be with the code, but I couldn’t quite figure it out. It was an error that ISO standards require a type to be set for Player(). I started using -fpermissive which seemed to negate that. The course was written a while ago, so I guess that there is a newer, better way to do this. In any event, now that the third problem is fixed, it went away.

After this, the game would load, but the player character (an archer) would not display. This lead to the third problem… which was the title problem:

Player.cpp:6:16: error: no ‘int Player::player()’ member function declared in class ‘Player’

This error was giving me fits. I looked things over for hours, searched the web, compared my hand typed code to the instructors code line by line. Finally, it hit me: Player::player()! This needed to be Player::Player()! I forgot to upper case one letter, and it boiled down to that!

The compiler was right, there was no “player” member in the class, because it was declared as “Player”!!!!

Screenshot from 2018-05-16 11-45-42

If you look really close, there is an archer standing there.

You can check out the commit on my GitLab, hopefully soon I’ll be adding jello to storm my character!

Linux – keep it simple.

Leave a Reply

Your email address will not be published. Required fields are marked *