Help building "cmark" on Windows


I ran .\nmake.bat and got:

NMAKE : fatal error U1064: MAKEFILE not found and no target specified
NMAKE : fatal error U1077: 'cd' : return code '0x2'

I inspected “Makefile.nmake” and tried to modify some bits but failed.


Do you have cmake installed?
It is required for the build.


Yes and cmake is in $PATH.
I just modified some bits and have built it successfully.

First, I made some edits to “Makefile.nmake”.

diff --git a/Makefile.nmake b/Makefile.nmake
index b0556e2..e4124a6 100644
--- a/Makefile.nmake
+++ b/Makefile.nmake
@@ -7,7 +7,7 @@ PROG=$(BUILDDIR)\src\cmark.exe
GENERATOR=NMake Makefiles

all: $(BUILDDIR)
    -	@cd $(BUILDDIR) && $(MAKE) /nologo && cd ..
    +	@cd $(BUILDDIR) && $(MAKE) /nologo /f ..\Makefile.nmake && cd ..

        @-mkdir $(BUILDDIR) 2> nul
        @@ -20,7 +20,7 @@ $(BUILDDIR):
            cd ..

            install: all
            -	@cd $(BUILDDIR) && $(MAKE) /nologo install && cd ..
            +	@cd $(BUILDDIR) && $(MAKE) /f ..\Makefile.nmake /nologo install && cd ..

            -rmdir /s /q $(BUILDDIR) $(MINGW_INSTALLDIR) 2> nul
            @@ -29,7 +29,7 @@ $(SRCDIR)\ $(DATADIR)\CaseFolding-3.2.0.txt
            perl < $? > $@

            test: $(SPEC) all
            -	@cd $(BUILDDIR) && $(MAKE) /nologo test ARGS="-V" && cd ..
            +	@cd $(BUILDDIR) && $(MAKE) /f ..\Makefile.nmake /nologo test ARGS="-V" && cd ..

            distclean: clean
            del /q src\scanners.c 2> nul

Then I ran .\nmake.bat and got:

cd build &&  cmake  -G "NMake Makefiles"  -D CMAKE_BUILD_TYPE=  -D CMAKE_INSTALL_PREFIX=windows  .. &&  cd ..
-- Configuring done
-- Generating done
-- Build files have been written to: D:/Workspaces/cmark/build
NMAKE : fatal error U1052: file '..\Makefile.nmake' not found
NMAKE : fatal error U1077: 'cd' : return code '0x2'
NMAKE : fatal error U1077: 'cd' : return code '0x2'

I supposed the build files are generated successfully.
I then reverted the change to “Makefile.nmake” and ran .\nmake.bat again. This time it succeeded.

So it seems the build script is not robust or not correct.


You should probably open an issue on the tracker. I don’t know much about Windows, but we can get the attention of the people who created this build script.

Incidentally, on appveyor we build cmark with one simple command, nmake. It seems to work fine:

Note that the build script might fail if the build directory exists but was not created with the appropriate files by running cmake. Can you try deleting the entire build directory, reverting nmake.bat to the version in the repository, and running it again? (But really this whole discussion should be moved to the github issue tracker.)


I’ll report this as an issue.

Previously I thought this as an ask-for-help and I want to know if the error is reproducible.


@jgm, @bohrshaw : if you want to build cmark using MSVC, maybe you find my clone helpful, see my comment over there in the issue #85 thread: I build cmark without using cmake or any build scripts, in the Visual Studio 2008 IDE.