vc++ 4.0 and dll
-
i have created test_build.dll, xxx.h, xxx.def. next i created testexe to try calling functions inside that dll. but this testexe does not compile - error msg about unresolved external symbol... indicating it could not 'see' those functions inside the dll. question - what settings on this testexe project i need to set/un_set for it to work?
-
i have created test_build.dll, xxx.h, xxx.def. next i created testexe to try calling functions inside that dll. but this testexe does not compile - error msg about unresolved external symbol... indicating it could not 'see' those functions inside the dll. question - what settings on this testexe project i need to set/un_set for it to work?
-
There are two ways to do it: -link your testexe with a .lib file created when you compile the dll -use LoadLibrary and GetProcAddress to load the dll during execution of the test executable
i am a total amateur with vc++ so pls bear with me... >-link your testexe with a .lib file created when you compile the dll this would mean i am hard-wiring my .lib to the testexe build? >-use LoadLibrary and GetProcAddress to load the dll during execution of >the test executable with the following code("square" is on of the functions inside test_build.dll) FARPROC * lpfProcFn; HINSTANCE hLib; hLib = LoadLibrary("test_build.dll"); *lpfProcFn = GetProcAddress(&hLib, "square"); ?? how do i now call that "square" fn ?? abc = square(45); <-- compiler will complain unresolved fn... thanks.
-
i am a total amateur with vc++ so pls bear with me... >-link your testexe with a .lib file created when you compile the dll this would mean i am hard-wiring my .lib to the testexe build? >-use LoadLibrary and GetProcAddress to load the dll during execution of >the test executable with the following code("square" is on of the functions inside test_build.dll) FARPROC * lpfProcFn; HINSTANCE hLib; hLib = LoadLibrary("test_build.dll"); *lpfProcFn = GetProcAddress(&hLib, "square"); ?? how do i now call that "square" fn ?? abc = square(45); <-- compiler will complain unresolved fn... thanks.
If your square function has for example the following definition:
int square(int a,int b);
you could do it this way:typedef int (*proc)(int a,int b); HINSTANCE hLib; hLib = LoadLibrary("test_build.dll"); proc fptr=(proc)GetProcAddress(hLib,"square"); abc=fptr(1,2);