Problem with MakeFile

Hi, I'm doing a project and I added some new classes. The problem is that now the MakeFile is getting some errors!!! :(



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
g++ -g -Wall -c main.cpp
g++ -g -Wall -c ResourceHolder.cpp
g++ -g -Wall -c World.cpp
g++    -c -o Aircraft.o Aircraft.cpp
g++ -g -Wall -c Entity.cpp
g++ -g -Wall -c SceneNode.cpp
g++ -g -Wall -c Game.cpp
In file included from Game.cpp:1:0:
Game.hpp: In constructor ‘Game::Game()’:
Game.hpp:38:17: warning: ‘Game::mStatisticsNumFrames’ will be initialized after [-Wreorder]
   std::size_t   mStatisticsNumFrames;
                 ^~~~~~~~~~~~~~~~~~~~
Game.hpp:33:13: warning:   ‘World Game::mWorld’ [-Wreorder]
   World     mWorld;
             ^~~~~~
Game.cpp:9:1: warning:   when initialized here [-Wreorder]
 Game::Game()
 ^~~~
Game.cpp: In member function ‘void Game::processEvents()’:
Game.cpp:55:10: warning: enumeration value ‘Resized’ not handled in switch [-Wswitch]
   switch (event.type)
          ^
Game.cpp:55:10: warning: enumeration value ‘LostFocus’ not handled in switch [-Wswitch]
Game.cpp:55:10: warning: enumeration value ‘GainedFocus’ not handled in switch [-Wswitch]
Game.cpp:55:10: warning: enumeration value ‘TextEntered’ not handled in switch [-Wswitch]
Game.cpp:55:10: warning: enumeration value ‘MouseWheelMoved’ not handled in switch [-Wswitch]
Game.cpp:55:10: warning: enumeration value ‘MouseWheelScrolled’ not handled in switch [-Wswitch]
Game.cpp:55:10: warning: enumeration value ‘MouseButtonPressed’ not handled in switch [-Wswitch]
Game.cpp:55:10: warning: enumeration value ‘MouseButtonReleased’ not handled in switch [-Wswitch]
Game.cpp:55:10: warning: enumeration value ‘MouseMoved’ not handled in switch [-Wswitch]
Game.cpp:55:10: warning: enumeration value ‘MouseEntered’ not handled in switch [-Wswitch]
Game.cpp:55:10: warning: enumeration value ‘MouseLeft’ not handled in switch [-Wswitch]
Game.cpp:55:10: warning: enumeration value ‘JoystickButtonPressed’ not handled in switch [-Wswitch]
Game.cpp:55:10: warning: enumeration value ‘JoystickButtonReleased’ not handled in switch [-Wswitch]
Game.cpp:55:10: warning: enumeration value ‘JoystickMoved’ not handled in switch [-Wswitch]
Game.cpp:55:10: warning: enumeration value ‘JoystickConnected’ not handled in switch [-Wswitch]
Game.cpp:55:10: warning: enumeration value ‘JoystickDisconnected’ not handled in switch [-Wswitch]
Game.cpp:55:10: warning: enumeration value ‘TouchBegan’ not handled in switch [-Wswitch]
Game.cpp:55:10: warning: enumeration value ‘TouchMoved’ not handled in switch [-Wswitch]
Game.cpp:55:10: warning: enumeration value ‘TouchEnded’ not handled in switch [-Wswitch]
Game.cpp:55:10: warning: enumeration value ‘SensorChanged’ not handled in switch [-Wswitch]
Game.cpp:55:10: warning: enumeration value ‘Count’ not handled in switch [-Wswitch]
g++ -g main.o ResourceHolder.o World.o Aircraft.o Entity.o SceneNode.o Game.o -lsfml-graphics -lsfml-window -lsfml-system -lsfml-audio -o output
World.o: In function `World::loadTextures()':
/home/albert/Projects/SFML_tutorial/World.cpp:53: undefined reference to `ResourceHolder<sf::Texture, Textures::ID>::load(Textures::ID, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/home/albert/Projects/SFML_tutorial/World.cpp:54: undefined reference to `ResourceHolder<sf::Texture, Textures::ID>::load(Textures::ID, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/home/albert/Projects/SFML_tutorial/World.cpp:55: undefined reference to `ResourceHolder<sf::Texture, Textures::ID>::load(Textures::ID, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
World.o: In function `World::buildScene()':
/home/albert/Projects/SFML_tutorial/World.cpp:70: undefined reference to `ResourceHolder<sf::Texture, Textures::ID>::get(Textures::ID)'
/home/albert/Projects/SFML_tutorial/World.cpp:75: undefined reference to `SpriteNode::SpriteNode(sf::Texture const&, sf::Rect<int> const&)'
Aircraft.o: In function `Aircraft::Aircraft(Aircraft::Type, ResourceHolder<sf::Texture, Textures::ID> const&)':
Aircraft.cpp:(.text+0x94): undefined reference to `ResourceHolder<sf::Texture, Textures::ID>::get(Textures::ID) const'
collect2: error: ld returned 1 exit status
Makefile:4: recipe for target 'output' failed
make: *** [output] Error 1 


The above is the error that shows when I do make.

The project is in this repo -> https://github.com/lazaro92/SFML_tutorial/ on the branch development.

I think is not a good idea to post the entire code here.

Anyone know which is the problem?
My makeFile is this (also it is inside the repo):

The principal problem I have to detect errors is that I'm novice with C++


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
output: main.o ResourceHolder.o World.o Aircraft.o Entity.o SceneNode.o Game.o 
	g++ -g main.o ResourceHolder.o World.o Aircraft.o Entity.o SceneNode.o Game.o -lsfml-graphics -lsfml-window -lsfml-system -lsfml-audio -o output

main.o: main.cpp
	g++ -g -Wall -c main.cpp

Aircaft.o: Aircaft.cpp Aircraft.hpp ResourceHolder.hpp
	g++ -g -Wall -c Aircaft.cpp

Entity.o: Entity.cpp Entity.hpp
	g++ -g -Wall -c Entity.cpp

SceneNode.o: SceneNode.cpp SceneNode.hpp
	g++ -g -Wall -c SceneNode.cpp

World.o: World.cpp World.hpp
	g++ -g -Wall -c World.cpp

Game.o: Game.cpp Game.hpp 
	g++ -g -Wall -c Game.cpp

ResourceHolder.o: ResourceHolder.cpp ResourceHolder.hpp
	g++ -g -Wall -c ResourceHolder.cpp

clean:
	rm *.o

> undefined reference to `ResourceHolder<sf::Texture, Textures::ID>::load
you may use `nm' and see that ResourceHolder.o is basically empty
http://www.cplusplus.com/forum/general/113904/#msg622073
put the template code in the header

> undefined reference to `SpriteNode::SpriteNode
http://www.cplusplus.com/forum/general/113904/#msg622050
did a simple search and couldn't find the implementation of the constructors
Ok thanks!

The first problem I saw that in the code that I downloaded from the web of the book it uses an #include "ResourceHolder.inl" . I never saw an inl file but I imagine it's use.

The second one is a fail XD

Thanks a lot!!!

This weekend I will document all the code to finish understanding it. The problem is that I have had a little time to work on this.
Last edited on
> it uses an #include "ResourceHolder.inl" . I never saw an inl file but I imagine it's use.
perhaps the inline functions implementations
#include is simply copy-paste and extensions are meaningless

> https://github.com/lazaro92/SFML_tutorial/
¿did you remove the repository? ¿why?
I changed it to private because it is based on a tutorial book, so in fact I (think) don't have the rights to publish it
Topic archived. No new replies allowed.