G
Guest
Hello,
I'm trying to use a DLL (by static linking) which was compiled with Borland
C++Builder (BCB) in Visual C++ (Visual-Studio 2003).
All functions are declared with the directive 'extern "C"' so that a
cross-compiler-usage must be possible.
I created an import library (.lib) for MSVC by using the LIB function and
using a .DEF file (as described in KB131313 -
http://support.microsoft.com/default.aspx?scid=kb;en-us;131313)
My DUMPBIN showed the following exports:
ordinal hint RVA name
2 0 000012E4 @SayHello2
1 1 000012D0 SayHello1
3 2 000012F8 _SayHello3
4 3 0000130C _SayHello4
5 4 000090F8 ___CPPdebugHook
So I created a .DEF as follows:
EXPORTS
@SayHello2
SayHello1
_SayHello3
_SayHello4
The .lib and .exp generation succeeded so far.
The declaration (.h) used in BCB and included in MSVC later on is as follows:
#ifndef __BCB2VC_DLL_H
#define __BCB2VC_DLL_H
#ifdef __BUILD_DLL__
#define __DECL_SPEC__ __declspec(dllexport)
#else
#define __DECL_SPEC__ __declspec(dllimport)
#endif //#ifdef __BUILD_DLL__
extern "C" __DECL_SPEC__ void __stdcall SayHello1(void);
extern "C" __DECL_SPEC__ void __fastcall SayHello2();
extern "C" __DECL_SPEC__ void __cdecl SayHello3();
extern "C" __DECL_SPEC__ void SayHello4();
#endif //#ifndef __BCB2VC_DLL_H
In my MSVC application I simply try to call the functions:
int _tmain(int argc, _TCHAR* argv[])
{
SayHello1();
SayHello2();
SayHello3();
SayHello4();
}
This lead to the result, that I received the following linker errors:
Test.obj : error LNK2019: Nicht aufgelöstes externes Symbol
'__imp__SayHello4', verwiesen in Funktion '_main'
Test.obj : error LNK2019: Nicht aufgelöstes externes Symbol
'__imp__SayHello3', verwiesen in Funktion '_main'
Test.obj : error LNK2019: Nicht aufgelöstes externes Symbol
'__imp_@SayHello2@0', verwiesen in Funktion '_main'
Test.obj : error LNK2019: Nicht aufgelöstes externes Symbol
'__imp__SayHello1@0', verwiesen in Funktion '_main'
Debug/USE_BCB_DLL.exe : fatal error LNK1120: 4 unaufgelöste externe Verweise
---
when I create the .LIB with the .DEF like:
EXPORTS
SayHello2
SayHello1
SayHello3
SayHello4
and call the functions with (calling SayHello1 and SayHello2 doesn't succeed
at all):
int _tmain(int argc, _TCHAR* argv[])
{
//SayHello1();
//SayHello2();
SayHello3();
SayHello4();
}
then my application starts (which means linking succeeds). But while
starting, a MessageBox appears, which says:
'The entrypoint of "SayHello3" in "Test.dll" could not be found.'
So what is wrong here? How do I manage to get to get my DLL run without
changing the calling conventions (__stdcall / __fastcall) ?
Thanks,
Uli
I'm trying to use a DLL (by static linking) which was compiled with Borland
C++Builder (BCB) in Visual C++ (Visual-Studio 2003).
All functions are declared with the directive 'extern "C"' so that a
cross-compiler-usage must be possible.
I created an import library (.lib) for MSVC by using the LIB function and
using a .DEF file (as described in KB131313 -
http://support.microsoft.com/default.aspx?scid=kb;en-us;131313)
My DUMPBIN showed the following exports:
ordinal hint RVA name
2 0 000012E4 @SayHello2
1 1 000012D0 SayHello1
3 2 000012F8 _SayHello3
4 3 0000130C _SayHello4
5 4 000090F8 ___CPPdebugHook
So I created a .DEF as follows:
EXPORTS
@SayHello2
SayHello1
_SayHello3
_SayHello4
The .lib and .exp generation succeeded so far.
The declaration (.h) used in BCB and included in MSVC later on is as follows:
#ifndef __BCB2VC_DLL_H
#define __BCB2VC_DLL_H
#ifdef __BUILD_DLL__
#define __DECL_SPEC__ __declspec(dllexport)
#else
#define __DECL_SPEC__ __declspec(dllimport)
#endif //#ifdef __BUILD_DLL__
extern "C" __DECL_SPEC__ void __stdcall SayHello1(void);
extern "C" __DECL_SPEC__ void __fastcall SayHello2();
extern "C" __DECL_SPEC__ void __cdecl SayHello3();
extern "C" __DECL_SPEC__ void SayHello4();
#endif //#ifndef __BCB2VC_DLL_H
In my MSVC application I simply try to call the functions:
int _tmain(int argc, _TCHAR* argv[])
{
SayHello1();
SayHello2();
SayHello3();
SayHello4();
}
This lead to the result, that I received the following linker errors:
Test.obj : error LNK2019: Nicht aufgelöstes externes Symbol
'__imp__SayHello4', verwiesen in Funktion '_main'
Test.obj : error LNK2019: Nicht aufgelöstes externes Symbol
'__imp__SayHello3', verwiesen in Funktion '_main'
Test.obj : error LNK2019: Nicht aufgelöstes externes Symbol
'__imp_@SayHello2@0', verwiesen in Funktion '_main'
Test.obj : error LNK2019: Nicht aufgelöstes externes Symbol
'__imp__SayHello1@0', verwiesen in Funktion '_main'
Debug/USE_BCB_DLL.exe : fatal error LNK1120: 4 unaufgelöste externe Verweise
---
when I create the .LIB with the .DEF like:
EXPORTS
SayHello2
SayHello1
SayHello3
SayHello4
and call the functions with (calling SayHello1 and SayHello2 doesn't succeed
at all):
int _tmain(int argc, _TCHAR* argv[])
{
//SayHello1();
//SayHello2();
SayHello3();
SayHello4();
}
then my application starts (which means linking succeeds). But while
starting, a MessageBox appears, which says:
'The entrypoint of "SayHello3" in "Test.dll" could not be found.'
So what is wrong here? How do I manage to get to get my DLL run without
changing the calling conventions (__stdcall / __fastcall) ?
Thanks,
Uli