This isn't specifically an SFML thing, but it is somewhat involved with how SFML compilation is done on linux g++, so I thought this would be a good place to start.
Im developing a game engine to simulate basic newtonian mechanics in 2d spaceflight games (ie like lunar lander)
https://github.com/BruceJohnJennerLawso/Ignition_Engine/releases/tag/0.01The above link is to a zip package containing the relevant source that Im trying to compile for the first time. I have SFML 2.1 set up and working properly on Crunchbang Linux. I spent a great deal of time rooting out bugs in my code, but once I got it to compile properly, it gave me some errors at link time:
Final_frontier.o: In function `Inertia_moment::Inertia_moment()':
Final_frontier.cpp:(.text+0x3e91): undefined reference to `vtable for Inertia_moment'
Final_frontier.o: In function `Inertia_moment::~Inertia_moment()':
Final_frontier.cpp:(.text+0x3ebb): undefined reference to `vtable for Inertia_moment'
Final_frontier.o: In function `CSimulation_Object::CSimulation_Object()':
Final_frontier.cpp:(.text+0x5985): undefined reference to `vtable for CSimulation_Object'
Final_frontier.o: In function `CSimulation_Object::~CSimulation_Object()':
Final_frontier.cpp:(.text+0x5a57): undefined reference to `vtable for CSimulation_Object'
Final_frontier.o: In function `Resource_type::Resource_type()':
Final_frontier.cpp:(.text+0x64e5): undefined reference to `vtable for Resource_type'
Final_frontier.o: In function `Resource_type::~Resource_type()':
Final_frontier.cpp:(.text+0x64fb): undefined reference to `vtable for Resource_type'
Final_frontier.o: In function `Resource_hydrogen::Resource_hydrogen()':
Final_frontier.cpp:(.text+0x6521): undefined reference to `vtable for Resource_hydrogen'
Final_frontier.cpp:(.text+0x6532): undefined reference to `Resource_type::R'
Final_frontier.cpp:(.text+0x6615): undefined reference to `Resource_hydrogen::Hydrogen_properties'
Final_frontier.o: In function `Resource_hydrogen::~Resource_hydrogen()':
Final_frontier.cpp:(.text+0x6633): undefined reference to `vtable for Resource_hydrogen'
Final_frontier.o: In function `Resource_oxygen::Resource_oxygen()':
Final_frontier.cpp:(.text+0x6673): undefined reference to `vtable for Resource_oxygen'
Final_frontier.cpp:(.text+0x6684): undefined reference to `Resource_type::R'
Final_frontier.cpp:(.text+0x6767): undefined reference to `Resource_oxygen::Oxygen_properties'
Final_frontier.o: In function `Resource_oxygen::~Resource_oxygen()':
Final_frontier.cpp:(.text+0x6785): undefined reference to `vtable for Resource_oxygen'
Final_frontier.o: In function `Resource_water::Resource_water()':
Final_frontier.cpp:(.text+0x67c5): undefined reference to `vtable for Resource_water'
Final_frontier.cpp:(.text+0x67d6): undefined reference to `Resource_type::R'
Final_frontier.cpp:(.text+0x68b9): undefined reference to `Resource_water::Water_properties'
Final_frontier.o: In function `Resource_water::~Resource_water()':
Final_frontier.cpp:(.text+0x68d7): undefined reference to `vtable for Resource_water'
Final_frontier.o: In function `Engine_type::Engine_type()':
Final_frontier.cpp:(.text+0x69cf): undefined reference to `vtable for Engine_type'
Final_frontier.o: In function `Engine_type::~Engine_type()':
Final_frontier.cpp:(.text+0x69f9): undefined reference to `vtable for Engine_type'
Final_frontier.o: In function `Engine_type_lox_lh2::Engine_type_lox_lh2()':
Final_frontier.cpp:(.text+0x6a66): undefined reference to `Engine_type_lox_lh2::Maximum_exhaust_velocity'
Final_frontier.cpp:(.text+0x6a77): undefined reference to `Engine_type_lox_lh2::Optimal_mix_ratio'
Final_frontier.cpp:(.text+0x6a88): undefined reference to `Engine_type_lox_lh2::Drop_off_constant'
Final_frontier.o: In function `Engine_type_lox_lh2::Get_maximum_exhaust_velocity()':
Final_frontier.cpp:(.text+0x6ae5): undefined reference to `Engine_type_lox_lh2::Maximum_exhaust_velocity'
Final_frontier.o: In function `Engine_type_lox_lh2::Get_optimal_mix_ratio()':
Final_frontier.cpp:(.text+0x6aff): undefined reference to `Engine_type_lox_lh2::Optimal_mix_ratio'
Final_frontier.o: In function `Engine_type_lox_lh2::Get_exhaust_velocity(double)':
Final_frontier.cpp:(.text+0x6b23): undefined reference to `Engine_type_lox_lh2::Optimal_mix_ratio'
Final_frontier.cpp:(.text+0x6b38): undefined reference to `Engine_type_lox_lh2::Maximum_exhaust_velocity'
Final_frontier.cpp:(.text+0x6b42): undefined reference to `Engine_type_lox_lh2::Optimal_mix_ratio'
Final_frontier.cpp:(.text+0x6b58): undefined reference to `Engine_type_lox_lh2::Drop_off_constant'
Final_frontier.cpp:(.text+0x6b75): undefined reference to `Engine_type_lox_lh2::Maximum_exhaust_velocity'
Final_frontier.o: In function `Engine_type_lh2_antimatter::Engine_type_lh2_antimatter()':
Final_frontier.cpp:(.text+0x6c1c): undefined reference to `Engine_type_lh2_antimatter::Maximum_exhaust_velocity'
Final_frontier.cpp:(.text+0x6c28): undefined reference to `Engine_type_lh2_antimatter::Optimal_mix_ratio'
Final_frontier.cpp:(.text+0x6c34): undefined reference to `Engine_type_lh2_antimatter::Drop_off_constant'
Final_frontier.o: In function `Engine_type_lh2_antimatter::Get_maximum_exhaust_velocity()':
Final_frontier.cpp:(.text+0x6c7d): undefined reference to `Engine_type_lh2_antimatter::Maximum_exhaust_velocity'
Final_frontier.o: In function `Engine_type_lh2_antimatter::Get_exhaust_velocity(double)':
Final_frontier.cpp:(.text+0x6cb4): undefined reference to `Engine_type_lh2_antimatter::Maximum_exhaust_velocity'
Final_frontier.o: In function `Vessel_component::Vessel_component()':
Final_frontier.cpp:(.text+0x6ebd): undefined reference to `vtable for Vessel_component'
Final_frontier.o: In function `Vessel_component::~Vessel_component()':
Final_frontier.cpp:(.text+0x6ef5): undefined reference to `vtable for Vessel_component'
Final_frontier.o: In function `Thruster::Set_throttle(double)':
Final_frontier.cpp:(.text+0x88f3): undefined reference to `Throttle::Set_throttle_value(long double)'
Final_frontier.o:(.rodata._ZTV15Armstrong_class[_ZTV15Armstrong_class]+0x58): undefined reference to `Vessel_I::Process_input_events(double, key_commands*)'
Final_frontier.o:(.rodata._ZTV8Vessel_I[_ZTV8Vessel_I]+0x58): undefined reference to `Vessel_I::Process_input_events(double, key_commands*)'
Final_frontier.o:(.rodata._ZTV17CNewtonian_Object[_ZTV17CNewtonian_Object]+0x50): undefined reference to `CSimulation_Object::Set_theta(long double)'
Final_frontier.o:(.rodata._ZTV17CNewtonian_Object[_ZTV17CNewtonian_Object]+0x58): undefined reference to `CSimulation_Object::Process_input_events(double, key_commands*)'
Final_frontier.o:(.rodata._ZTV17CNewtonian_Object[_ZTV17CNewtonian_Object]+0x68): undefined reference to `CSimulation_Object::Draw_object_image(SFML_Window*)'
Final_frontier.o:(.rodata._ZTV17CNewtonian_Object[_ZTV17CNewtonian_Object]+0x70): undefined reference to `CSimulation_Object::Draw_flag(SFML_Window*, int)'
Final_frontier.o:(.rodata._ZTV7TPlanet[_ZTV7TPlanet]+0x10): undefined reference to `TPlanet::Get_object_name()'
Final_frontier.o:(.rodata._ZTV7TPlanet[_ZTV7TPlanet]+0x20): undefined reference to `TPlanet::Get_mass()'
Final_frontier.o:(.rodata._ZTV7TPlanet[_ZTV7TPlanet]+0x28): undefined reference to `TPlanet::Get_x_position()'
Final_frontier.o:(.rodata._ZTV7TPlanet[_ZTV7TPlanet]+0x30): undefined reference to `TPlanet::Get_y_position()'
Final_frontier.o:(.rodata._ZTV7TPlanet[_ZTV7TPlanet]+0x38): undefined reference to `TPlanet::Get_theta()'
Final_frontier.o:(.rodata._ZTV7TPlanet[_ZTV7TPlanet]+0x40): undefined reference to `TPlanet::Set_x_position(long double)'
Final_frontier.o:(.rodata._ZTV7TPlanet[_ZTV7TPlanet]+0x48): undefined reference to `TPlanet::Set_y_position(long double)'
Final_frontier.o:(.rodata._ZTV7TPlanet[_ZTV7TPlanet]+0x50): undefined reference to `TPlanet::Set_theta(long double)'
Final_frontier.o:(.rodata._ZTV7TPlanet[_ZTV7TPlanet]+0x58): undefined reference to `CSimulation_Object::Process_input_events(double, key_commands*)'
Final_frontier.o:(.rodata._ZTV17CKeplerian_Object[_ZTV17CKeplerian_Object]+0x10): undefined reference to `CKeplerian_Object::Get_object_name()'
Final_frontier.o:(.rodata._ZTV17CKeplerian_Object[_ZTV17CKeplerian_Object]+0x50): undefined reference to `CSimulation_Object::Set_theta(long double)'
Final_frontier.o:(.rodata._ZTV17CKeplerian_Object[_ZTV17CKeplerian_Object]+0x58): undefined reference to `CSimulation_Object::Process_input_events(double, key_commands*)'
Final_frontier.o:(.rodata._ZTV17CKeplerian_Object[_ZTV17CKeplerian_Object]+0x68): undefined reference to `CSimulation_Object::Draw_object_image(SFML_Window*)'
Final_frontier.o:(.rodata._ZTV17CKeplerian_Object[_ZTV17CKeplerian_Object]+0x70): undefined reference to `CSimulation_Object::Draw_flag(SFML_Window*, int)'
Final_frontier.o:(.rodata._ZTV17CKeplerian_Object[_ZTV17CKeplerian_Object]+0x80): undefined reference to `CKeplerian_Object::Update_rotation(double)'
Final_frontier.o:(.rodata._ZTI17CNewtonian_Object[_ZTI17CNewtonian_Object]+0x10): undefined reference to `typeinfo for CSimulation_Object'
Final_frontier.o:(.rodata._ZTI8Thruster[_ZTI8Thruster]+0x10): undefined reference to `typeinfo for Vessel_component'
Final_frontier.o:(.rodata._ZTI13Resource_Tank[_ZTI13Resource_Tank]+0x10): undefined reference to `typeinfo for Vessel_component'
Final_frontier.o:(.rodata._ZTI4Hull[_ZTI4Hull]+0x10): undefined reference to `typeinfo for Vessel_component'
Final_frontier.o:(.rodata._ZTI26Engine_type_lh2_antimatter[_ZTI26Engine_type_lh2_antimatter]+0x10): undefined reference to `typeinfo for Engine_type'
Final_frontier.o:(.rodata._ZTI19Engine_type_lox_lh2[_ZTI19Engine_type_lox_lh2]+0x10): undefined reference to `typeinfo for Engine_type'
Final_frontier.o:(.rodata._ZTI17CKeplerian_Object[_ZTI17CKeplerian_Object]+0x10): undefined reference to `typeinfo for CSimulation_Object'
Final_frontier.o:(.rodata._ZTI11Inertia_box[_ZTI11Inertia_box]+0x10): undefined reference to `typeinfo for Inertia_moment'
Final_frontier.o:(.rodata._ZTI14Inertia_sphere[_ZTI14Inertia_sphere]+0x10): undefined reference to `typeinfo for Inertia_moment'
Final_frontier.o:(.rodata._ZTI16Inertia_cylinder[_ZTI16Inertia_cylinder]+0x10): undefined reference to `typeinfo for Inertia_moment'
Final_frontier.o:(.rodata._ZTI15Inertia_complex[_ZTI15Inertia_complex]+0x10): undefined reference to `typeinfo for Inertia_moment'
collect2: error: ld returned 1 exit status
I checked the undefined reference to vtable error, but it doesnt appear to make sense in this context. If the cpp files include each other one by one, all of the code should be properly included in the Final_frontier.o object, but the compiler appears to not be able to find the code needed in the code produced by the compiler.
my scripts for compiling and linking are as follows:
#!/bin/bash
g++ -c -std=c++0x Final_frontier.cpp
exit 0
#!/bin/bash
g++ Final_frontier.o -o Final_frontier -lsfml-graphics -lsfml-window -lsfml-system -lsfml-audio
exit 0
Where am I going wrong here? Is there just something stupid that I have done in my code, or am I not understanding the compilation & linking process?