The MASM Forum

General => The Campus => Topic started by: totosayen_cpp on May 01, 2021, 10:22:15 PM

Title: include error on D:
Post by: totosayen_cpp on May 01, 2021, 10:22:15 PM
Hello again :biggrin:,
I've tried to move masm32 from C: to D:, but not at the root (D:/.../masm32).
I searched on the forum and saw that the folder should be at the root, or else we must use a trick on Windows to create an alias of a volume.
This is the batch file used for assembling :

@echo off
set file=%1
if %file%V equ V (echo No arg given ! & pause & exit)
set app=%file:~0,-4%
echo *************************************************************************************************************
echo Assembling %file% into %app%.exe
echo *************************************************************************************************************
echo.
echo.
subst Z: D:\Programmation\Assembleur
Z:\masm32\bin\ml.exe /c /coff /Cp /nologo /W3 /I"Z:" /I"Z:\masm32\include" %file%
Z:\masm32\bin\link.exe /subsystem:console /release /version:4.0 /libpath:"Z:" /libpath:"Z:\masm32\lib" /out:%app%.exe %app%.obj
subst Z: /D
%app%.exe
echo.
echo.
echo *************************************************************************************************************
pause


I got the following error :
Quote
Z:\masm32\include\masm32rt.inc(38) : fatal error A1000: cannot open file : \masm32\include\windows.inc
(and another from the linker whch cannot open test.obj)

So it seems that I did something wrong, but I can't see where, because the compiler says that it cannot find a file, but I put /I"Z:\masm32\include" in the batch file.
Could you please healp me to find the error ?
Title: Re: include error on D:
Post by: jj2007 on May 01, 2021, 10:52:14 PM
Your problem happens here:
subst Z: D:\Programmation\Assembleur
Z:\masm32\bin\ml.exe /c /coff /Cp /nologo /W3 /I"Z:" /I"Z:\masm32\include" %file%


Try
subst Z: D:\Programmation\Assembleur
Z:
\masm32\bin\ml.exe /c /coff /Cp /nologo %file%


Your %file% is on Z:, I suppose?
Title: Re: include error on D:
Post by: totosayen_cpp on May 01, 2021, 11:41:42 PM
Thanks for your reply.
If I add Z: in the .bat, the .obj file is created in Z: directory, instead of being in the same folder than %file%.
And by the way the linker is unable to find the .obj in the same folder of %file%.

So I can make a little code which moves the .obj in the correct folder, but it involves the parsing of the file's path to find the directory.
Is there a better solution ?
Title: Re: include error on D:
Post by: jj2007 on May 01, 2021, 11:53:10 PM
I have been using the SUBST trick for many years, never had similar problems.

My suspicion is that your drive Z is not permanent enough. Suppose you want a permanent drive M: (like "Masm"); press Alt R, type regedit and hit Return. Then go for this:

Key      HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\DOS Devices
RegSZ    M: (you need to create a new REG_SZ value)
Text     \??\D:\Programmation\Assembleur


Save and reboot. Afterwards, you have P:\Masm32\... and all the rest.
Title: Re: include error on D:
Post by: totosayen_cpp on May 02, 2021, 12:19:50 AM
I tried both A: and M: but each time I try to open it (command A: or M: with CMD), I get an error.
So, I think I'll modify my batch file to move the .obj .
Thanks for time spent on my problem  :azn:

(Perhaps I'll edit post with new file for person who will maybe have the same problem)
Title: Re: include error on D:
Post by: jj2007 on May 02, 2021, 12:23:45 AM
Moving files around is not a solution - even if you get it to work, you'll regret it later on.

What kind of errors do you get with A: or M: with CMD? If the drives really exist (and they should, if the registry entry is correct, and you rebooted), then typing A: or M: should never throw an error.

(Btw A: was a special drive, I wonder if the OS has some legacy quirks that could make problems (https://hackaday.com/2019/09/30/the-legacy-of-the-floppy-still-looms-over-windows/))
Title: Re: include error on D:
Post by: totosayen_cpp on May 02, 2021, 01:17:57 AM
I'll strive to describe and translate correctly :

I've edited the register and rebooted the computer.
When I open explorer.exe, a new local disk appeared, M:, so that's ok (but the icon has a ? near the picture)
If I want to access, Windows throws me an error :
Quote
M:\ isn't accessible.
Syntax or file's, directory's or volume's name is incorrect.

So I guess I didn't edit correctly the register :
Title: Re: include error on D:
Post by: jj2007 on May 02, 2021, 01:38:52 AM
Quote from: totosayen_cpp on May 02, 2021, 01:17:57 AM
  • Changed its value to D:\Programmation\Assembleur\

That should be \??\D:\Programmation\Assembleur
Title: Re: include error on D:
Post by: totosayen_cpp on May 02, 2021, 01:45:05 AM
Thanks, all is now working as expected  :thumbsup:

I didn't write the \??\ because I thought you meant "replace it by parent directories".
Title: Re: [Resolved] include error on D:
Post by: jj2007 on May 02, 2021, 01:52:36 AM
Quote from: totosayen_cpp on May 02, 2021, 01:45:05 AM
Thanks, all is now working as expected  :thumbsup:

Congrats, now it's time to code :thumbsup:
Title: Re: include error on D:
Post by: totosayen_cpp on May 02, 2021, 05:17:00 PM
After several changes, the batch file can compile and link without modifying register (that's quite handy for me, if I want to code on my school's computers where I haven't admin rights fo course) :


@echo off

set file=%1
if %file%V equ V (echo No arg given ! & pause & exit)

call :extractNames %file%

echo *************************************************************************************************************
echo Assembling %file% into %app%.exe
echo *************************************************************************************************************
echo.
echo.

subst Z: D:\Programmation\Assembleur
Z:
set zFilePath=%filePath%
set zFilePath=%zFilePath:D:\Programmation\Assembleur=%
cd %zFilePath%
echo %zFilePath% %cd%
Z:\masm32\bin\ml.exe /c /coff /Cp /nologo /W3 /I"Z:\" /I"Z:\masm32\include\" %file%
Z:\masm32\bin\link.exe /subsystem:console /release /version:4.0 /libpath:"Z:\" /libpath:"Z:\masm32\lib\" /out:%app%.exe %app%.obj
%drive%
subst Z: /d

%app%.exe
echo.
echo.
echo *************************************************************************************************************
pause

:extractNames
set drive=%~d1
set filePath=%drive%%~p1
set app=%filePath%%~n1


Instead of compiling at the wrong place and then moving, I extracted the path from the complete file name and then went to Z: (temp drive) and moved to the file's directory to build and link at the same place.

Links which helped me :

I hope it may help someone with the same problems.
Title: Re: include error on D:
Post by: Vortex on May 02, 2021, 06:21:21 PM
Hi totosayen_cpp,

Concerning the Masm32 package, the best installation location is the root of a partition. Simple and easy.
Title: Re: include error on D:
Post by: totosayen_cpp on May 02, 2021, 06:28:31 PM
Evenif it's finally a bit more complicated than leave it at the root, I did that to organize correctly my files.
But I wonder why it needs to be at the root of a (virtual or not) drive...
Title: Re: include error on D:
Post by: jj2007 on May 02, 2021, 06:53:58 PM
Quote from: totosayen_cpp on May 02, 2021, 06:28:31 PM
But I wonder why it needs to be at the root of a (virtual or not) drive...

Because all the includes in all examples are organised as
include \Masm32\include\msvcrt.inc
includelib \Masm32\lib\msvcrt.lib

No need for environment variables. And it works, always. Compare that to the incredible mess of a C++ compiler...
Title: Re: include error on D:
Post by: Vortex on May 02, 2021, 06:58:08 PM
Easy. You probably have heard of Occam's razor, an important principle of science and philosophy. Prefering the root of a partition as the installation location makes easy the maintainance of your batch files. Nearly all of my .bat files are looking like the following :

C:\masm32 or D:\masm32 :


\masm32\bin\ml /c /coff Hello.asm
\masm32\bin\polink /SUBSYSTEM:WINDOWS Hello.obj


I don't have to tweak complicated .bat files to build Masm projects.

jj2007 is right, you can see the complications of some C++ compilers to build even the most simple hello world project.
Title: Re: include error on D:
Post by: totosayen_cpp on May 02, 2021, 07:31:34 PM
Thank you both for the explanation.

And yes, I code in C++, so I know how hard and tricky it sometimes can be to include external libraries (especially the first time).

Now, that's all, thank you again and good day
Title: Re: include error on D:
Post by: jj2007 on May 02, 2021, 08:01:10 PM
The Masm32 SDK system of hard-coded paths may look a bit ancient, but it works. It works absolutely fine on code specifically designed to run with the latest Windows 10 version, and it works on somewhat older code, too.

With "older" I don't mean the C++ notion of "as old as the previous Visual whatever version of last year". I mean as old as \Masm32\examples\exampl01\minimum\minimum.asm of January 1999 :cool:
Title: Re: include error on D:
Post by: hutch-- on May 02, 2021, 08:01:45 PM
toto,

Trying to put the project elsewhere than directly off the drive root is self inflicted punishment. It was designed originally so it could be put on any partition and it would work correctly on that partition. The whole construction is based around having a reliable path so that people do not get the path errors you have been getting. I used to get the problem years ago from people who wanted to put it in a directory called MASM then I used to hear from them the it "dozen werk".

The current installer removes that error as it will only install directly off the drive root directory. Just reinstall it correctly and it will work correctly.
Title: Re: include error on D:
Post by: hutch-- on May 02, 2021, 11:53:37 PM
Oe request for all, don't use the [resolved] notation as this forum is not a help desk, its a forum of members.
Title: Re: include error on D:
Post by: totosayen_cpp on May 03, 2021, 06:56:02 AM
Thanks for additional informations and sorry for [resolved].