Subj : Help with DLL, some additional questions. To : borland.public.cpp.borlandcpp From : tazzi Date : Sat Nov 20 2004 06:25 pm Ed: I have had some success and some additional questions. This dialog continues from an earlier question, which was incorrectly posted at newsgroups.borland.com/borland.public.cppbuilder for those interested in following the entire thread. Using the first bit of code that you supplied, I performed 3 experiments. The code is listed below: Code: ------------------------------------------------- #include #ifdef __BORLANDC__ #pragma argsused #endif BOOL WINAPI DllEntryPoint( HINSTANCE dllInst, DWORD reason, LPVOID i) { return TRUE; } __declspec(dllexport) int __stdcall mult(int a, int b) { return a*b; } -------------------------------------------------- Experiment #1: 1. From IDE, compile mult.c to mult.dll. -> This produces the file mult.dll which is 6.5kb long. 2. Start Maple and attempt to load with the following command: > mult := > define_external('mult', > a::integer[4], > b::integer[4], > LIB="mult.dll", > RETURN::integer[4]): -> Produces a failed load, with the following error message: "Error, external lookup of mult: The specified procedure could not be found." Experiment #2: 1. From command line, compile mult.c to mult.dll using the following command (Note: Must kill Maple session, as the program has opened "mult.dll" and this file can not be deleted): bcc32 -WD mult.c -> This produces the file mult.dll which is 56kb long. 2. Start Maple and attempt to load with previous command. -> Produces a successful load! 3. Now test the DLL: > mult(2,3); -> 6 (Correct answer) Experiment #3: 1. Copy mult.c to mult.cpp (the original extension used in my first correspondence). From command line, compile mult.cpp to mult.dll using the following command: bcc32 -WD mult.cpp -> This produces the file mult.dll which is 56kb long. 2. Start Maple and attempt to load with previous command. -> Produces a failed load, with the following error message: "Error, external lookup of mult: The specified procedure could not be found." --------------------------------------------- Ed, can you answer the following questions? 1. Returning to you previous answer, I don't understand where I would use second bit of code that you supplied: Code: ---------------------------------------------- #ifndef SOMEDLL_H #define SOMEDLL_H /* handle if this C function is used from C++ */ #ifdef __cplusplus extern "C" #endif __declspec(dllimport) int __stdcall mult(int, int); #endif ---------------------------------------------- 2. Can you explain what settings I need to make in the IDE to get it to compile correctly, as with the command line experiment #2? 3. When the code has a cpp extension, does the compiler change the function names? This may be why experiment #3 failed. Thanks, tazzi .