linker - Link error when referencing managed dll to native c++ -
i trying create rather simple project in native c++ calls a managed dll. how native c++ code looks:
// mycppstud.cpp : defines entry point 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 .h , .cpp files managed dll (compiled /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 build solution 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 understand not referencing the .lib file correctly , therefor linker not recognize c'tor wrapper class. can please explain how correctly reference dll c++ project. thank much!
Comments
Post a Comment