Board index » cppbuilder » Link DLL using BCC32 free compiler

Link DLL using BCC32 free compiler


2004-08-04 04:32:46 PM
cppbuilder19
How is a DLL linked to an application using the free command line compiler, BCC32 (version 5.5)? Both are written in ANSI C.
For example, if MyDLL.c is:
__declspec(dllexport) int __stdcall DLLFunction1(int num)
{ return(2*num); }
It is compiled to a DLL at the command line using:
Quote
bcc32 -WD MyDLL.c
to generate MyDLL.dll, MyDLL.obj. and MyDLL.tds. Then the lib file is generated using:
Quote
implib MyDLL.lib MyDLL.dll
Both MyDLL.lib MyDLL.dll are added to the project directory. If the application, named test_MyDLL.c is:
__declspec(dllimport) void __stdcall DLLFunction1(int num);
int main(void){
int ret_val=DLLFunction1(6);
return 0;
}
the compiler error is:
Error E2468 test_MyDLL.c 3: Value of type void is not allowed in function main
 
 

Re:Link DLL using BCC32 free compiler

One of two things:
- The C and C++ languages specify a main that does not have a calling
argument of 'void'. Change to 'int main()'
- The function prototype:
Quote
__declspec(dllimport) void __stdcall DLLFunction1(int num);
has a return type of 'void' meaning it does not return anything.
However you try to use a return value in this line:
Quote
int ret_val=DLLFunction1(6);
You are using the command line tools from C++ Builder but are posting
questions to the newsgroup for the old Borland C++ compiler. Post
questions about your compiler to newsgroups with 'cppbuilder' in their
name.
. Ed
Quote
Doug Martin wrote in message
news:41109f2e$ XXXX@XXXXX.COM ...

How is a DLL linked to an application using the free command
line compiler, BCC32 (version 5.5)? Both are written in ANSI C.

For example, if MyDLL.c is:

__declspec(dllexport) int __stdcall DLLFunction1(int num)
{ return(2*num); }

It is compiled to a DLL at the command line using:

>bcc32 -WD MyDLL.c

to generate MyDLL.dll, MyDLL.obj. and MyDLL.tds. Then the lib
file is generated using:

>implib MyDLL.lib MyDLL.dll

Both MyDLL.lib MyDLL.dll are added to the project directory. If the
application, named test_MyDLL.c is:

__declspec(dllimport) void __stdcall DLLFunction1(int num);
int main(void){
int ret_val=DLLFunction1(6);
return 0;
}

the compiler error is:

Error E2468 test_MyDLL.c 3: Value of type void is not allowed in
function main