Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Trying to compile a large project in g++  (Read 2327 times)

0 Members and 1 Guest are viewing this topic.

BruceJohnJennerLawso

  • Jr. Member
  • **
  • Posts: 55
    • View Profile
    • My Code on Github
Trying to compile a large project in g++
« on: May 18, 2014, 06:57:45 pm »
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.01

The 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?
Quote
The computer is mightier than the pen, the sword, and usually the programmer.

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
Re: Trying to compile a large project in g++
« Reply #1 on: May 18, 2014, 08:19:49 pm »
http://stackoverflow.com/questions/3065154/undefined-reference-to-vtable

This took me 20 seconds to find using Google by the way...
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).

BruceJohnJennerLawso

  • Jr. Member
  • **
  • Posts: 55
    • View Profile
    • My Code on Github
Re: Trying to compile a large project in g++
« Reply #2 on: May 19, 2014, 03:09:29 am »
http://stackoverflow.com/questions/3065154/undefined-reference-to-vtable

This took me 20 seconds to find using Google by the way...

That wasn't one of the results my search gave me  ::). Most of what I saw seemed to indicate that it was an issue with not compiling properly.

But I didnt declare any virtual destructors. What caused it in this case?

Edit: just realized, it wants any non-pure virtual methods defined. Im assuming that the compiler would want a virtual destructor for the class to be considered pure virtual?
« Last Edit: May 19, 2014, 03:28:42 am by BruceJohnJennerLawso »
Quote
The computer is mightier than the pen, the sword, and usually the programmer.

select_this

  • Full Member
  • ***
  • Posts: 130
  • Current mood: just ate a pinecone
    • View Profile
    • darrenferrie.com
Re: Trying to compile a large project in g++
« Reply #3 on: May 19, 2014, 10:33:08 am »
But I didnt declare any virtual destructors. What caused it in this case?

Edit: just realized, it wants any non-pure virtual methods defined. Im assuming that the compiler would want a virtual destructor for the class to be considered pure virtual?

Normally, in a class that is intended to be derived from (assuming it is a non-zero sized class), it is required to declare and define a virtual destructor. Please see guideline #4 on http://www.gotw.ca/publications/mill18.htm.
Follow me on Twitter, why don'tcha? @select_this

 

anything