Hello, I have written a little C program composed in 2 c files
One containe
main
function and the second one containe my function called "CopyFile".
I compiled a project and it work fine.
Then I decided to include the object file in my lazarus project using this code
{$L copyfuncs.o}
function fBinFileCopyC(const infile: PChar;
const outfile: PChar; fp: TfCopyCallback ): Integer; cdecl; external;
.
After compiling I have these error in compile time :
Compile Project, Target: testcopc.exe: Exit code 1, Errors: 8
testcopc.lpr(21,1) Error: Undefined symbol: _fopen
testcopc.lpr(21,1) Error: Undefined symbol: _fseek
testcopc.lpr(21,1) Error: Undefined symbol: _fread
testcopc.lpr(21,1) Error: Undefined symbol: _fwrite
testcopc.lpr(21,1) Error: Undefined symbol: _fclose
testcopc.lpr(21,1) Error: Undefined symbol: _ftell
testcopc.lpr(21,1) Error: Undefined symbol: _malloc
testcopc.lpr(21,1) Error: Undefined symbol: _free
C function code is
int fBinFileCopyC(const char *infile, const char *outfile, fCopyCallback fp ) {
char *aBuff;
int iRead,
bSize,
ifsize = 0, /* size of the file */
iftotread = 0;
FILE *fin = NULL,
*fout = NULL;
/* */
bSize = 64*1024*1024;
aBuff = NULL;
aBuff
= (char*)malloc( bSize
*sizeof(char) ); if ( aBuff == NULL) { return -10; }
if ( (fin
= fopen(infile
, "rb")) == NULL
) { return -11; } if ( (fout
= fopen(outfile
, "wb")) == NULL
) { return -12; } /* get size of file */
/*fsetpos(fin, )*/
if ( fseek(fin
, 0, SEEK_END
) == 0 ) { }
/*--------------------------------*/
while (1) {
iRead
= fread( aBuff
, sizeof(char), bSize
*sizeof(char), fin
); if (iRead != 0) {
fwrite( aBuff
, sizeof(char), iRead
, fout
); iftotread += iRead;
/* put backup fonction here */
if (fp) { fp( infile, outfile, ifsize, iftotread, iRead ); }
} else { break; }
}
return 0;
}
So any one have experimented this issue,
Thanks for help.