CALICAWESOME
CALICAWESOME

Reputation: 55

Linking external libraries using MASM

I have an assembly project I've written using Visual Studio 2015.

The project depends on 2 external libraries. I have included them both at the top of my .asm file like this:

include lib\Irvine\Irvine32.inc
includelib lib\Irvine\Irvine32.lib

include lib\masm32\include\winmm.inc
includelib lib\masm32\lib\winmm.lib

When I compile and run the project in Visual Studio, there are no errors and the program runs the way it's supposed to.

But when I try to compile from the command line:

ml /c /coff /Cp pacman.asm /I lib/Irvine /I lib\masm32\lib
link pacman.obj \lib\Irvine\Irvine32.lib lib\masm32\lib\winnm.lib /subsystem:console

I get a whole bunch of errors that look like this:

pacman.obj:pacman.asm:(.text+0x51): undefined reference to `_ExitProcess@4'

where ExitProcess is the name of a procedure from somewhere inside masm32.

I tried looking into the project and solution files to see if I was missing anything but I couldn't figure it out.

What is VS doing that I'm not?

Upvotes: 0

Views: 1678

Answers (1)

rkhb
rkhb

Reputation: 14409

Add explicitly the libs (kernel32 and user32) where the functions are defined:

...
includelib lib\Irvine\Irvine32.lib
includelib lib\Irvine\Kernel32.lib
includelib lib\Irvine\User32.lib
...

You can use instead the MASM32 libs:

includelib lib\masm32\lib\winmm.lib
includelib lib\masm32\lib\kernel32.lib
includelib lib\masm32\lib\user32.lib

Check the path! You're using relative paths.

Upvotes: 2

Related Questions