external library in pas2js file lazarus / 76-Pas2JS ---------------------------------------------------------------------- krolikbest · 2023-01-28 19:24 Hi,  i try to use some functions from my library. Declaration is as follows: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   function CalculateArm(x,y : Integer; fixedPoint : TFixedPoint; var RobotArmInfo : TRobotArmInfo; var seg : TArm) : Boolean; stdcall; external 'project1.dll';  function GetRangeOfArm(seg : TArm) : Integer; stdcall; external 'project1.dll';   but during compilation pas2js file I get the error Quoteunit1.pas(81,24) Error: Not supported: stdcall I'm using win7 64bit, Lazarus 2.0.10, but I suspect that the platform has nothing to do with it. Perhaps it is a matter to pas2js engine? I did installation two years ago, so maybe since then something in pas2js has changed and this issue appears no more? Some variables in my library are Single type and using this type in pasjs file I get also warning: Quoteunit1.pas(76,13) Warning: Symbol "Single" is not implementedI hope that in this case I'll be okey anyway. Regards, ---------------------------------------------------------------------- Thaddy · 2023-01-28 19:28 replace with winapi ---------------------------------------------------------------------- krolikbest · 2023-01-28 19:57 Now it gives me Syntax error In Project Inspector  in Required Packages are added: 'pas2js_rtl, and 'WCL'. I'm saying this because maybe it is syntax error is related to use something else but I can't use i.e. LCL and similar.. ---------------------------------------------------------------------- PierceNg · 2023-01-29 01:54 Quote from: krolikbest on January 28, 2023, 08:24:22 pmCode: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   function ...; stdcall; external 'project1.dll';  function ...; stdcall; external 'project1.dll';   Perhaps it is a matter to pas2js engine? I did installation two years ago, so maybe since then something in pas2js has changed and this issue appears no more? You mean the code worked two years ago? In web browser or with say Node? The 'compiled' output of pas2js is Javascript source code, to be run with some Javascript engine. The well known engines are the web browsers and Node, but there are others. Node supports calling DLLs. Not sure if this functionality is exposed to pas2js. Anyway if you can run Node you might also be able to run native-compiled Pascal program in its place and not use Node at all? Web browsers dropped the old Netscape plugin API a few years back. Dunno if there is some new standard. Letting web browser run native code from arbitrary DLL is a security no-no in principle. See this page: https://wiki.freepascal.org/pas2js_modules ---------------------------------------------------------------------- krolikbest · 2023-01-29 10:09 QuoteYou mean the code worked two years ago? In web browser or with say Node? No, this is my first attempt at using an external library. Fortunately this is my library (for compute some trigonometric functions) so I can easily implement them into the source of the pas2js file. ---------------------------------------------------------------------- PierceNg · 2023-01-29 11:18 Quote from: krolikbest on January 29, 2023, 11:09:31 amNo, this is my first attempt at using an external library. Fortunately this is my library (for compute some trigonometric functions) so I can easily implement them into the source of the pas2js file. After you have it all working, you could try compiling what usually goes into the DLL into WebAssembly and use it from your pas2js program. ---------------------------------------------------------------------- krolikbest · 2023-01-29 11:48 Ok, I get the idea, compiling to wasm. I will consider this for my future projects. Currently for my few function from library I've made an extra unit in pas2js project and it works. ---------------------------------------------------------------------- krolikbest · 2023-02-02 10:59 As I suspected in my first email, it is about new version of pas2js. So according to https://wiki.freepascal.org/pas2js#Releases from ver 2.1.0 (pas2js)  libraries are supported ---------------------------------------------------------------------- af0815 · 2023-02-02 11:48 Quote from: krolikbest on February 02, 2023, 11:59:54 am So according to https://wiki.freepascal.org/pas2js#Releases from ver 2.1.0 (pas2js)  libraries are supported  If i look in https://wiki.freepascal.org/pas2js_modules it is true - BUT this must be *.js Modules aka libraries ! Not normal *.so (Linux) *.dll (Windows) libraries. ---------------------------------------------------------------------- krolikbest · 2023-02-02 11:59 There is a paragraph : Using Pascal Library from Pascal. I understand it as using .so or .dll but it is highly possible that I get it wrong, have to check in near future.