Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8318265
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:54:14+00:00 2026-06-08T21:54:14+00:00

I’d like to write C bindings for InpOut32 library . First of all I

  • 0

I’d like to write C bindings for InpOut32 library.

First of all I downloaded binaries for this library.

There are three files in it:

  • inpout32.lib
  • inpout32.h
  • inpout32.dll

Here’s what i’ve tried to get D to use this lib.

//io.d

extern(C)
{
    void    Out32(short PortAddress, short data);
    short   Inp32(short PortAddress);
}

// test.d 

import std.stdio;
import io;

// parallel port address
short port = 0x0378;

void main()
{
    /* data */
    short data = 0b_00000000;
    Out32(port, data);
}

Compile: dmd -c test.d io.d Result: successfull

Link: link test.obj io.obj inpout32.lib

But when I try to link I get this linker error:

OPTLINK (R) for Win32 Release 8.00.12 Copyright (C) Digital Mars

1989-2010 All rights reserved.

http://www.digitalmars.com/ctg/optlink.html inpout32.lib Offset 00000H

Record Type 0021 Error 138: Module or Dictionary corrupt

The library file probably is in the COFF format. I think coffimplib tool is not free, so I used Borland’s coff2omf tool to OMF format.After converting I still get linker errors like this:

OPTLINK (R) for Win32 Release 8.00.12

Copyright (C) Digital Mars 1989-2010 All rights reserved.

http://www.digitalmars.com/ctg/optlink.html

test.obj(test)
Error 42: Symbol Undefined _Out32

Any ideas how to use this lib? Thanks..


Update:
Today I read an interesting article about creating bindings to C libraries for the D programming language.

Now test.exe works as expected. So far I’ve done these steps.

Compile : dmd -c -g test.d io.d

Thanks Ali Çehreli for mentioning -g option. After adding -g flag access violation errors disappeared.

Generate OMF import library: implib -a inpout32.lib inpout32.dll

Link: link test.obj io.obj inpout32.lib

After this I’d like to try manually loading DLL’s. Thanks for taking the time to answer, everyone!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T21:54:17+00:00Added an answer on June 8, 2026 at 9:54 pm

    You may need to fiddle with coff2omf or similar tools’ flags regarding the leading _ characters (check the lib file to make sure symbols include them).

    Alternatively, you may find it easier to generate an OMF import library directly from the .dll, using an implib utility.

    Finally, if you only need to use a small number of functions, loading the DLL dynamically using LoadLibrary and getting the functions’ addresses using GetProcAddress will avoid all hassle with .lib files.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
For some reason, after submitting a string like this Jack’s Spindle from a text
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I know there's a lot of other questions out there that deal with this
Let's say I'm outputting a post title and in our database, it's Hello Y’all
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I've got a string that has curly quotes in it. I'd like to replace
this is what i have right now Drawing an RSS feed into the php,
I would like to run a str_replace or preg_replace which looks for certain words
I am trying to render a haml file in a javascript response like so:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.