Click here to Skip to main content
15,909,205 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
Hello,

I'm working on my game framework in C++. It is composed of a shared library containing all the features and an executable used to test the features (The executable will eventually become a working game).

The library and executable both compile and link fine, but when I try to execute it, I get this error:

main/bin/debug/main: symbol lookup error: main/bin/debug/main: undefined symbol: _ZN7Survive8Graphics4TwoD6SpriteC1Ev


Survive::Graphics::TwoD::Sprite is a sprite class for 2D images.

I'm wondering, what would cause this error?

Sprite and Graphics2D, a class used to draw to a given Sprite, are both defined in Sprite.hpp and implemented in their respective .cpp files. Could this be a cause of the problem?

Here's the code to Main.cpp:
C++
#include "system/App.hpp"
#include "graphics/2d/Sprite.hpp"
#include "game/2d/Entity2D.hpp"
#include <iostream>

//using namespace Survive::Math;
using namespace Survive::System;
using namespace Survive::Graphics;
using namespace Survive::Graphics::TwoD;
using namespace Survive::Game::TwoD;

int main(int argc, char* argv[]) {
	App *theApp = AppSingleton::instance();
	
	// create a new entity
	Entity2D entity;
	
	// Create a new blank 100x100 sprite, and obtain a Graphics2D object to draw to it.
	Graphics2D *gr = entity.create(100, 100);
	
	if (gr) {
		gr->beginDrawing();
		gr->pixelRGB(50, 50, 255, 1, 1);
		gr->endDrawing();
	}
	
	entity.setPosition(20, 20);
	
	theApp->addEntity(entity);
	
	return theApp->onExecute();
}


Some additional details:

  • I'm working in Ubuntu, compiling from the command line using makefiles generated by premake.
  • The constructor
    C++
    Survive::Graphics::TwoD::Sprite::Sprite()
    *is* defined in Sprite.cpp
  • The relative locations of the executable and the shared library are not a problem, because I've been able to run the executable with the library, each in the same locations, before.


Any suggestions on how to fix this?

Note: I have no idea where this might originate, so if further code is necessary to find what's causing this, please tell me.

Thanks in advance!
Posted
Updated 25-Jun-12 13:59pm
v2
Comments
Sergey Alexandrovich Kryukov 25-Jun-12 19:29pm    
How do you hope to get help if you even did not give us any code sample?
--SA
Member 7887373 25-Jun-12 20:01pm    
Ok I added some code, but I have no idea where this might be coming from, so please indicate what further code might be necessary to find the problem (I only program for a hobby, so I'm not so great with stuff like this...)
Albert Holguin 25-Jun-12 23:28pm    
You need more details, is your library loaded dynamically at run-time? ...or is it static? ...how are you including that library within your exe project? Are you sure you didn't use C-style exports for your methods? In which case there would be no mangling... or alternatively, are you sure your mangling is correct? In the MS compiler some of the options will change the method decorations, so make sure both the library and the application use the same settings.
Member 7887373 26-Jun-12 10:22am    
It is dynamically loaded at run-time, but that doesn't matter because I've been able to use the library with the executable before. AFAIK GCC doesn't use exports/imports (i.e. __declspec export etc) so I didn't use anything like that. c++filt indicates that _ZN7Survive8Graphics4TwoD6SpriteC1Ev is in fact, Survive::Graphics::TwoD::Sprite::Sprite(), but that constructor is defined in Sprite.cpp.
Albert Holguin 26-Jun-12 11:09am    
Isn't that in your library? ...or is it in your exe?

1 solution

Is there a reference to Survive::Graphics::TwoD::Sprite::operator++ in main?

Is that operator defined in Sprite?

The suffix C1Ev might possible be interpreted as:

C=volatile, 1=reference to sprite, E=operator++, v=struct

Of course, it could also mean something else entirely, since the name mangling isn't standard.


You mention that you've been able to run the executable with the library before.

So, what did you change between the last time you ran it successfully and the first time you got the error?


If that doesn't solve your problem try googling "name mangling C++" or look for documentation on how your specific compliler "mangles" or "decorates" C++ function names so that you can "de-mangle" that error and determine what exactly is being referred to.
 
Share this answer
 
Comments
Member 7887373 25-Jun-12 20:57pm    
The change was that I added the graphics stuff (Graphics2D, Entity2D, Sprite) to the library.

There is no reference to operator++ whatsoever.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900