News:

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

Main Menu

include error on D:

Started by totosayen_cpp, May 01, 2021, 10:22:15 PM

Previous topic - Next topic

totosayen_cpp

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 ?

jj2007

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?

totosayen_cpp

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 ?

jj2007

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.

totosayen_cpp

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)

jj2007

#5
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)

totosayen_cpp

#6
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 :

  • Win+R regedit [Enter] -> as administrator
  • Browsing to Ordinateur\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\DOS Devices
  • Right click -> new -> string value ("valeur chaĆ®ne" in French, if the translation isn't correct)
  • Named it M:
  • Changed its value to D:\Programmation\Assembleur\
  • Rebooted the computer
  • Started Chrome and went to MASM forum to reply  :biggrin:

jj2007

#7
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

totosayen_cpp

#8
Thanks, all is now working as expected  :thumbsup:

I didn't write the \??\ because I thought you meant "replace it by parent directories".

jj2007

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:

totosayen_cpp

#10
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 :

  • https://stackoverflow.com/questions/15567809/batch-extract-path-and-filename-from-a-variable
  • https://www.dostips.com/DtTipsStringManipulation.php#Snippets.Remove

I hope it may help someone with the same problems.

Vortex

#11
Hi totosayen_cpp,

Concerning the Masm32 package, the best installation location is the root of a partition. Simple and easy.

totosayen_cpp

#12
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...

jj2007

#13
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...

Vortex

#14
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.