Problem while linking a DLL function 
Author Message
 Problem while linking a DLL function

I have a problem while trying to link a application which uses a function
in a DLL. When I include the DLLxxx.LIB in my project everything works
fine, but I like to load the DLL only when is about to be used.
No I link without the .LIB include and in the link step i get a link error
:

Linking...
GeoImportTest.obj : error LNK2001: unresolved external symbol __imp__MyFunc

How can I get my linker to accept this function ? Do I need a DEF File, How
does that have to look ?

extern "C" __declspec( dllexport ) int MyFunc(char* parm1);

Thank, I really appreciate your input.

--
Daniel Zuppinger, SoftToys
(remove XX_ from my Email address)



Mon, 31 Jul 2000 03:00:00 GMT  
 Problem while linking a DLL function

Quote:

>I have a problem while trying to link a application which uses a function
>in a DLL. When I include the DLLxxx.LIB in my project everything works
>fine, but I like to load the DLL only when is about to be used.
>No I link without the .LIB include and in the link step i get a link error
>:

>Linking...
>GeoImportTest.obj : error LNK2001: unresolved external symbol __imp__MyFunc

>How can I get my linker to accept this function ? Do I need a DEF File, How
>does that have to look ?

>extern "C" __declspec( dllexport ) int MyFunc(char* parm1);

>Thank, I really appreciate your input.

You should provide the function name in the EXPORTS section of the def file
(playing with decorated names are quite complicated).  If you want to load the
function only when you need it - look at LoadLibrary.




Mon, 31 Jul 2000 03:00:00 GMT  
 Problem while linking a DLL function

Quote:

> I have a problem while trying to link a application which uses a
> function
> in a DLL. When I include the DLLxxx.LIB in my project everything works
> fine, but I like to load the DLL only when is about to be used.
> No I link without the .LIB include and in the link step i get a link
> error
> :

> Linking...
> GeoImportTest.obj : error LNK2001: unresolved external symbol
> __imp__MyFunc

> How can I get my linker to accept this function ? Do I need a DEF
> File, How
> does that have to look ?

> extern "C" __declspec( dllexport ) int MyFunc(char* parm1);

> Thank, I really appreciate your input.

> --
> Daniel Zuppinger, SoftToys
> (remove XX_ from my Email address)

If you load the DLL at run time (using LoadLibrary instead of linking to
the LIB file) you can't call functions in that DLL directly. You have to
get a pointer to the function with GetProcAddress.

Seth Jones



Mon, 31 Jul 2000 03:00:00 GMT  
 Problem while linking a DLL function

Quote:


>> I have a problem while trying to link a application which uses a
>> function
>> in a DLL. When I include the DLLxxx.LIB in my project everything works
>> fine, but I like to load the DLL only when is about to be used.
>> No I link without the .LIB include and in the link step i get a link
>> error
>> :

>> Linking...
>> GeoImportTest.obj : error LNK2001: unresolved external symbol
>> __imp__MyFunc

>> How can I get my linker to accept this function ? Do I need a DEF
>> File, How
>> does that have to look ?

>> extern "C" __declspec( dllexport ) int MyFunc(char* parm1);

>> Thank, I really appreciate your input.

>> --
>> Daniel Zuppinger, SoftToys
>> (remove XX_ from my Email address)
>If you load the DLL at run time (using LoadLibrary instead of linking to
>the LIB file) you can't call functions in that DLL directly. You have to
>get a pointer to the function with GetProcAddress.
>Seth Jones

//
// in the variable definintion of the .cpp file-
//
#ifndef DllImport
#define DllImport FAR Pascal *
#endif
typedef int   ( DllImport  DoIt_T            )( char *thestring );

HMODULE          hDll;
DoIt_T                  DoIt ;

//
// in the body of the .cpp file
//
if( ( hDll = LoadLibrary( "A.dll" ) ) != NULL )
{
    if( ( DoIt = ( DoIt_T ) GetProcAddress( hDll, "DoIt" ) ) == NULL )
    {
      printf( "LoadLibrary() - Cannot locate function  DoItr\n" );
    }

Quote:
}

else
    printf( "LoadLibrary() - Cannot load the DLL 'A.dll'\n" );

---
Steven M. Fink
http://sfink.home.mindspring.com



Tue, 01 Aug 2000 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Linking functions problems in dll

2. Template Implementaion in a DLL problem linking problem...

3. DLL function calling problems (explicit - only knowing function name at runtime)

4. Linking against exported functions in a DLL

5. Linking error in calling a function exporting from a DLL

6. About explicit linking to DLL functions:

7. DLL doesn't link runtime functions

8. dynamically link to the function in a DLL

9. Calling RAS API functions without linking to DLL

10. Dynamic Linking DLL problem

11. Linking problem on a migrated VC6 Win32 DLL project

12. problem linking to outside dll (oracle client)

 

 
Powered by phpBB® Forum Software