The MASM Forum

General => The Campus => Topic started by: todd on January 21, 2017, 06:01:14 AM

Title: MASM32 IDE Linking question
Post by: todd on January 21, 2017, 06:01:14 AM
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
Title: Re: MASM32 IDE Linking question
Post by: ragdog on January 21, 2017, 06:57:20 AM
Hello

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

include msvcrt..inc
includelib msvcrt.lib


Greets,
Title: Re: MASM32 IDE Linking question
Post by: jj2007 on January 21, 2017, 07:20:50 AM
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.
Title: Re: MASM32 IDE Linking question
Post by: todd on January 21, 2017, 10:26:29 AM
Great!

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

Thanks!
Title: Re: MASM32 IDE Linking question
Post by: jj2007 on January 21, 2017, 10:54:26 AM
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 (http://masm32.com/board/index.php?topic=5314.0) 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

Title: Re: MASM32 IDE Linking question
Post by: todd on January 21, 2017, 05:14:19 PM
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
Title: Re: MASM32 IDE Linking question
Post by: hutch-- on January 21, 2017, 06:00:30 PM
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.