FlappingBird icon indicating copy to clipboard operation
FlappingBird copied to clipboard

make error

Open khanhnb opened this issue 11 years ago • 13 comments

I installed curl, xorg-dev and libglu1-mesa-dev and then make but it failed. Here is output: build/main.o: In function main': main.cpp:(.text+0x40): undefined reference tosge::Game::run()' build/Pipe.o: In function Pipe::Pipe(sge::Vector2 const&, sge::Sprite const*, sge::Sprite const*)': Pipe.cpp:(.text+0x43): undefined reference tosge::Rectangle::Rectangle(float, float, float, float)' ..................................................... collect2: error: ld returned 1 exit status make: *** [flappingbird] Error 1

khanhnb avatar Mar 03 '14 18:03 khanhnb

Did you remember to use git clone --recurse-submodules https://github.com/C0deH4cker/FlappingBird.git when cloning? Or at least git submodule update --init --recursive after cloning?

C0deH4cker avatar Mar 04 '14 19:03 C0deH4cker

I used git clone --recurse-submodules https://github.com/C0deH4cker/FlappingBird to clone before. But it still had error. It seems to be a problem with libsge.a lib. I built it on Ubuntu, is it different ??

khanhnb avatar Mar 05 '14 05:03 khanhnb

Hmm, it should be fine. Try deleting the whole repo, cloning it again, and cd into FlappingBird/SimpleGameEngine before running make. If it works, then try make in FlappingBird. If you still get errors, paste them here.

C0deH4cker avatar Mar 05 '14 15:03 C0deH4cker

I still get this error In function Bird::Bird(sge::Texture2D const*, float)': Bird.cpp:(.text+0x63): undefined reference tosge::Vector2::Vector2(float)' Bird.cpp:(.text+0x7f): undefined reference to sge::Rectangle::Rectangle(float, float, float, float)' Bird.cpp:(.text+0xb1): undefined reference tosge::Timer::Timer()' Bird.cpp:(.text+0xc1): undefined reference to sge::Timer::Timer()' Bird.cpp:(.text+0xed): undefined reference tosge::Rectangle::Rectangle(float, float, float, float)' Bird.cpp:(.text+0x121): undefined reference to sge::Sprite::Sprite(sge::Texture2D const*, sge::Rectangle)' Bird.cpp:(.text+0x14d): undefined reference tosge::Rectangle::Rectangle(float, float, float, float)' Bird.cpp:(.text+0x181): undefined reference to sge::Sprite::Sprite(sge::Texture2D const*, sge::Rectangle)' Bird.cpp:(.text+0x1ad): undefined reference tosge::Rectangle::Rectangle(float, float, float, float)' Bird.cpp:(.text+0x1e1): undefined reference to sge::Sprite::Sprite(sge::Texture2D const*, sge::Rectangle)' Bird.cpp:(.text+0x1e6): undefined reference tosge::Game::instance()' Bird.cpp:(.text+0x1fa): undefined reference to sge::Window::getWidth()' Bird.cpp:(.text+0x23a): undefined reference tosge::Window::getHeight()' Bird.cpp:(.text+0x2f9): undefined reference to sge::Rectangle::topLeft() const' Bird.cpp:(.text+0x310): undefined reference tosge::Vector2::operator=(sge::Vector2 const&)' Bird.cpp:(.text+0x31c): undefined reference to sge::Vector2::~Vector2()' Bird.cpp:(.text+0x336): undefined reference tosge::Vector2::~Vector2()' Bird.cpp:(.text+0x34b): undefined reference to sge::Vector2::~Vector2()' build/Bird.o: In functionBird::update(double)': Bird.cpp:(.text+0x487): undefined reference to sge::Rectangle::midY() const' build/Bird.o: In functionBird::draw(double)': Bird.cpp:(.text+0x577): undefined reference to sge::Timer::elapsed() const' Bird.cpp:(.text+0x6c8): undefined reference tosge::Sprite::draw(sge::Rectangle const&, float) const' Bird.cpp:(.text+0x77e): undefined reference to sge::Sprite::draw(sge::Rectangle const&, float) const' build/Bird.o: In functionBird::flap()': Bird.cpp:(.text+0x7ba): undefined reference to sge::Timer::reset()' Bird.cpp:(.text+0x7ca): undefined reference tosge::Timer::reset()' Bird.cpp:(.text+0x7da): undefined reference to sge::Rectangle::top() const' build/Bird.o: In functionBird::reset()': Bird.cpp:(.text+0x863): undefined reference to sge::Timer::reset()' Bird.cpp:(.text+0x873): undefined reference tosge::Timer::reset()' build/Bird.o: In function Bird::pause()': Bird.cpp:(.text+0x8d0): undefined reference tosge::Timer::pause()' Bird.cpp:(.text+0x8e0): undefined reference to sge::Timer::pause()' build/Bird.o: In functionBird::resume()': Bird.cpp:(.text+0x906): undefined reference to sge::Timer::resume()' Bird.cpp:(.text+0x916): undefined reference tosge::Timer::resume()' build/Bird.o: In function Bird::getBBox() const': Bird.cpp:(.text+0x9c2): undefined reference tosge::Rectangle::Rectangle(float, float, float, float)' build/Bird.o: In function Bird::getRotation() const': Bird.cpp:(.text+0xa4e): undefined reference tosge::Timer::elapsed() const' build/Bird.o: In function Bird::getFrame()': Bird.cpp:(.text+0xbe9): undefined reference tosge::Timer::elapsed() const' Bird.cpp:(.text+0xcba): undefined reference to sge::Timer::reset()' build/FlappingBird.o: In functionFlappingBird::FlappingBird()': FlappingBird.cpp:(.text+0x76): undefined reference to sge::Content::Content(std::string)' FlappingBird.cpp:(.text+0xda): undefined reference tosge::Window::setTitle(std::string)' FlappingBird.cpp:(.text+0x120): undefined reference to sge::Window::setSize(unsigned int, unsigned int)' FlappingBird.cpp:(.text+0x149): undefined reference tosge::Window::hideCursor(bool)' build/FlappingBird.o: In function FlappingBird::FlappingBird()': FlappingBird.cpp:(.text+0x1d5): undefined reference tosge::Game::Game()' FlappingBird.cpp:(.text+0x22d): undefined reference to sge::Content::Content(std::string)' FlappingBird.cpp:(.text+0x285): undefined reference tosge::Window::setTitle(std::string)' FlappingBird.cpp:(.text+0x2bf): undefined reference to sge::Window::setSize(unsigned int, unsigned int)' FlappingBird.cpp:(.text+0x2dc): undefined reference tosge::Window::hideCursor(bool)' FlappingBird.cpp:(.text+0x345): undefined reference to sge::Game::~Game()' build/FlappingBird.o: In functionFlappingBird::~FlappingBird()': FlappingBird.cpp:(.text+0x3e3): undefined reference to sge::Game::~Game()' FlappingBird.cpp:(.text+0x42c): undefined reference tosge::Game::~Game()' build/FlappingBird.o: In function FlappingBird::~FlappingBird()': FlappingBird.cpp:(.text+0x4b4): undefined reference tosge::Game::~Game()' FlappingBird.cpp:(.text+0x4fd): undefined reference to sge::Game::~Game()' build/FlappingBird.o: In functionFlappingBird::initialize()': FlappingBird.cpp:(.text+0x560): undefined reference to sge::Game::instance()' FlappingBird.cpp:(.text+0x56c): undefined reference tosge::Window::getBounds() const' build/FlappingBird.o: In function sge::Game::keyDown(int, int, int)': FlappingBird.cpp:(.text._ZN3sge4Game7keyDownEiii[_ZN3sge4Game7keyDownEiii]+0x2b): undefined reference tosge::Game::terminate(int)' build/FlappingBird.o:(.rodata.ZTI12FlappingBird[ZTI12FlappingBird]+0x18): undefined reference to typeinfo for sge::Game' build/Level.o: In functionLevel::Level(sge::Content const&, sge::Rectangle)': Level.cpp:(.text+0xe6): undefined reference to sge::Rectangle::Rectangle(float, float, float, float)' Level.cpp:(.text+0x11e): undefined reference tosge::Sprite::Sprite(sge::Texture2D const, sge::Rectangle)' Level.cpp:(.text+0x145): undefined reference to sge::Rectangle::Rectangle(float, float, float, float)' Level.cpp:(.text+0x17d): undefined reference tosge::Sprite::Sprite(sge::Texture2D const, sge::Rectangle)' Level.cpp:(.text+0x1a4): undefined reference to sge::Rectangle::Rectangle(float, float, float, float)' Level.cpp:(.text+0x1dc): undefined reference tosge::Sprite::Sprite(sge::Texture2D const_, sge::Rectangle)' Level.cpp:(.text+0x203): undefined reference to sge::Rectangle::Rectangle(float, float, float, float)' Level.cpp:(.text+0x23b): undefined reference tosge::Sprite::Sprite(sge::Texture2D const_, sge::Rectangle)' Level.cpp:(.text+0x24d): undefined reference to sge::Sprite::getHeight() const' Level.cpp:(.text+0x283): undefined reference tosge::Sprite::getWidth() const' Level.cpp:(.text+0x2c7): undefined reference to sge::Sprite::getHeight() const' Level.cpp:(.text+0x309): undefined reference tosge::Rectangle::Rectangle(float, float, float, float)' Level.cpp:(.text+0x38f): undefined reference to sge::Sprite::getHeight() const' build/Level.o: In functionLevel::~Level()': Level.cpp:(.text+0x486): undefined reference to sge::Texture2D::~Texture2D()' build/Level.o: In functionLevel::update(double)': Level.cpp:(.text+0x561): undefined reference to sge::Rectangle::right() const' build/Level.o: In functionLevel::draw(double)': Level.cpp:(.text+0x81d): undefined reference to sge::Sprite::draw(sge::Rectangle const&, float) const' Level.cpp:(.text+0x8d7): undefined reference tosge::Sprite::draw(sge::Rectangle const&, float) const' build/Level.o: In function Level::addPipe(float)': Level.cpp:(.text+0xb26): undefined reference tosge::Vector2::Vector2(float, float)' Level.cpp:(.text+0xb6d): undefined reference to sge::Vector2::~Vector2()' Level.cpp:(.text+0xba8): undefined reference tosge::Vector2::~Vector2()' build/Level.o: In function _ZNK3sge7Content4loadINS_9Texture2DEJiEEEPT_SsDpT0_': Level.cpp:(.text._ZNK3sge7Content4loadINS_9Texture2DEIiEEEPT_SsDpT0_[_ZNK3sge7Content4loadINS_9Texture2DEIiEEEPT_SsDpT0_]+0x4a): undefined reference to sge::Texture2D::Texture2D(std::string const&, unsigned int)' build/main.o: In functionmain': main.cpp:(.text+0x40): undefined reference to sge::Game::run()' build/Pipe.o: In functionPipe::Pipe(sge::Vector2 const&, sge::Sprite const_, sge::Sprite const_)': Pipe.cpp:(.text+0x43): undefined reference to sge::Rectangle::Rectangle(float, float, float, float)' Pipe.cpp:(.text+0x6b): undefined reference tosge::Rectangle::Rectangle(float, float, float, float)' Pipe.cpp:(.text+0x7b): undefined reference to sge::Sprite::getHeight() const' Pipe.cpp:(.text+0xaf): undefined reference tosge::Sprite::getWidth() const' Pipe.cpp:(.text+0xf1): undefined reference to sge::Sprite::getHeight() const' Pipe.cpp:(.text+0x14c): undefined reference tosge::Rectangle::Rectangle(float, float, float, float)' Pipe.cpp:(.text+0x163): undefined reference to sge::Rectangle::operator=(sge::Rectangle const&)' Pipe.cpp:(.text+0x173): undefined reference tosge::Sprite::getHeight() const' Pipe.cpp:(.text+0x1a7): undefined reference to sge::Sprite::getWidth() const' Pipe.cpp:(.text+0x1fe): undefined reference tosge::Rectangle::Rectangle(float, float, float, float)' Pipe.cpp:(.text+0x215): undefined reference to sge::Rectangle::operator=(sge::Rectangle const&)' build/Pipe.o: In functionPipe::draw()': Pipe.cpp:(.text+0x288): undefined reference to sge::Sprite::draw(sge::Rectangle const&, float) const' Pipe.cpp:(.text+0x2a6): undefined reference tosge::Sprite::draw(sge::Rectangle const&, float) const' build/Pipe.o: In function Pipe::collides(Bird const*) const': Pipe.cpp:(.text+0x33d): undefined reference tosge::Rectangle::intersects(sge::Rectangle const&) const' Pipe.cpp:(.text+0x35b): undefined reference to sge::Rectangle::intersects(sge::Rectangle const&) const' Pipe.cpp:(.text+0x389): undefined reference tosge::Rectangle::center() const' Pipe.cpp:(.text+0x3ac): undefined reference to sge::Rectangle::bottom() const' Pipe.cpp:(.text+0x3f8): undefined reference tosge::Rectangle::top() const' Pipe.cpp:(.text+0x460): undefined reference to sge::Rectangle::left() const' Pipe.cpp:(.text+0x4ac): undefined reference tosge::Rectangle::right() const' Pipe.cpp:(.text+0x4f1): undefined reference to sge::Rectangle::top() const' Pipe.cpp:(.text+0x518): undefined reference tosge::Rectangle::bottom() const' Pipe.cpp:(.text+0x549): undefined reference to sge::Rectangle::bottom() const' Pipe.cpp:(.text+0x570): undefined reference tosge::Rectangle::top() const' Pipe.cpp:(.text+0x620): undefined reference to sge::Rectangle::bottomLeft() const' Pipe.cpp:(.text+0x63c): undefined reference tosge::Vector2::sqrdistance(sge::Vector2 const&) const' Pipe.cpp:(.text+0x67f): undefined reference to sge::Rectangle::bottomLeft() const' Pipe.cpp:(.text+0x69b): undefined reference tosge::Vector2::sqrdistance(sge::Vector2 const&) const' Pipe.cpp:(.text+0x6de): undefined reference to sge::Rectangle::bottomLeft() const' Pipe.cpp:(.text+0x6fa): undefined reference tosge::Vector2::sqrdistance(sge::Vector2 const&) const' Pipe.cpp:(.text+0x739): undefined reference to sge::Rectangle::topRight() const' Pipe.cpp:(.text+0x755): undefined reference tosge::Vector2::sqrdistance(sge::Vector2 const&) const' Pipe.cpp:(.text+0x79d): undefined reference to sge::Vector2::~Vector2()' Pipe.cpp:(.text+0x7ae): undefined reference tosge::Vector2::~Vector2()' Pipe.cpp:(.text+0x7bf): undefined reference to sge::Vector2::~Vector2()' Pipe.cpp:(.text+0x7d0): undefined reference tosge::Vector2::~Vector2()' Pipe.cpp:(.text+0x7fb): undefined reference to sge::Vector2::~Vector2()' build/Pipe.o:Pipe.cpp:(.text+0x81e): more undefined references tosge::Vector2::~Vector2()' follow build/Pipe.o: In function Pipe::didScore(Bird const*)': Pipe.cpp:(.text+0x8ca): undefined reference tosge::Rectangle::left() const' build/Pipe.o: In function Pipe::offScreen() const': Pipe.cpp:(.text+0x91c): undefined reference tosge::Rectangle::right() const' build/Score.o: In function Score::Score(sge::Texture2D const*)': Score.cpp:(.text+0x51): undefined reference tosge::Rectangle::Rectangle(float, float, float, float)' Score.cpp:(.text+0x9a): undefined reference to sge::Sprite::Sprite(sge::Texture2D const*, sge::Rectangle)' Score.cpp:(.text+0xc9): undefined reference tosge::Rectangle::Rectangle(float, float, float, float)' Score.cpp:(.text+0x112): undefined reference to sge::Sprite::Sprite(sge::Texture2D const*, sge::Rectangle)' Score.cpp:(.text+0x13e): undefined reference tosge::Rectangle::Rectangle(float, float, float, float)' Score.cpp:(.text+0x181): undefined reference to sge::Sprite::Sprite(sge::Texture2D const*, sge::Rectangle)' Score.cpp:(.text+0x1ad): undefined reference tosge::Rectangle::Rectangle(float, float, float, float)' Score.cpp:(.text+0x1f0): undefined reference to sge::Sprite::Sprite(sge::Texture2D const*, sge::Rectangle)' Score.cpp:(.text+0x21c): undefined reference tosge::Rectangle::Rectangle(float, float, float, float)' Score.cpp:(.text+0x25f): undefined reference to sge::Sprite::Sprite(sge::Texture2D const*, sge::Rectangle)' Score.cpp:(.text+0x28b): undefined reference tosge::Rectangle::Rectangle(float, float, float, float)' Score.cpp:(.text+0x2d1): undefined reference to sge::Sprite::Sprite(sge::Texture2D const*, sge::Rectangle)' Score.cpp:(.text+0x2fd): undefined reference tosge::Rectangle::Rectangle(float, float, float, float)' Score.cpp:(.text+0x343): undefined reference to sge::Sprite::Sprite(sge::Texture2D const*, sge::Rectangle)' Score.cpp:(.text+0x36f): undefined reference tosge::Rectangle::Rectangle(float, float, float, float)' Score.cpp:(.text+0x3b5): undefined reference to sge::Sprite::Sprite(sge::Texture2D const*, sge::Rectangle)' Score.cpp:(.text+0x3e1): undefined reference tosge::Rectangle::Rectangle(float, float, float, float)' Score.cpp:(.text+0x427): undefined reference to sge::Sprite::Sprite(sge::Texture2D const*, sge::Rectangle)' Score.cpp:(.text+0x453): undefined reference tosge::Rectangle::Rectangle(float, float, float, float)' Score.cpp:(.text+0x499): undefined reference to sge::Sprite::Sprite(sge::Texture2D const*, sge::Rectangle)' build/Score.o: In functionScore::draw() const': Score.cpp:(.text+0x505): undefined reference to sge::Game::instance()' Score.cpp:(.text+0x511): undefined reference tosge::Window::getBounds() const' Score.cpp:(.text+0x6b2): undefined reference to sge::Rectangle::Rectangle(float, float, float, float)' Score.cpp:(.text+0x6e2): undefined reference to`sge::Sprite::draw(sge::Rectangle const&, float) const' collect2: error: ld returned 1 exit status make: *** [flappingbird] Error 1

khanhnb avatar Mar 05 '14 18:03 khanhnb

Did libsge.a even build successfully? Can you show the contents of FlappingBird/SimpleGameEngine/build please?

C0deH4cker avatar Mar 05 '14 18:03 C0deH4cker

http://pic.bitvn.org/di/595S/Screenshot_from_2014-03-07_16:50:49.png

khanhnb avatar Mar 07 '14 09:03 khanhnb

Okay, I think that I may know what the issue is. In that folder, run ar -t libsge.a and look for an entry named __.symdef. If that doesn't exist, run ranlib libsge.a and then make in FlappingBird.

C0deH4cker avatar Mar 09 '14 07:03 C0deH4cker

I ran ranlib libsge.a but that lib still didn't have any entry named __.symdef. So, make failed too

khanhnb avatar Mar 09 '14 19:03 khanhnb

That's really odd... What's the output of running nm Window.o?

On Mar 9, 2014, at 3:19 PM, Bảo Khánh [email protected] wrote:

I ran ranlib libsge.a but that lib still didn't have any entry named __.symdef. So, make failed too

— Reply to this email directly or view it on GitHub.

C0deH4cker avatar Mar 09 '14 21:03 C0deH4cker

Here is the output of running 'nm Window.o' 0000000000000a8b t _GLOBAL__sub_I__ZN3sge6WindowC2ESsiijjb U _Unwind_Resume 0000000000000a4e t _Z41__static_initialization_and_destruction_0ii U _ZN3sge5ColorC1Ev U ZN3sge5ColoraSERKS0 00000000000007ee T _ZN3sge6Window10hideCursorEb 0000000000000244 T _ZN3sge6Window10updateSizeEjj 0000000000000798 T _ZN3sge6Window11setPositionEii 0000000000000a06 T _ZN3sge6Window12isFullscreenEv 00000000000004d8 T _ZN3sge6Window13setBackgroundERKNS_5ColorE 000000000000088e T _ZN3sge6Window16enableFullscreenEv 0000000000000852 T _ZN3sge6Window16toggleFullscreenEv 000000000000097a T _ZN3sge6Window17disableFullscreenEv 0000000000000a1e T _ZN3sge6Window20currentWindowContextEv 000000000000061a T _ZN3sge6Window20preservesAspectRatioEv 0000000000000600 T _ZN3sge6Window23setPreservesAspectRatioEb 0000000000000774 T _ZN3sge6Window4getXEv 0000000000000786 T _ZN3sge6Window4getYEv 0000000000000554 T _ZN3sge6Window5clearEv 000000000000056c T _ZN3sge6Window6renderEv 000000000000048c T _ZN3sge6Window7didMoveEii 00000000000006f8 T _ZN3sge6Window7setSizeEjj 000000000000058e T _ZN3sge6Window8getTitleEv 00000000000006d4 T _ZN3sge6Window8getWidthEv 000000000000059c T _ZN3sge6Window8setTitleESs 00000000000003a0 T _ZN3sge6Window8updateGLEv 000000000000012a T _ZN3sge6Window9constructEv 00000000000004b0 T _ZN3sge6Window9didResizeEii 00000000000006e6 T _ZN3sge6Window9getHeightEv 0000000000000000 T _ZN3sge6WindowC1ESsiijjb 0000000000000000 T _ZN3sge6WindowC2ESsiijjb 00000000000000ce T _ZN3sge6WindowD1Ev 00000000000000ce T _ZN3sge6WindowD2Ev U _ZN3sge9RectangleC1Effff 000000000000062c T _ZNK3sge6Window9getBoundsEv U _ZNKSs5c_strEv U _ZNSsC1ERKSs U _ZNSsD1Ev U _ZNSsaSERKSs U _ZNSt8ios_base4InitC1Ev U _ZNSt8ios_base4InitD1Ev 0000000000000000 r _ZStL19piecewise_construct 0000000000000000 b _ZStL8__ioinit 0000000000000008 r _ZZL18__gthread_active_pvE20__gthread_active_ptr U __cxa_atexit U __dso_handle U __gxx_personality_v0 U glClear U glClearColor U glLoadIdentity U glMatrixMode U glOrtho U glViewport U glfwCreateWindow U glfwDestroyWindow U glfwGetFramebufferSize U glfwGetPrimaryMonitor U glfwMakeContextCurrent U glfwSetInputMode U glfwSetWindowPos U glfwSetWindowSize U glfwSetWindowTitle U glfwSwapBuffers U glfwWindowHint w pthread_cancel

khanhnb avatar Mar 12 '14 15:03 khanhnb

Okay, run make clean again in all dirs (FlappingBird, SimpleGameEngine, glfw). Delete the Makefile from glfw/. Then, make the following change:

On line 73 in the Makefile of SimpleGameEngine, change the capital S in the flags to ar to a lowercase s. So,

$(AR) -cruS $(LIB) $(ARCHIVED)

becomes

$(AR) -crus $(LIB) $(ARCHIVED)

It appears that the static library libsge.a has no object file index, which is why the linker cannot find symbols. Running ranlib on the archive should have added the object file index, but this change will make it happen as the archive is created.

C0deH4cker avatar Mar 12 '14 17:03 C0deH4cker

@khanhnb so have you solved the problem already? Faced the same issue and came across this thread. No luck here stuck with the same problem @C0deH4cker

Erickkkkk avatar Nov 10 '21 14:11 Erickkkkk

No luck here stuck with the same problem, please @C0deH4cker

aldfaaa avatar Sep 01 '23 03:09 aldfaaa