Aurel300/ammer

Can't produce hdll

Closed this issue · 4 comments

When building the sample, I ended up ultimately modifying build-hl.hxml like so:

build-common.hxml
-D ammer.hl.hlInclude=C:\Users\user\Desktop\hl-1.10.0-win/include
-D ammer.hl.hlLibrary=C:\Users\user\Desktop\hl-1.10.0-win
-D ammer.hl.build=bin/hl
-D ammer.hl.output=bin/hl
--hl bin/hl/sample.hl

I then ran nmake from the Visual Studio 2019 Developer Prompt on Makefile.win in the native folder, which worked. I have the library files.

Now, when I run haxe build-hl.hxml I get this error:
'"C:\Users\user\Desktop\New folder\ammer\ammer\samples\poc\nmake"' is not recognized as an internal or external command,

Which I expected, as nmake is only accessible from the VS 2019 Developer Command Prompt for me. So, when I open the prompt and run nmake on Makefile.hl.ammer, I get this output:

C:\Users\user\Desktop\New folder\ammer\ammer\samples\poc\bin\hl>nmake /F 
Makefile.hl.ammer

Microsoft (R) Program Maintenance Utility Version 14.24.28316.0
Copyright (C) Microsoft Corporation.  All rights reserved.

        C:/Users/user/Desktop/New folder/ammer/ammer/samples/poc/cl /c ammer_adder.hl.c /I C:/Users/user/Desktop/New folder/ammer/ammer/samples/poc/native /I C:\Users\user\Desktop\hl-1.10.0-win/include
        C:/Users/user/Desktop/New folder/ammer/ammer/samples/poc/cl /LD ammer_adder.hl.obj /DLIBHL_EXPORTS /link /OUT:ammer_adder.hdll /LIBPATH:C:\Users\user\Desktop\hl-1.10.0-win libhl.lib /LIBPATH:C:/Users/user/Desktop/New folder/ammer/ammer/samples/poc/native adder.lib

Which, I guess should mean it is successful? I'm not sure, I don't usually play with Makefiles. But I don't get any output at all from this (at leas that I know of), judging by the Makefile, it looks like it should be generating an hdll file no?

And of course, when I run the hl file (Which was built despite the nmake error) it complains about the missing hdll.

Am I missing some steps?

Oh, upon further inspection it seems to be creating the Makefile incorrectly? I'm not really sure why but it's prefixing a lot of things with the cwd that shouldn't be (like nmake, even though it still wouldn't be accessible, but it should simply be nmake)

Here it's prefixing cl with the cwd as well, and cl clearly wouldn't (and doesn't) exist there.

It also needs to quote escape paths with spaces (folder path here is 'New Folder', couldn't find my adder.h, so I added quotes)

I guess I'll just post my resultant makefile once it builds with the changes I made.

EDIT:

This is the Makefile that finally built ammer_adder.hdll for me:

all: ammer_adder.hdll
	@:

ammer_adder.hdll: ammer_adder.hl.obj
	cl /LD ammer_adder.hl.obj /DLIBHL_EXPORTS /link /OUT:ammer_adder.hdll /LIBPATH:C:\Users\user\Desktop\hl-1.10.0-win libhl.lib /LIBPATH:"C:/Users/user/Desktop/New folder/ammer/ammer/samples/poc/native" adder.lib

ammer_adder.hl.obj: ammer_adder.hl.c
	cl /c ammer_adder.hl.c /I "C:/Users/user/Desktop/New folder/ammer/ammer/samples/poc/native" /I C:\Users\user\Desktop\hl-1.10.0-win/include

.PHONY: 

And my output folder structure looks like this:

bin/hl
| ammer_adder.hdll
| ammer_adder.hl.c
| ammer_adder.hl.exp
| ammer_adder.hl.lib
| ammer_adder.hl.obj
| Makefile.hl.ammer
| sample.hl

It still didn't run. (Couldn't load ammer_adder.hdll)

But then I copied adder.dll from the native folder to bin/hl and it ran fine (couldn't open file 'dummy.txt' however, but likely because my cwd is bin/hl).

So I guess it needs quote escaping and to play a little better with working directories other than that seems to work like a charm!

These are changes I could make myself so maybe I will make a PR if that will make things easier.

ETA: Less useful (and kind of obvious info) but copying dummy.txt to bin/hl fixes read file, so the entire sample works fine it seems barring the issues I mentioned above.

Thanks for the report. I think you listed three issues above:

  • CWD showing up in the Makefile when using MSVC - this was an oversight by me when I merged #26. The config now (correctly) defaults to "", i.e. cl and nmake need to be in the PATH, as stated in the manual.
  • Spaces in paths - good point.
  • Missing adder.dll and dummy.txt - this is actually addressed in the readme for the sample project; both of the files need to be copied next to the .hl binary for the sample to work

I pushed 85ad75e just now, which should fix the first two issues. I don't think there's much to be done about the third! Let me know if there are any more issues with this, feel free to close if not.

I would call this closed, as I am able to produce the hdll now though.

Thanks!