Unresolved reference to constructor which is defined [duplicate]

倾然丶 夕夏残阳落幕 提交于 2019-12-13 10:09:53

问题


I am getting an unresolved external symbol "public: __thiscall TestLanguage::TestLanguage(void)" (??0TestLanguage@@QAE@XZ) referenced in function _main

The TestLanguage constructor is defined as far as I can see, however obviously the compiler can't see it. My only conclusion is that there is some sort of inclusion problems (e.g. circular includes).

I have made a diagram of the includes for each translation unit below, however I can't see any problems. Any guidance would be appreciated.

Includes:

Test.cpp
    Expression.h
        Operation.h
        Token.h
    CPU.h
        Operation.h
    TestLanguage.h
        ILanguage.h
        TLOperators.h
            IOperator.h
                Operation.h
                Token.h

TestLanguage.cpp
    TestLanguage.h
        ILanguage.h
        TLOperators.h
            IOperator.h
                Operation.h
                Token.h

TLOperators.cpp
    TLOperators.h
        IOperator.h
            Operation.h
            Token.h
    Expression.h
        Operation.h
        Token.h
    CPU.h
        Operation.h

CPU.cpp
    CPU.h
        Operation.h
    Operation.h

Expression.cpp
    Expression.h
        Operation.h
        Token.h
    Util.h
    IOperator.h
        Operation.h
        Token.h
    CPU.h
        Operation.h
    ILanguage.h

Operation.cpp
    Operation.h

Token.cpp
    Token.h

回答1:


After attempting to create a MCVE as suggested by @inetknght (thanks BTW), I discovered that it was actually a bug in Visual Studio Express 2013. I copied all my source files to a new project, so I could keep removing stuff to get the smallest example, however it compiled fine in the new project.

When attempting to fix the original project, I cleaned the solution, manually deleted the object files, deleted the .sdf file in the project. None of that worked. Then I tried removing the TestLanguage.cpp file from the project and adding it back - and it worked.

Hopefully this will help any others who experience this.



来源:https://stackoverflow.com/questions/27748699/unresolved-reference-to-constructor-which-is-defined

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!