LNK2019未解析的外部__declspec(dllimport)SDL_main

时间:2015-06-05 20:41:55

标签: dll import export lnk2019

我正在制作游戏引擎。引擎是dll项目。现在,引擎构建为dll和lib。我试图用另一个项目来测试我到目前为止所做的事情。这是我收到的错误消息:

error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall Aria::GameConfig::GameConfig(class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > const &)" (__imp_??0GameConfig@Aria@@QAE@ABV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@@Z) referenced in function "int __cdecl SDL_main(void)" (?SDL_main@@YAHXZ)    D:\My Documents\Programing\Repo\NDTD\NDTD\Project\Main.obj
error LNK2019: unresolved external symbol "public: __thiscall TestGame::TestGame(class Aria::GameConfig *)" (??0TestGame@@QAE@PAVGameConfig@Aria@@@Z) referenced in function "int __cdecl SDL_main(void)" (?SDL_main@@YAHXZ)    D:\My Documents\Programing\Repo\NDTD\NDTD\Project\Main.obj
error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup   D:\My Documents\Programing\Repo\NDTD\NDTD\Project\MSVCRTD.lib(crtexe.obj)

这是我的platform.h文件的一部分,它包含dll导入和导出宏

#if !defined(ARIA_STATIC)
    #ifdef ARIA_SYS_WINDOWS
        #if defined (ARIA_NONCLIENT_BUILD)
            // define dllexport and dllimport macros
            #ifndef ARIA_API
                #define ARIA_API __declspec(dllexport)
            #endif
        #else
            #ifndef ARIA_API
                #define ARIA_API __declspec(dllimport)
            #endif
        #endif

        // Visual c++ compiler warning C4251 disable
        #ifdef _MSC_VER
            #pragma warning(disable : 4251)
        #endif

    #else // Linux and MAC OS X
        #if __GNUC__ >= 4
            // GCC 4 has unique keywords for showing/hiding symbols
            // the same keyword is used for both import and export
            #define ARIA_API __attribute__ ((__visibility__("default")))
            #define ARIA_API __attribute__ ((__visibility__("default")))
        #else
            #define ARIA_API
            #define ARIA_API
        #endif
    #endif
#else
    // static build doesn't need import/export macros
    #define ARIA_API
    #define ARIA_API
#endif

我已经使用预处理器定义ARIA_NONCLIENT_BUILDUNICODE以及它定义的窗口构建了引擎。我已链接到SDL lib并包含头文件。我也在使用带有wchar的unicode字符串。我也没有忘记在类定义中添加ARIA_API宏。

在测试项目中,这里是main.cpp文件

#include <Game\Game.h>

using namespace Aria;

class TestGame : public IGame
{
public:
    TestGame(GameConfig* config);
    ~TestGame();

    void OnStartUp()        override;
    void OnUpdate(float dt) override;
    void OnRender(float dt) override;
    void OnShutdown()       override;
};

void TestGame::OnStartUp()
{
}
void TestGame::OnUpdate(float dt)
{
}    
void TestGame::OnRender(float dt)
{
}    
void TestGame::OnShutdown()
{   
}    
int main()
{
    GameConfig* config = new GameConfig(ATEXT("test.config"));
    TestGame* game = new TestGame(config);
    return game->Run();
}

如果我忘记了某些内容,请告诉我。

0 个答案:

没有答案