créér une dll avec borland c++ compiler
j'aimerais developper une dll avec borland c++ compiler et j'aimerais connaitre la ligne de compilation qui permet de generer le DLL a partir du code c++ et / ou s'il il fo quelleques lignes "speciales" dans le code.
sous visual on le dis seulement a la creation du projet et y fait tout tout seul
Compiler une dll avec Borland C++
Bonsoir,
Pour compiler votre .c en DLL 32bits assurer vous que
avez cette fonction dans votre source
Code:
1 2 3 4 5
|
BOOL WINAPI DllEntryPoint(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved )
{
return TRUE ;
} |
De plus pour des raisons de compatibilité donnez la convention
d'appel __stdcall
Code:
1 2 3
|
par ex :
BOOL __stdcall _export strToLdouble( LPCSTR z, long double * val ) ; |
Finallement choisissez le fichier COD32DYN.OBJ comme fichier
de démarrage
Cordialement.
Creation de DLL avec Borland C++
Bonsoir,
PRECONDITIONS
-Vous utilisez Win9x ou plus.
-Vous utilisez Borland C++ 5.0 ou ultérieur
-Les exemples qui suivent s'appliquent à Borland C++ 5.01 ou 5.02
pas à CBuilder.
FIN des PRECONDITIONS
Pour se faire une idée de la programmations des DLL en C 32bits
consulter mon message précédent.
(Pas d'autres fonctions ni constantes sont nécéssaires ) .
Pour informations sur les DLL compatibles Delphi, Borland C++, Visual
C++, Visual Basic 4.0 .
Citation:
Calling 32-bit DLL's built with Borland C++ from non-BC Apps
Currently, Borland C++ supports calling a DLL compiled with Borland C++ from
applications created with other tools only if they are dynamically bound to the
DLL. This is achieved by the application calling LoadLibrary at run-time to load
the DLL and then calling GetProcAddress to retrieve the entry points for the
functions exported from the DLL.
Static binding is not supported. From a C or C++ application, static binding is
achieved by linking import records (either import libraries or entries in the
IMPORTS section of the application's Module Definition File) to the calling
application. Using Delphi 2.0, static binding is achieved using a declaration
such as:
function Foo(parm: Integer): Integer; stdcall; external 'my.dll' name 'Foo';
You can use either C++ or Structured Exception Handling in the DLL. For best
results, exceptions should be caught within the scope of the DLL throwing the
exception. If the calling application is built with Borland C++, Delphi or
Microsoft Visual C++, the exception can be caught in the application calling the
DLL; however, Visual Basic does not seem to have an exception handlng syntax.
To create an EH-compatible 32-bit DLL, just replace the default startup code,
c0d32.obj for 32-bit DLL's, with c0d32dyn.obj and re-link the DLL. Using
command-line tools, the startup code is the first object module specified to
Tlink32. Using the Integrated Development Environment, select Options |
Environment | Project View and check Show run-time nodes. In the project window,
there will now be displayed entries for the startup module and all the libraries
which are automatically linked in depending on your target. Remove the node for
the startup code, c0d32.obj, and add c0d32dyn.obj in its place.
I hope you have a fluent English.
May be better if I say "I wish you have a fluent English" .
Si vous voulez créer une DLL qui tient compte de la gestion des exceptions
vous devez la lier avec une version dynamique de la librairie des DLL.
Exemple :
Soit MyDyll la librairie à produire sous Win9x :
1) bcc32 -c -D_RTLDLL MyDll.c
2) TLink32 -Tpd -aa -x c0d32dyn MyDll, MyDll.dll, , import32 cw32i
Cette compilation assure la compatibilité avec Delphi, Visual C++,
Visual Basic ( sous réserve pour ce dernier ) .
Je rappelle que ces instructions ne sont valides que pour les créateurs de
DLL avec Borland C++ 5.02.
La compatibilité entre appel de DLL entre Borland C++ ( et BCbuilder ) se
fait par une convention d'appel dite "__stdcall".
Avec CBuilder les instructions sont légérement différentes.
Cordialement.