News:

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

Main Menu

How to build an asm file in different directory?

Started by laskar01, June 21, 2012, 11:15:26 PM

Previous topic - Next topic

laskar01

Hi all, it is almost a year since I've been here, had to reregister...

I've restarted Iczelions number 2 tutorial, but cannot build it because the Linker answers:

LINK : fatal error LNK1104: cannot open file "kernel32.lib"

I can rebuild Hutch's examples, though, in the example directory, but I cannot do a coplete build in a different directory. .obj file is generated though.


Kindest regards,
Lasse

hutch--

Either put the path to the binaries OR set the path environment in a make style batch file.

laskar01

Hi Hutch, I don't get it. I've typed in the console-window

set PATH=c:\mas32\lib
set PATH=c:\masm32\lib\kernel32.lib

and I've also tried set LIBPATH=c:\masm32\lib

I've verified the existence of the path, by executing "set" at the console window, and I also restarted the computer.

I've shut down the virus-scanner during installation.
It doesn't work to build the .asm file inside the masm32 folder, but I can rebuild all of your examples!

dedndave

when you set environment variables at the prompt or in batch files,
they only have a lifetime of the console window where they were created

if you want to permanently set variables...
My Computer - Properties
Advanced tab - Environment Variables button

you can elect to set variables for the current user name - or system-wide, which affects all users

the window provided is a hard place to edit the strings
i usually copy/paste the string into a temporary text file, edit the string, then copy/paste it back into the window  :t

hutch--

As Dave mentioned, the SET capacity only exists for the life of the console process. Either put the paths directly in the file OR run a batch file that sets the environment.

I would recommend against setting the OS environment as it prevents you from running multiple copies and additional compilers that also use LINK and other LIB files.

MASM32 is specifically designed to be able to run on a machine that has multiple compilers and assemblers but it comes at the price of properly setting the paths to the binaries.

laskar01

Thanks Hutch and dedndave.
I am learning, but very, very slowly.

I've accomplished to assemble and link from the command-line
ml /c /coff /Cp msgbox.asm
link /SUBSYSTEM:WINDOWS /LIBPATH:c:\masm32\lib msgbox.obj

It works, but when I delete the object and the exe-file and try to do a "Build all" from the quick editor I get the above mentioned message from the linker that it - cannot open file "kernel32.lib"

But as I said I can rebuild Hutch's asm-files, no problem, so the problem is me, nothing else!

Am I to sloppy for assemblyprogramming? I'm starting doubting myself....
:(

jj2007

Kernel32.lib is present, as \masm32\lib\kernel32.lib
If your code asks for \masm32\lib\kernel32.lib, it will work.
If it asks for kernel32.lib, it will not work, as there is no kernel32.lib in the current folder.

There is a reason why many of us use as first line
include \masm32\include\masm32rt.inc
instead of the whole bunch of model directives etc...

dedndave

there are a few caveats that apply, here
perhaps one of them will hit home   :P

1. the masm32 package should be installed in the root of a drive
it can be any drive (C:\, D:\, etc), but it must be in the root of that drive (C:\masm32)

2. the package is set up so that you can only assemble from that same drive
so - you want your project(s) to be on the same drive

3. there is really not much need for setting the LIB, MASM, INCLUDE environment variables
the masm32 package is not set up to be used that way

4. the one environment variable that will help is the PATH variable
it makes things easier if the C:\masm32\bin folder is in the PATH (or whatever drive you use)

5. in the \masm32\bin folder, you will find different batch files that may be used at the command prompt
for a SUBSYSTEM:WINDOWS app, the one named "build.bat" will work
you can open the batch file with NotePad to see what it does

6. follow Jochen's advice   :P
QuoteThere is a reason why many of us use as first line
include \masm32\include\masm32rt.inc
instead of the whole bunch of model directives etc...

laskar01

Thank you all people. You are very helpful.

I changed from the original
includelib user32.lib
includelib kernel32.lib

to

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

in tut02, and now it works in quickeditor!

Izcelions original tut02 code is attached below.

Kindest regards,
Lasse


.386
.model flat, stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
includelib kernel32.lib
include \masm32\include\user32.inc
includelib user32.lib

.data
MsgCaption      db "Iczelion's tutorial no.2",0
MsgBoxText      db "Win32 Assembly is Great!",0

.code
start:
   invoke MessageBox, NULL,addr MsgBoxText, addr MsgCaption, MB_OK
   invoke ExitProcess,NULL
end start

Vortex

Hi laskar01,

The original code for tutorial #2 is :


.386
.model flat,stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
includelib \masm32\lib\kernel32.lib
include \masm32\include\user32.inc
includelib \masm32\lib\user32.lib