calling function from dll

I have a function in my program:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
void tables()
{ 
   BOOL freeResult, runTimeLinkSuccess = FALSE; 
   HINSTANCE dllHandle = NULL;              
   tablemain tablem = NULL;

   dllHandle = LoadLibrary(LPCWSTR("table.dll"));


   if (NULL != dllHandle) 
   { 
      tablem = (tablemain)GetProcAddress(dllHandle,"tablemain");

      if (runTimeLinkSuccess = (NULL != tablem))
      {
         tablem(logflag);
      }


      freeResult = FreeLibrary(dllHandle);       
   }

   if(!runTimeLinkSuccess)
      printf("\tUnable to acces 'table.dll.'"); 

I've seen it on MSDN
in the same directory i have a table.dll with dllmain.cpp and table.cpp.In table.cpp i have declared a function:
int _stdcall tablemain(int&login)
the def file looks like:
LIBRARY "table.dll"

EXPORTS
tablemain @1

But my function isn't exported.Can someone help?
Last edited on
if i export by name,do i need the def?
I made this in table.cpp:
__declspec(dllexport) void __cdecl tablemain(int& );
amd deleted the .def file.But even now,it can't read the dll
I've followed what that page said and it worked for me without problems. If you're still having problems, I'm not sure what to suggest.

EDIT:
Actually look at the top right of the page I suggested at the 'Export from a Dll' link. This is a drop down menu. Have a look at these to see if any of them are of any use.
Last edited on
2>System.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) void __cdecl tablemain(int &)" (__imp_?tablemain@@YAXAAH@Z) referenced in function "void __cdecl tables(void)" (?tables@@YAXXZ)
2>C:\Documents and Settings\user\My Documents\Visual Studio 2008\Projects\System\Debug\System.exe : fatal error LNK1120: 1 unresolved externals
I get this error....I nhave in front of table.cpp __declspec(dllexport) void __cdecl tablemain(int&); and int the declarations in system.cpp: __declspec( dllimport ) void tablemain(int&);
This is my call to the function:
void tables()
{
tablemain(logflag);
}
Have you got the dll project in your solution?
yes
Sorry, it was an obvious thing but your link error is saying that your dll object code isn't being included in the link command for the executable. You have called a function but the object code for that function cannot be found by the linker.

I'm not familiar enough with VS2008 to be able to give you much more than I have already, sorry. I'm sure someone else will know but you may have to wait for people to wake up in the various time zones around the globe.
Thanks for your help
Topic archived. No new replies allowed.