-5

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
Captain Obvlious
  • 19,754
  • 5
  • 44
  • 74
brettwhiteman
  • 4,210
  • 2
  • 29
  • 38
  • 3
    Do you have a MCVE? http://stackoverflow.com/help/mcve – inetknght Jan 02 '15 at 21:28
  • 1
    @inetknght I'll try get one together. – brettwhiteman Jan 02 '15 at 21:31
  • 5
    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 Jan 02 '15 at 21:44
  • @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 Jan 02 '15 at 21:49
  • @Praetorian *facepalm* You can't discriminate a question because you don't trust the question-asker or their ability to provide correct information. Honestly.... – brettwhiteman Jan 02 '15 at 21:51
  • @Brett Just learn to ask a good question. Whinging isn't going to make the down-votes disappear. – juanchopanza Jan 02 '15 at 21:53
  • 2
    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 Jan 02 '15 at 22:09

1 Answers1

0

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.

Community
  • 1
  • 1
brettwhiteman
  • 4,210
  • 2
  • 29
  • 38
  • 1
    Sounds like the source file in question was excluded from the build. – Captain Obvlious Jan 02 '15 at 21:45
  • 1
    Sounds like you have a small-ish consistent repro under your hand. How about reporting it at connect and have MS investigate? Until you do, you cannot be certain it is indeed a VS bug. – Ofek Shilon Jun 15 '15 at 05:49