Page 1 of 1

Inpout32 Dev-Cpp and Codebloks linking error

Posted: Sun Jan 08, 2012 12:46 am
by lope
Hi! sorry about my english but I am from spain, I have recenly started to work with Impout32 and I have some problems in order to get it working...

1. At first, I have downloaded the last version of Inpout32 from here

2. Installed the "Installdriver.exe" file as admin, it returned "Succesfuly installed and opened 64bit inpout driver Inpout64.sys"

3. Then I have created a new proyect on Dev-Cpp, with inpout32.lib on the same folder.
May should use inpoutx64.lib? My pc is an AMD Atholon II runing a 64bit version of Windows 7 ultimate
Well, I have created a really easy try program on Dev-Cpp, here the code:

Code: Select all

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

void	_stdcall Out32(short PortAddress, short data);
short	 _stdcall Inp32(short PortAddress);

int main(){

Out32(0xCD00,255); // yes! my LPT is on 0xCD00
return 0;


When I try to compile it gives an error "[Linker Error] undefined reference to `Out32(short, short)@8'"
I try to link on Proyect Options/Additional options on comand line/Linker -> Add Library or object. adding the inpout32.lib but it doesn´t work, the same error... and the same on CodeBloks compiler.

May I should link not adding the inpout32.lib but with some like -lxxx linker comand?

I have been looking for a solution for a long time, hope you can help me, and sorry again about my bad english... :oops:

Re: Inpout32 Dev-Cpp and Codebloks linking error

Posted: Sun Jan 08, 2012 1:08 am
by phil
Sorry but Im not familiar with the compilers you are using. I've only ever used MS C++ compilers.
However, I would expect it to be similar, and adding the InpOut32.lib to the linker options (additional libraries) should do the trick.

Having said that, when I use InpOut32 I don't use the LIB to link to the DLL. I use runtime linking, with LoadLibrary, GetProcAddress etc. which means the DLL can be easily replaced with no re-compiling.

You only need to use the x64 library if your building in x64 mode (I presume your not?).

Other than that I don't really know what to suggest. Have you looked at the c++ example on the website?


Re: Inpout32 Dev-Cpp and Codebloks linking error

Posted: Sun Jan 08, 2012 4:35 pm
by lope
OK problem solved, I couldn´t get inpout32.lib linked to my proyect, or if I could, It doesnt work anyway, so I tried as you said with runtimelinking, so I used this code created for the old version of Impout32 and it works perfectly!!

Code: Select all

#include <stdio.h>
#include <conio.h>
#include <windows.h>

     typedef short _stdcall (*inpfuncPtr)(short portaddr);
     typedef void _stdcall (*oupfuncPtr)(short portaddr, short datum);

int main(void)
     HINSTANCE hLib;
     inpfuncPtr inp32;
     oupfuncPtr oup32;

     int i;
     hLib = LoadLibrary("inpout32.dll");
     if (hLib == NULL) {
          printf("LoadLibrary Failed.\n");
           Sleep(2000);return -1; Sleep(2000);
     inp32 = (inpfuncPtr) GetProcAddress(hLib, "Inp32");
     if (inp32 == NULL) {
          printf("GetProcAddress for Inp32 Failed.\n");
          Sleep(2000); return -1; Sleep(2000);
     oup32 = (oupfuncPtr) GetProcAddress(hLib, "Out32");
     if (oup32 == NULL) {
          printf("GetProcAddress for Oup32 Failed.\n");
           Sleep(2000);return -1; 
     /* Aqui va tu codigo */
     /* Aqui termina tu codigo */
     return 0;
If I execute the program on another machine it should auto-install the driver, or it can work only with inpout32.dll on the same folder?? It should work on a 32 and 64bit machine not? my application is compiled on 32 bits!

Re: Inpout32 Dev-Cpp and Codebloks linking error

Posted: Sun Jan 08, 2012 4:42 pm
by phil
Im glad the runtime linkage is working for you.

The driver needs administrative permission to be installed. That is why I created InstallDriver.exe which requests admin elevation on Vista/Win7. You should be able to call this exe (or the DLL directly) from an installer of some sort.

The driver is embedded in the DLL and at first run the relevate driver file (x86 or x64) is extracted from the resources and installed, where it will be placed in the system32\drivers folder. From then on, it no longer needs admin elevation to run.

The source code of the DLL is available on the website if you need more info as to how this works!

The DLL needs to be in the path somewhere, but ideally along side your executable as that is where the runtime will look first (and it means if another DLL with the same name exists, it will avoid confusion).


Re: Inpout32 Dev-Cpp and Codebloks linking error

Posted: Sun Jan 08, 2012 5:01 pm
by lope
So you are the creator of this library?? wow! awersome work!! congratulations!

Ok so if I execute the code I have post before on another machine as admin, as I am using the dll on runtime link it should install the driver the first time I do it, I dont need to call any other funcition of the dll or something like that?

Re: Inpout32 Dev-Cpp and Codebloks linking error

Posted: Sun Jan 08, 2012 5:07 pm
by phil
No I did not create InpOut32, I only ported the driver and DLL to 64bit (x64) windows using the original source on the website (the author).

I think if I recall correctly, you only have to load the DLL. That should do the work of installing the driver. There are some helper functions exported from the DLL, like "IsInpOutDriverOpen()" that you can call to verify the driver is loaded and running but they are not necessary for installation.

Take a look in the header provided in the binaries download for a list of all the functions and their call prototypes.


Re: Inpout32 Dev-Cpp and Codebloks linking error

Posted: Sun Jan 08, 2012 5:23 pm
by lope
OK sorry, I allready now you just ported the driver and dll but I feel very thaksfull because is dificult to find libreries for parallel port programing sice modern computer arent using parallel ports, I was using a partition of my pc with winxp (using Logix4U inpout32) and another with ubuntu for years before I found this dll.

I am creating something like a programable card with an eprom by parallel port for my computing class so now I have to create the control software in order to read/write data from it, when finished I will be back and will tell you how have it gone.

Thanks another time!