Xojo says my VS2022 64-bit .lib /.dll contains an error?

I have a 64-bit .dll with its .lib compiled by Visual Studio 2022. The subroutine, called DLLTEST, adds two 4-byte integers into a third 4-byte integer. Dumpbin.exe reports that all is as expected…

Xojo compiles, but when I try to use the .dll in a 64-bit Xojo app, there is this error message:
“… DLLTEST.lib is either not designed to run on Windows or it contains an error … error status 012f”

The Xojo External Method matches the .dll. Here is the method:
Method: DLLTEST
Parameters: byref in1 as integer, byref in2 as integer, byref out1 as integer
Return type: blank (this .dll is a subroutine)
Lib: DLLTEST.Lib

(have also tried SOFT DECLARE SUB)

Here is the VS2022 code. It is Intel IFORT Fortran:
subroutine DLLTEST (IN1, IN2, OUT1)
!DEC$ ATTRIBUTES DLLEXPORT::DLLTEST
!DEC$ ATTRIBUTES REFERENCE:: IN1, IN2, OUT1
integer*4 IN1, IN2, OUT1
OUT1 = IN1 + IN2
end

I have tried variables byref and byvalue, and also compiled the routine as a subroutine and a function, with matching Xojo external methods. Always the same error message.

Any suggestions about the error?

This is similar to Make and Call AddTwo from DLL but that was for a 32-bit .dll

I may be missing something, but are you trying to link a static lib into Xojo, instead of loading a DLL?

Xojo can only do declares to .dll files, not .lib files.

You can link the lib into a dll usually.

In Fortran code you may be missing

BIND(C,name="DLLTEST")

Too.

And OUT1 may not work as you expect too.

And I don’t know the implications of

To Xojo.

Hello @Mike_Linacre1,

I have a 2022 Visual Studio Github project that creates the AddTwo dll from Visual Studio, and when the dll is placed in the example Xojo plugin folder, it compiles and runs properly in 64-bit mode.

Visual Studio 2022
Xojo 2023 R4
Windows 11

Here is the link to the github project with Visual Studio 2022 code and the example Xojo program:

Eugene’s Github 64-bit github project example

This would be a good place to start with Windows DLL code and then add another method to see if it runs on your computer.

Let me know if it works on your computer :slight_smile:

Edit: Here is a link to a YouTube video where I create the DLL from scratch: YouTube Visual Studio 2022 Xojo DLL video

I guess his intent is for another kind of code base, Eugene.

By the way, IFORT is phased out, and users must migrate to IFX, ASAP.

1 Like

Rick, absolutely correct! Stupid me. That should be
Lib DLLTEST.Dll

Thank you everyone! Am kicking myself.

1 Like

Oops, you are correct @Rick_Araujo , my mistake. :slight_smile:

1 Like