Click here to Skip to main content
15,896,428 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
I want to call method in abc.dll written in c++ using vc++ and vs2008.
My code is
C#
/* global handle for the dynamic library */
HMODULE g_hLib = NULL;
#if defined(WIN32)
    #define DERMALOG_LIBNAME "abc.dll"
/* load the library */
   g_hLib = LoadLibrary(DERMALOG_LIBNAME);
   if (g_hLib==NULL)
   {
      printf("%s not found\n", DERMALOG_LIBNAME);

   }
typedef long nRetCode = FC3Initialize(NULL);

METHOD PROTOTYPE IS DrmErrorCode_t DRMAPI FC3Initialize(const char* szReserved);

It is successfully loaded but when I call method it gives linking error...


Error 13 error LNK2019: unresolved external symbol _FC3Initialize@4 referenced in function "public: void __thiscall CZF1SDKLightTutorialDlg::OnBnClickedButton3(void)" (?OnBnClickedButton3@CZF1SDKLightTutorialDlg@@QAEXXZ) ZF1SDKLightTutorialDlg.obj ZF1SDKLightTutorial

Error 14 fatal error LNK1120: 1 unresolved externals C:\Users\Acer\Desktop\a\ZF1SDKDemo_12July2012_imran\ZF1SDKDemo\ZF1SDKDemo\Debug\ZF1SDKDemo.exe 1 ZF1SDKLightTutorial
Posted
Updated 12-Jul-12 3:14am
v4

Take a look at those links here in CP, probably they will help you:

Regular DLL Tutor For Beginners[^]

Step by Step: Calling C++ DLLs from VC++ and VB - Part 1[^]


And this Q&A that seems related to your needs:
using DLL without importing the LIB[^]

Hope this helps...
 
Share this answer
 
Comments
Albert Holguin 12-Jul-12 16:04pm    
Those are all good resources... +5
Joan M 12-Jul-12 16:22pm    
Thank you Albert!
You cannot make a direct call to a library function unless that library is linked to your program. If you are dynamically loading the DLL at run time then you must use GetProcAddress()[^] and call it through a function pointer.
 
Share this answer
 
Comments
Albert Holguin 12-Jul-12 16:03pm    
Pretty important step... +5
make function pointer to function in dll.
And call laoddll function
 
Share this answer
 
Comments
Richard MacCutchan 16-Nov-12 8:44am    
Which is what I told you four months ago.
Amol Patil May2021 10-May-21 1:12am    
Hi,
I am tried to load the DLL in c.DLL loading got successful. I called one dll function, the function called successfully. but inside that dll function one thread got registered after that there was a callback to the platform.there is check of pj_this() and its asserting.how to avoid that assert.looks like pj functions outside of the dll not accessible

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900