Developing DLLs with FBC?

Windows specific questions.
coderJeff
Site Admin
Posts: 4313
Joined: Nov 04, 2005 14:23
Location: Ontario, Canada
Contact:

Re: Developing DLLs with FBC?

Post by coderJeff »

Moved to Platforms | Windows
Vortex
Posts: 118
Joined: Sep 19, 2005 9:50

Re: Developing DLLs with FBC?

Post by Vortex »

Hi dodicat,

Here is a modified version of your example :

Code: Select all

'udttest.bas

'compile with -dll to get udttest.dll

Extern "C++"

Type udt
    As Long sum
    Declare Function plus (As Long) As Long
    Declare Sub disp(As Long)
End Type

Function udt.plus (a As Long) As Long Export
    sum=sum+a
    Return sum
End Function

Sub udt.disp(a As Long) Export

Print a

End Sub

End Extern

Code: Select all

// udt2.cpp

#include<stdlib.h>
#include <stdio.h>

struct udt
{
int sum;
int plus(int a);
void disp(int a);
};


int main()
{
   udt u;
   u.sum=12;
   u.disp(u.sum);
   printf("%d\n",u.plus(8));
   system("pause");
   
}

// command line:
//g++ Udt2.cpp -o Udt2.exe -L. -l udttest -mconsole
The trick is that the decoration of the symbols should match on both sides, the DLL and the client :

The symbols from udttest.o :

Code: Select all

_ZN3udt4plusEi
_ZN3udt4dispEi
GCC and MSVC C++ Demangler :

Code: Select all

public _ZN3udt4plusEi
public _ZN3udt4dispEi

Demangled symbols :

public udt::plus(int)
public udt::disp(int)
https://demangler.com/

The sample above is compiled as 64-bit code.

Attachment :

https://we.tl/t-DWllzZc7BC

https://virusscan.jotti.org/en-US/files ... vu53b0r4mp
Post Reply