1

I have a C++ project in Visual Studio 2022, which creates a .dll which calls a function created by the MASM assembler. The assembler - ml64 - however does not consider a single .inc file, and so fails with a error LNK2019: unresolved external symbol error.

I have one file, Core.asm which links to V.inc which in turn links to V_Constants.inc. The files are linked together using include, so Core.asm has include V.inc, which in turn has include V_Constants.inc.

Initially this worked well, however when I changed Core.asm in a trivial way, everything stopped. I can empty the file to rule out any weird syntax errors and I get the same.

Changing the output to show what it is doing (as much as possible, by removing the /nologo command line) shows that the assembler is missing out V.inc, yet including everything else.

What could possibly stop ml64.exe from ignoring a file? Is it possible to force the assembly?

Interestingly if I rename V.inc I get a cannot open file: v.inc error. So it knows to include this file, yet it doesn't want to assemble it.

BJury
  • 2,526
  • 3
  • 16
  • 27
  • 1
    Without seeing a minimal complete example it is hard to say. Can you put the contetnts of all the files (the includes in question) and core.asm in your question. You did say "Initially this worked well, however when I changed Core.asm in a trivial way, everything stopped. I can empty the file to rule out any weird syntax errors and I get the same." I'd be curious what the trivial change was. – Michael Petch Aug 15 '22 at 22:55
  • So when looking how to explain what is going on, it appears the Include in the `.vcxproj` has changed. Why would VS do that?! – BJury Aug 15 '22 at 23:05
  • Okay, I got your project but can't actually build it as you are (I'm using VS 2019) and I don't have all the required dependencies. But I think what is happening is that it is trying to assemble the .INC files. You don't assemble the INC files, just the ASM files that may include them. So `core.asm` should be assembled but the INC files shouldn't be. What happens if you mark both INC files as TEXT? – Michael Petch Aug 15 '22 at 23:59
  • Thank you for looking, I've tried many combinations none seem to work with the same error. I'll try to boil it down to a basic example and post it as a new question. – BJury Aug 16 '22 at 08:11

1 Answers1

0

Looks like something in Visual Studio 2022 changed the include element in the xml in the .vcxproj file, from MASM to text. I have no idea why.

This is what I had, note the wrong element for V.inc.

  <ItemGroup>
    <MASM Include="Core.asm" />
  </ItemGroup>
  <ItemGroup>
    <MASM Include="V_Constants.inc" />
  </ItemGroup>
  <ItemGroup>
    <Text Include="V.inc" />
  </ItemGroup>

Edit : So it turns out the original issue is that the main .asm file needs to include the external files. These cannot be be included as MASM elements in the project file.

In addition, I had END directives at the end of these .inc files, this is incorrect as it stops the processing. (I added these as when the files had a MASM element the assembler would complain about there not being an END. This was a big red-herring, and lead me down the wrong path.)

tl;dr: Files that are included should be marked as Text, and don't add an END to these files!


Edit 2: However, marking these files as text stops the project from being recompiled when they are changed.

BJury
  • 2,526
  • 3
  • 16
  • 27
  • You haven't told it to actually assemble the INC files directly have you? You don't assemble INC files. You just assemble the ASM files that may rely on those iNC files. – Michael Petch Aug 15 '22 at 23:09
  • No, I just added them, `include`'d them, and it initially worked. Something in VS would appear to have changed the elements. I do think something else is at play here, as its still not compiling, even with empty files but maybe that's a different question. – BJury Aug 15 '22 at 23:11
  • Any chance you can put the project (including the VS project files and everything else) onto Github to look at? – Michael Petch Aug 15 '22 at 23:15