1
votes

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
Do you have a MCVE? stackoverflow.com/help/mcveinetknght
@inetknght I'll try get one together.developerbmw
I haven't downvoted (yet :)), but how is this a reasonable question? You haven't given us any useful information. A giant tree of source files and headers they include is not useful because 1. we have no way of knowing whether it's correct 2. there's nothing to indicate whether you've even provided a definition of the constructor in question.Praetorian
@Brett I did not vote as a duplicate.I chose one of the "off topic" options, the one that asks for an MCVE. It is an artifact to the stackoverflow closing system that only one reason appears (presumably the majority one, which I don't agree with.) There is a link right at the top of your question though.juanchopanza
Usually I do trust the OP to provide correct info, but what you've posted is easy to get wrong. And, even if I didn't doubt any of the include stuff, how is it useful? The error occurs because the linker is unable to find the definition, which makes the information about what translation units see the class definition irrelevant. Nobody expects you to post a flawless question, otherwise there'd be no need for a comments section. But we do expect you to supply relevant information. I understand you didn't withhold it intentionally, but complaining about downvotes doesn't help anything.Praetorian

1 Answers

0
votes

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.