执行Main时出现符号查找错误 [英] Symbol Lookup Error when Executing Main

查看:109
本文介绍了执行Main时出现符号查找错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我正在使用C ++开发我的游戏框架.它由一个包含所有功能的共享库和一个用于测试这些功能的可执行文件组成(该可执行文件最终将成为可运行的游戏).

库和可执行文件都可以编译和链接,但是当我尝试执行它时,出现此错误:

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是2D图像的Sprite类.

我想知道什么会导致此错误?

Sprite和Graphics2D(用于绘制给定Sprite的类)都在Sprite.hpp中定义,并在各自的.cpp文件中实现.这可能是问题的原因吗?

这是Main.cpp的代码:



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:

#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();
}



其他一些详细信息:


  • 我正在Ubuntu中工作,使用premake生成的makefile从命令行进行编译.
  • 构造函数



    Some additional details:


    • I''m working in Ubuntu, compiling from the command line using makefiles generated by premake.
    • The constructor

      Survive::Graphics::TwoD::Sprite::Sprite()

      *是在Sprite.cpp中定义的.

    • 可执行文件和文件的相对位置共享库不是问题,因为以前我已经可以在同一位置使用该库运行可执行文件.
    • *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.
    • 推荐答案

      在主目录中是否存在对Survive :: Graphics :: TwoD :: Sprite :: operator ++的引用?
      Sprite中定义了该运算符吗?

      后缀C1Ev可能解释为:

      C = volatile,1 =引用精灵,E = operator ++,v = struct

      当然,这也可能完全意味着其他含义,因为名称改写不是标准的.


      您提到您以前已经能够使用该库运行可执行文件.

      那么,在上一次成功运行它与第一次遇到错误之间,您做了什么更改?


      如果那不能解决您的问题,请尝试使用Google搜索名称修改C ++"或查找有关特定编译器如何组合"或修饰" C ++函数名称的文档,以便您可以分解"该错误并确定确切的含义.被引用.
      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.


      这篇关于执行Main时出现符号查找错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆