Try to use inpout32.dll

For issues with communication ports, protocols, etc.
calatorius
Posts: 18
Joined: Oct 05, 2020 8:39

Try to use inpout32.dll

Post by calatorius »

I am trying to use the inpout32.dll library but it is impossible, I enter several threads but any of the options does not work for me. To begin I try to create the .a library with the .def file and if I create it without error but it is 0 bytes long.
I have tried with:
inpout32.def:
LIBRARY "INPOUT32.dll"
EXPORTS
Inp32 @ 4
Out32 @ 8

dlltool -k -d inpout32.def -l linpout32.dll.a

but it doesn't work, it creates a .a with zero bytes, and if I have the dll and everything in the same folder

if someone could help me
thanks
srvaldez
Posts: 3373
Joined: Sep 25, 2005 21:54

Re: Try to use inpout32.dll

Post by srvaldez »

hi calatorius, wellcome to the FreeBasic forum
I did a google search for inpout32.dll and found this http://www.highrez.co.uk/downloads/inpout32/
I ran gendef on the 32-bit dll and this is the resulting inpout32.def

Code: Select all

;
; Definition file of inpout32.dll
; Automatic generated by gendef
; written by Kai Tietz 2008
;
LIBRARY "inpout32.dll"
EXPORTS
Inp32@4
Out32@8
IsInpOutDriverOpen
DlPortReadPortUchar@4
DlPortWritePortUchar@8
DlPortReadPortUshort@4
DlPortWritePortUshort@8
DlPortReadPortUlong@4
DlPortWritePortUlong@8
IsXP64Bit
MapPhysToLin@12
UnmapPhysicalMemory@8
GetPhysLong@8
SetPhysLong@8
then running dlltool as in your example produced a 12k libinpout32.dll.a
it seems to me that you need to install the driver, I assume that you already did.
calatorius
Posts: 18
Joined: Oct 05, 2020 8:39

Re: Try to use inpout32.dll

Post by calatorius »

thanks very much
Yes I installed , but I think it installed 64 bits version, it created me the inpoutx64.sys but in any case when I try to make the library the result is a file with 0 bytes
I used the version of .def you sent me
MrSwiss
Posts: 3910
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: Try to use inpout32.dll

Post by MrSwiss »

Hi,
you cannot ever mix bitness (32/64) within the needed components for an application.
All have to be mandatorily of equal bitness: driver .sys | library .dll (+ import lib) | compiler (FBC here).
calatorius
Posts: 18
Joined: Oct 05, 2020 8:39

Re: Try to use inpout32.dll

Post by calatorius »

yes, I put all of that in the same directory .sys file dll file and lib file but it results in zero bytes file without any error.
MrSwiss
Posts: 3910
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: Try to use inpout32.dll

Post by MrSwiss »

calatorius wrote:yes, I put all of that in the same directory ...
That is NOT what I've written about, it's nothing to do with the files location on storage medium.
(due to their different purposes, they are typically located in different places)
ee: Word (computer architecture) at Wikipedia ...
Last edited by MrSwiss on Oct 05, 2020 15:34, edited 1 time in total.
calatorius
Posts: 18
Joined: Oct 05, 2020 8:39

Re: Try to use inpout32.dll

Post by calatorius »

Excuse me, maybe I have not explained myself well.
I fully understand the architecture of computers.
Before opening this post I was since yesterday testing all the possibilities and looking for all the threads in the forum on this subject.
First try as they explain in this thread viewtopic.php?f=18&t=23039&p=202686&hilit=inp32#p202686 but when I compiled the bas it return me this error:
D:\basic\WinFBE_Suite\WinFBE_Suite\FreeBASIC-1.07.1-gcc-8.4\bin\win64\ld.exe: D:\basic\WinFBE_Suite\prueba.o:fake:(.text+0x59): undefined reference to `Inp32'
linking failed: 'D:\basic\WinFBE_Suite\WinFBE_Suite\FreeBASIC-1.07.1-gcc-8.4\bin\win64\ld.exe' terminated with exit code 1
I used inpout.bi
#ifndef __INPOUT_BI__
#define __INPOUT_BI__

#ifdef __FB_WIN32__
#ifdef __FB_64BIT__
extern "Windows-MS" lib "inpoutx64"
#else
extern "Windows-MS" lib "inpout32"
#endif
declare sub Out32(byval PortAddress as short, byval data as short)
declare function Inp32(byval PortAddress as short) as short
end extern
#else
#error Sorry OS must be Windows X86 or x86_64 !
#endif
#endif

and the bas file:

Code: Select all

#include "inpout32.bi"
print Inp32(&H278)
sleep
and when I try to compile with the 64 bits version give me the error I mentioned before.
Of course I installed the driver in windows with the tool it has the pack I download in the link you mentioned before.
All ok, The problem is when I try to compile give that error.

So I continue searching and I find that perhaps is necesary to convert de dll file to a form freebasic use dll with the dlltool, but when I use with the 64 bits version it return me a zero bytes file.

I used :

Code: Select all

;
; Definition file of inpout32.dll
; Automatic generated by gendef
; written by Kai Tietz 2008
;
LIBRARY "inpoutx64.dll"
EXPORTS
Inp32@4
Out32@8
IsInpOutDriverOpen
DlPortReadPortUchar@4
DlPortWritePortUchar@8
DlPortReadPortUshort@4
DlPortWritePortUshort@8
DlPortReadPortUlong@4
DlPortWritePortUlong@8
IsXP64Bit
MapPhysToLin@12
UnmapPhysicalMemory@8
GetPhysLong@8
SetPhysLong@8
dlltool -k -d inpout64.def -l linpoutx64.dll.a

it return me no error but the result file is zero bytes I don't know why
MrSwiss
Posts: 3910
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: Try to use inpout32.dll

Post by MrSwiss »

Well, I see now that you are using WinFBE (with a nonstandard version of GCC in FBC).
We've noticed in the past that this may be causing problems with linking external *.dll's.
This in and of itself may cause problems (typically standalone WIN versions of FBC are GCC 5.2 currenly).

Therefore, I'd use a Standard Win FBC build 'standalone' and CLI (or another IDE).
(also: extern "windows-ms" on 64 bits should just be extern "windows", ms only for Win32)

Why does the .dll name (identifier) differ? Is that really so, the additional "x" in there?
calatorius
Posts: 18
Joined: Oct 05, 2020 8:39

Re: Try to use inpout32.dll

Post by calatorius »

Yes the dll file of 64 bits is like that inpoutx64.dll. It's like that in the pack I download in the link you gave me.
I installed the fbc 64 bits without ide, and i use the cli and I have the same result a zero bytes file :(
This is really incredible, I can't understand what it's happening.
And yes I tried withy the version "Windows" withouth MS yersterday and the result was the same :(

A question:
All is described in the forum with lpt printer is ok?, there is seems like it runs without adapt the dll to freebasic format dll.a
Is really necesary?

Thanks for your patience
MrSwiss
Posts: 3910
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: Try to use inpout32.dll

Post by MrSwiss »

The point is: you're not changing the .dll at all.
Making the .dll.a is just a helper known as 'import library' for FBC.

Workaround (uses a bit more storage, but works without .dll.a):
put one copy of the .dll in the _FBC_\lib\win64\ directory (for dlltool at compile time).
calatorius
Posts: 18
Joined: Oct 05, 2020 8:39

Re: Try to use inpout32.dll

Post by calatorius »

I did it
I tried to compile with this:
inpout.pi

Code: Select all

#ifndef __INPOUT_BI__
#define __INPOUT_BI__

#ifdef __FB_WIN32__
#ifdef __FB_64BIT__
extern "Windows" lib "inpoutx64"
#else
extern "Windows" lib "inpout32"
#endif
declare sub Out32(byval PortAddress as short, byval data as short)
declare function Inp32(byval PortAddress as short) as short
end extern
#else
#error Sorry OS must be Windows X86 or x86_64 !
#endif

#endif
And this bas file:

Code: Select all

#include "inpout.bi"
screen 13
print Inp32(&h3d9)
getkey
I used CLI and give that error:

D:\basic\FreeBASIC-1.07.1-win64>fbc prueba.bas
prueba.o:fake:(.text+0x59): undefined reference to `Inp32'
MrSwiss
Posts: 3910
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: Try to use inpout32.dll

Post by MrSwiss »

As a first test just use:

Code: Select all

#include "inpout.bi"
getkey
undefined reference to `Inp32'
might only be correct for the 32 bit version?
srvaldez
Posts: 3373
Joined: Sep 25, 2005 21:54

Re: Try to use inpout32.dll

Post by srvaldez »

srvaldez wrote: I ran gendef on the 32-bit dll and this is the resulting inpout32.def
the 64-bit def file is different

Code: Select all

;
; Definition file of inpoutx64.dll
; Automatic generated by gendef
; written by Kai Tietz 2008
;
LIBRARY "inpoutx64.dll"
EXPORTS
Inp32
Out32
IsInpOutDriverOpen
DlPortReadPortUchar
DlPortWritePortUchar
DlPortReadPortUshort
DlPortWritePortUshort
DlPortReadPortUlong
DlPortWritePortUlong
IsXP64Bit
MapPhysToLin
UnmapPhysicalMemory
GetPhysLong
SetPhysLong
btw, to get the dll.a
dlltool -d inpoutx64.def -l libinpoutx64.dll.a
calatorius
Posts: 18
Joined: Oct 05, 2020 8:39

Re: Try to use inpout32.dll

Post by calatorius »

In theory is for 64 bits too, the pack include the 64 bits version of dll and when install the driver it works correctly and create the 64 bits .sys file.
The fact is that the functions are the same named in 32 or 64 bits, inp32 and out32.
For me is a mysterious why is not working both things. Using the dll directly give me the last message and when I try to use dlltool give me a zero file.
I used the .def file that srvaldez wrote and with the same result:(
calatorius
Posts: 18
Joined: Oct 05, 2020 8:39

Re: Try to use inpout32.dll

Post by calatorius »

Code: Select all

#ifndef __INPOUT_BI__
#define __INPOUT_BI__

#ifdef __FB_WIN32__
#ifdef __FB_64BIT__
extern "Windows" lib "inpoutx64"
#else
extern "Windows" lib "inpout32"
#endif
declare sub Out32(byval PortAddress as short, byval data as short)
declare function Inp32(byval PortAddress as short) as short
end extern
#else
#error Sorry OS must be Windows X86 or x86_64 !
#endif

#endif
This code is correct for the .pi file?
I think if it's correct I can't understand why when compiles give a error "undefined reference to ´Inp32´
Perhaps is referred to "PortAddress"?, and why no error in Out32 that is a line before to compile?
Post Reply