none
Linker problem unresolved token error

    Question

  • Answer

    Linker problem

    I am trying to use .NET C++ code from already existing native C++ source code.

    I am a complete noob in C++, so any help is appreciated.

    This is my header file "test.h" -->

    namespace Version
    {
        public ref class Test
        {
       public:

          static bool Init (System::UInt16 inId, int versionNum,
              array<System::UInt32>^ queryToggle, array<System::UInt32>^ queryResponse);

          static bool RunTest (int run1, int run2);

          static unsigned short GetTestVersion();

       private:
          static bool InitTest();
        };
    }

    This is the code file "test.cpp" -->

    #include "test.h"
    #include <stdlib.h>
    #include <time.h>

    namespace
    Version
    {

       static unsigned short _version = 0;

       bool Test::Init (System::UInt16 inId, int versionNum,
          array<System::UInt32>^
    queryToggle, array<System::UInt32>^ queryResponse)
       {

           ........

           ........

          return true;
       }

       bool Test::InitTest()
       {
          ....

          return true;
       }

       bool Test::RunTest (int run1, int run2)
       {

               ....

               return false;
         }

      }

       unsigned short Test::GetTestVersion()
       {
          return _version;
       }

    }

    The output is a dll

    Now when i try to reference this  from "VersionTester.cpp" (app with /clr) trying to link with "test.dll" 

    #include "test.h"

    int main(int argc, char* argv[])
    {
        printf("Hello Version tester");

        return 0;
    }

    I get these error messages :

    error LNK2020: unresolved token (06000001) Version.Test::InitTest    Version.obj   
    error LNK2020: unresolved token (06000002) Version.Test::RunTest    Version.obj   
    error LNK2020: unresolved token (06000003) Version.Test::GetTestVersion    Version.obj   
    error LNK2020: unresolved token (06000004) Version.Test::InitTest     Version.obj   
    error LNK1120: 4 unresolved externals  

    So how do i fix this and why is this happening ?


     

    Thursday, 23 October 2008 4:12 PM

Answers

All replies