Author Topic: How do I make a DLL file with NASM?  (Read 12290 times)

Offline ben321

  • Full Member
  • **
  • Posts: 185
How do I make a DLL file with NASM?
« on: June 28, 2015, 01:42:14 AM »
Is it possible to do so? Does it require a separate linker program to be used in conjunction with NASM when making a DLL file? Or is a linker only needed when making an EXE file? What command line params will be needed in NASM for making a DLL file, as opposed to an EXE file. I am using ALink for the linker. If I do need a linker to make a DLL file, what command line params will be needed in ALink when making a DLL file, and how will they differ from making an EXE file?

What about making static libraries with NASM? What about making import libraries with NASM? Do static libraries and import libraries (both of which have the LIB extension) require a linker, or only a compiler? And what would the command line parameters be for these programs when making a static library or  an import library?

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: How do I make a DLL file with NASM?
« Reply #1 on: June 30, 2015, 04:44:02 AM »
Hi ben321,

Well... typing "alink -h" informs me that "-dll" informs Alink that we want a .dll. Examination of the help screen in the executable of GoLink informs me that "/dll" does the same for GoLink. So far, so good.

http://forum.nasm.us/index.php?topic=1652.0
and
http://forum.nasm.us/index.php?topic=1678.0
appear to be examples.
http://www.nasm.us/doc/nasmdoc7.html#section-7.4.5
covers the "export" directive, which is specific to the "-f obj" output format. I ASSume there's a way to get the same effect in "-f win32" and "-f win64"(?), but I don't know what it is.

Unless I'm mistaken, there are macros in this file:
http://home.myfairpoint.net/fbkotler/nagoa20120202.zip
which will allow you to assemble a .dll with "-f bin" - without the assistance of a linker.

I believe we make static libraries with (MS's) "lib.exe" (which I seem to recall hearing just invokes "link.exe" with "certain" parameters). (or David Lindauer's "xlib.exe"?)

I've heard that we can make an import library by assembling a file with functions "import"ed and declared "extern" in "-f obj" mode. I guess that would be the only content, and I guess we'd name it ".lib". This can supposedly be used with "-f win32" objects(?).

That's all a fancy way of saying "I don't know", Ben. Wish I could help you more. If you'll detail exactly what you did, what you expected to happen, and what happened instead, someone might be able to help you narrow it down...

Best,
Frank


Offline nalsakas

  • Jr. Member
  • *
  • Posts: 18
Re: How do I make a DLL file with NASM?
« Reply #2 on: July 16, 2015, 01:26:27 PM »
Now there is another way of making exe's and dll's just using nasm alone with the help of NASM PE MACROS.

Check it out:

https://github.com/nalsakas/pe