
Originally Posted by
Smartzkid
In my opinion, it's easier to compile the c/cpp right into a dll to be used by SCAR (rather than the obj/cross linking thing).
I think you might be interested in
this thread, by yakman.
alright well how do i call the dll? ill continue looking throught the scar includes but this is what i have atm
dllmain.cpp
Code:
#include "my_dll.h"
#define SCAR_EXPORT
extern "C"
{
SCAR_EXPORT int Add( int a, int b )
{
return( a + b );
}
}
my_dll.h
Code:
#ifndef _MY_DLL_H_
#define _MY_DLL_H_
#if defined SCAR_EXPORT
#define SCAR_EXPORT _declspec(dllexport) __stdcall
#else
#define SCAR_EXPORT _declspec(dllexport) __stdcall
#endif
extern "C"
{
SCAR_EXPORT int Add( int a, int b );
}
#endif
libtest.def
Code:
LIBRARY my_test_dll
DESCRIPTION "a dll to test this crap"
EXPORTS
Add @1
Function @2
now i just need to figure out how to call it...
this is the first time ive ever even attempted a dll, so be gentle lol
edit: i think im defining SCAR_EXPORT incorrectly
edit again:
since scar is like delphi, i tried using delphi commands from scar (yea i know a shot in the dark)
needless to say this didnt work
Code:
program New;
var
DLLHandle: THandle;
begin
DLLHandle := LoadLibrary('C:\Dev-Cpp\DLL\test.dll');
writeln(add(5,5));
end.
like i said previously ive never made a dll and dont have the first clue about how scar interacts with them
i also tried this.... no dice
Code:
program New;
function add(x,y:integer):integer; external 'Add@test.dll SCAR_EXPORT';
begin
writeln(add(5,5));
end.
i get THESE erros ^^^ tried stdcall instead od scar_export still nothing
Code:
Line 5: [Error] (5:1): Invalid Calling Convention in script C:\Program Files\SCAR 3.20\Scripts\testDLL.scar
Line 5: [Error] (5:1): in script C:\Program Files\SCAR 3.20\Scripts\testDLL.scar