Hallo,
Ik zit nu al een tijdje te prutsen, en ik kan het maar niet werken krijgen. Ik heb een DLL gemaakt in Visual C++ 2005 (CLR Class Library), en heb dan een ander project (CLR Windows Forms Application) waar ik een functie uit die DLL wil gebruiken. Bijde projecten zitten in 1 solution.
De DLL bestaat uit my_dll.h & my_dll.c (& de standaard troep), hier heb ik dus alleen maar 1 functie aan toegevoegd (die niks doet). Mijn applicatie bestaat uit my_app.c en Form1.h, aan Form1.h heb ik niks veranderd. aan my_app.c heb ik alleen maar 1 regel toegevoegd, nl. de include regel voor de my_dll.h file.
Als ik dit dus probeer te compileren, dan krijg ik 2 errors, nl:
Error 1 error LNK2020: unresolved token (06000005) my_dll.Class1::my_func my_app.obj
Error 2 fatal error LNK1120: 1 unresolved externals E:\!projects\VS.NET Projects\test\test\Release\my_app.exe 1
Ik heb van alles geprobeerd, ik heb op google gezocht, daar staan allemaal verschillende problemen/antwoorden, maar ze helpen allemaal niet.
Alvast bedankt.
hier nog ff de broncode van de bestanden:
my_dll.h:
my_dll.c:
my_app.c:
Ik zit nu al een tijdje te prutsen, en ik kan het maar niet werken krijgen. Ik heb een DLL gemaakt in Visual C++ 2005 (CLR Class Library), en heb dan een ander project (CLR Windows Forms Application) waar ik een functie uit die DLL wil gebruiken. Bijde projecten zitten in 1 solution.
De DLL bestaat uit my_dll.h & my_dll.c (& de standaard troep), hier heb ik dus alleen maar 1 functie aan toegevoegd (die niks doet). Mijn applicatie bestaat uit my_app.c en Form1.h, aan Form1.h heb ik niks veranderd. aan my_app.c heb ik alleen maar 1 regel toegevoegd, nl. de include regel voor de my_dll.h file.
Als ik dit dus probeer te compileren, dan krijg ik 2 errors, nl:
Error 1 error LNK2020: unresolved token (06000005) my_dll.Class1::my_func my_app.obj
Error 2 fatal error LNK1120: 1 unresolved externals E:\!projects\VS.NET Projects\test\test\Release\my_app.exe 1
Ik heb van alles geprobeerd, ik heb op google gezocht, daar staan allemaal verschillende problemen/antwoorden, maar ze helpen allemaal niet.
Alvast bedankt.
hier nog ff de broncode van de bestanden:
my_dll.h:
C++:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| // my_dll.h #pragma once using namespace System; namespace my_dll { public ref class Class1 { // TODO: Add your methods for this class here. public: static char * my_func(char * my_var); }; } |
my_dll.c:
C++:
1
2
3
4
5
6
7
8
9
10
| // This is the main DLL file. #include "stdafx.h" #include "my_dll.h" char * my_dll::Class1::my_func(char * my_var) { return my_var; } |
my_app.c:
C++:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
| // my_app.cpp : main project file. #include "stdafx.h" #include "Form1.h" #include "../my_dll/my_dll.h" using namespace my_app; [STAThreadAttribute] int main(array<System::String ^> ^args) { // Enabling Windows XP visual effects before any controls are created Application::EnableVisualStyles(); Application::SetCompatibleTextRenderingDefault(false); // Create the main window and run it Application::Run(gcnew Form1()); return 0; } |
[ Voor 0% gewijzigd door RobIII op 02-05-2007 02:38 . Reden: Code-tags toegevoegd ]