Author Topic: How to build an asm file in different directory?  (Read 2405 times)

laskar01

  • Guest
How to build an asm file in different directory?
« on: June 21, 2012, 11:15:26 PM »
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--

  • Administrator
  • Member
  • ******
  • Posts: 1685
  • Mnemonic Driven API Grinder
    • View Profile
    • The MASM32 SDK
Re: How to build an asm file in different directory?
« Reply #1 on: June 21, 2012, 11:19:27 PM »
Either put the path to the binaries OR set the path environment in a make style batch file.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :biggrin:

laskar01

  • Guest
Re: How to build an asm file in different directory?
« Reply #2 on: June 21, 2012, 11:56:37 PM »
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

  • Member
  • *****
  • Posts: 6426
  • Still using Abacus 2.0
    • View Profile
Re: How to build an asm file in different directory?
« Reply #3 on: June 22, 2012, 12:01:22 AM »
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--

  • Administrator
  • Member
  • ******
  • Posts: 1685
  • Mnemonic Driven API Grinder
    • View Profile
    • The MASM32 SDK
Re: How to build an asm file in different directory?
« Reply #4 on: June 22, 2012, 12:26:49 AM »
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.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :biggrin:

laskar01

  • Guest
Re: How to build an asm file in different directory?
« Reply #5 on: June 22, 2012, 01:01:59 AM »
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

  • Member
  • *****
  • Posts: 3215
    • View Profile
    • MasmBasic
Re: How to build an asm file in different directory?
« Reply #6 on: June 22, 2012, 01:50:11 AM »
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

  • Member
  • *****
  • Posts: 6426
  • Still using Abacus 2.0
    • View Profile
Re: How to build an asm file in different directory?
« Reply #7 on: June 22, 2012, 02:29:11 AM »
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
Quote
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...

laskar01

  • Guest
Re: How to build an asm file in different directory?
« Reply #8 on: June 22, 2012, 03:05:00 AM »
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

  • Member
  • *****
  • Posts: 1136
    • View Profile
Re: How to build an asm file in different directory?
« Reply #9 on: June 22, 2012, 04:45:34 AM »
Hi laskar01,

The original code for tutorial #2 is :

Code: [Select]
.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