1
votes

I have two projects the first is c++ console application and the second is c++ CLR Empty project .I want to call function from the console and use it in CLR project .I tried to create header file , include it in CLR project and use #include "headername.h" and call the function render3d() but it gives me those linking errors .

Error 29 error LNK2028: unresolved token (0A000934) "void __cdecl render3d(void)" (?render3d@@$$FYAXXZ) referenced in function "private: void __clrcall DEMO::MainForm::AddAnimebutton_Click(class System::Object ^,class System::EventArgs ^)" (?AddAnimebutton_Click@MainForm@DEMO@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z) E:\Graduation Project\CPP ARENA DEMO New Design\DEMO\DEMO\MainForm.obj DEMO

Error 30 error LNK2019: unresolved external symbol "void __cdecl render3d(void)" (?render3d@@$$FYAXXZ) referenced in function "private: void __clrcall DEMO::MainForm::AddAnimebutton_Click(class System::Object ^,class System::EventArgs ^)" (?AddAnimebutton_Click@MainForm@DEMO@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z) E:\Graduation Project\CPP ARENA DEMO New Design\DEMO\DEMO\MainForm.obj DEMO

Error 31 error LNK1120: 2 unresolved externals E:\Graduation Project\CPP ARENA DEMO New Design\DEMO\Release\DEMO.exe DEMO

1
I'd make a header-only module, but you might find it easier to just create a traditional header+impl module. You can then just use those source files directly, or create a library.Cheers and hth. - Alf
in console project i have too many source files so it gives me too many errors every time i try too use those source files in the CLR project . that why i can not use it directly .Ahmed Javaboy

1 Answers

0
votes

You probably have to create a library containing the function you want to call and add a dependency between the projects. Your visual studio solution would then contain 3 projects:

  • library with render3d function
  • console application which references the above library
  • CLR empty project which references the above library