1

I am trying to create a rather simple project in native c++ that calls a a managed dll. this how my native c++ code looks:

// MyCppStud.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "MyStudWrapper\MyStudentWrapperWrapper.h"

int _tmain(int argc, _TCHAR* argv[])
{
char * path = "C:/Users/rami.schreiber/documents/visual studio    2013/Projects/TestProj/test.xml";
MyStudentWrapperWrapper* student = new MyStudentWrapperWrapper();
//  student->GetStudent(path);
return 0;
}

and here are the .h and .cpp files for the managed dll (compiled with /clr)

    //MyStudentWrapperWrapper.h
#pragma once

//#ifdef THISDLL_EXPORTS
#define THISDLL_API __declspec(dllexport)
/*#else
#define THISDLL_API __declspec(dllimport)
#endif*/


 class MyStudentWrapper;

    class THISDLL_API MyStudentWrapperWrapper
    {
    private:
        MyStudentWrapper* _Impl;
    public:
        MyStudentWrapperWrapper();
        MyStudentWrapperWrapper(MyStudentWrapper* student);
        ~MyStudentWrapperWrapper();
        MyStudentWrapperWrapper* GetStudent(const char*  path);
        void SaveStudent(MyStudentWrapperWrapper* student, const char*  path);
    };





// MyStudentWrapperWrapper.cpp
#pragma once
#include "stdafx.h"
#include "MyStudWrapper.h"

#include "MyStudentWrapperWrapper.h"

MyStudentWrapperWrapper::MyStudentWrapperWrapper()
{
_Impl = new MyStudentWrapper;

}

when i build the solution i get a link error

1>MyCppStud.obj : error LNK2019: unresolved external symbol "public: __thiscall MyStudentWrapperWrapper::MyStudentWrapperWrapper(void)" (??0MyStudentWrapperWrapper@@QAE@XZ) referenced in function _main
1>c:\users\...\documents\visual studio 2013\Projects\MyStudentProj\Debug\MyCppStud.exe : fatal error LNK1120: 1 unresolved externals

From what I understand I am not referencing the the .lib file correctly and therefor the linker does not recognize the c'tor for my wrapper class. can someone please explain how to correctly reference the dll to my c++ project. thank you very much!

avrsch
  • 11
  • 1
  • 1
    possible duplicate of [What is an undefined reference/unresolved external symbol error and how do I fix it?](http://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – πάντα ῥεῖ Mar 24 '14 at 14:29
  • something is going wrong with your dllimport/dllexports...everything relating to MyStudentWrapper should be declared but not defined in the managed assembly, and also definied in a separate native DLL, as per this question : http://stackoverflow.com/questions/10222566/what-is-dllspecdllimport-and-dllspecdllexport-means – Graham Griffiths Mar 24 '14 at 14:37

0 Answers0