News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

MASM32 IDE Linking question

Started by todd, January 21, 2017, 06:01:14 AM

Previous topic - Next topic

todd

Greetings! Where in the MASM32 IDE can I set a link list? For example, let's say I write a program that is going to use C's printf function. I need to link to msvcrt.lib, but I can find no place in the IDE to tell the linker where msvcrt.lib is.

Thanks!
~todd

ragdog

Hello

Write in your code where your includes example
include windows.inc
..
.
Write:

include msvcrt..inc
includelib msvcrt.lib


Greets,

jj2007

Console assemble & link:
include \masm32\include\masm32rt.inc

.code
start:
  printf("The number is %f\n", FP8(1234.5678))
  invoke crt_printf, cfm$("The number is %f\n"), FP8(1234.5678)
  invoke crt_printf, chr$("The number is %f", 13, 10), FP8(1234.5678)
  exit

end start


Option #1 is a macro,
#2 uses the crt_ prefix to identify a C RunTime function, and uses the cfm$() macro to produce a C-formatted string
#3 uses the crt_ prefix and a standard chr$() macro with Cr, Lf

Open \masm32\include\masm32rt.inc in Notepad, and you will understand why this works.

todd

Great!

But I still need to know how to add something to the link list. Is there a setting in the IDE?

Thanks!

jj2007

Normally, there is no need to add something: the linker "sees" the includelib \..*.lib statements

If you need to link other object modules, you need to write your own batch file for use with qEditor.exe; if you need it often, you can add it to the menus, see \Masm32\menus.ini

I use RichMasm for all my coding; if I insert this line somewhere in the source, the linker will get it:
; OPT_DebugL   some.obj /Largeaddressaware

include \masm32\include\masm32rt.inc

.code
start:
  printf("The number is %f\n", FP8(1234.5678))
  exit

end start

OPT_DebugL some.obj


todd

Okay, I get it now - it's all done by include and includelib statements. Or, if I have one or more obj files to link, then create a batch file.

Thanks to all who posted!!
~todd

hutch--

todd,

There is another option that is worth learning, if you have a number of object modules, you can place them in a library then just call the library instead of linking each one on the link command line. Just another way to build exe/dll code that is useful.