[vim/vim] Cannot build with libsodium with MSVC 2019 on Windows 10 (#8411)

58 views
Skip to first unread message

Cthulhux

unread,
Jun 20, 2021, 12:23:38 PM6/20/21
to vim/vim, Subscribed

  1. I downloaded libsodium-msvc from the website and I pointed SODIUM= to the extraction directory.
  2. nmake.
  3. This happens:

NMAKE : U1073: "-I" konnte nicht erstellt werden

I would guess that just adding -I $(SODIUM)/include to $(INCL) - as Make_mvc.mak does it now - is not the right way to do it.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.

Christian Brabandt

unread,
Jun 20, 2021, 12:56:28 PM6/20/21
to vim/vim, Subscribed

so how should it be done? It wasn't entirely obvious for me how to add this to the makefile properly.

Cthulhux

unread,
Jun 20, 2021, 2:59:22 PM6/20/21
to vim/vim, Subscribed

I thought I had a fix for that, but it did not work. I would assume that you'd need to /I $(SODIUM)/include for the targets (i.e. for the .obj files) instead?

Christian Brabandt

unread,
Jun 21, 2021, 4:22:12 AM6/21/21
to vim/vim, Subscribed

I could build it with the following patch using MSVC 2019:

diff --git a/src/Make_mvc.mak b/src/Make_mvc.mak
index 08af05eb8..319997b78 100644
--- a/src/Make_mvc.mak
+++ b/src/Make_mvc.mak
@@ -381,18 +381,18 @@ SODIUM = no

 !if "$(SODIUM)" != "no"
 ! if "$(CPU)" == "AMD64"
-SOD_LIB                = $(SODIUM)\x64\Release\v140\dynamic
+SOD_LIB                = $(SODIUM)\x64\Release\v142\dynamic
 ! elseif "$(CPU)" == "i386"
-SOD_LIB                = $(SODIUM)\x86\Release\v140\dynamic
+SOD_LIB                = $(SODIUM)\Win32\Release\v142\dynamic
 ! else
 SODIUM = no
 ! endif
 !endif

 !if "$(SODIUM)" != "no"
-SOD_INC                = -I $(SODIUM)\include
+SOD_INC                = /I "$(SODIUM)\include"
 SOD_DEFS       = -DFEAT_SODIUM
-SOD_LIB                = $(SOD_LIB)\libsodium.lib
+SOD_LIB        = $(SOD_LIB)\libsodium.lib
 !endif

 !ifndef NETBEANS
@@ -726,7 +726,7 @@ CFLAGS = $(CFLAGS) $(CFLAGS_DEPR)

 INCL = vim.h alloc.h ascii.h ex_cmds.h feature.h errors.h globals.h \
        keymap.h macros.h option.h os_dos.h os_win32.h proto.h regexp.h \
-       spell.h structs.h term.h beval.h $(NBDEBUG_INCL) $(SOD_INC)
+       spell.h structs.h term.h beval.h $(NBDEBUG_INCL)

 OBJ = \
        $(OUTDIR)\arabic.obj \
@@ -1568,6 +1568,7 @@ $(OUTDIR)/cmdexpand.obj:  $(OUTDIR) cmdexpand.c  $(INCL)
 $(OUTDIR)/cmdhist.obj: $(OUTDIR) cmdhist.c  $(INCL)

 $(OUTDIR)/crypt.obj:   $(OUTDIR) crypt.c  $(INCL)
+       $(CC) $(CFLAGS_OUTDIR) $(SOD_INC) crypt.c

 $(OUTDIR)/crypt_zip.obj: $(OUTDIR) crypt_zip.c  $(INCL)

@@ -1618,6 +1619,7 @@ $(OUTDIR)/ex_eval.obj:    $(OUTDIR) ex_eval.c  $(INCL)
 $(OUTDIR)/ex_getln.obj:        $(OUTDIR) ex_getln.c  $(INCL)

 $(OUTDIR)/fileio.obj:  $(OUTDIR) fileio.c  $(INCL)
+       $(CC) $(CFLAGS_OUTDIR) $(SOD_INC) fileio.c

 $(OUTDIR)/filepath.obj:        $(OUTDIR) filepath.c  $(INCL)

@@ -1710,6 +1712,7 @@ $(OUTDIR)/match.obj:      $(OUTDIR) match.c  $(INCL)
 $(OUTDIR)/memfile.obj: $(OUTDIR) memfile.c  $(INCL)

 $(OUTDIR)/memline.obj: $(OUTDIR) memline.c  $(INCL)
+       $(CC) $(CFLAGS_OUTDIR) $(SOD_INC) memline.c

 $(OUTDIR)/menu.obj:    $(OUTDIR) menu.c  $(INCL)

Note: depending on your version of MSVC used, you might need to adjust the 142 to whatever you are using (and what is available in the libsodium archive). Note also, you need to distribute the vim executable together with the libsodium.dll for the architecture for which you build.

Not sure if this is the best way to build it, so requesting @k-takata review :)

Christian Brabandt

unread,
Jun 21, 2021, 4:23:25 AM6/21/21
to vim/vim, Subscribed

FWIW, I tested using several options and build Vim 32bit/64bit with and without Gui and VIMDLL.

K.Takata

unread,
Jun 21, 2021, 5:28:59 AM6/21/21
to vim/vim, Subscribed

I haven't tried libsodium yet...

Using /I or -I doesn't matter on MSVC.
If we add the sodium header directory to $CFLAGS, then we may not need to add the separate rules to crypt.c, fileio.c and memline.c, but I'm not sure which is better.

Cthulhux

unread,
Jun 21, 2021, 5:49:49 AM6/21/21
to vim/vim, Subscribed

I would suggest the CFLAGS solution as it would allow later encryption extensions in other files without having to adjust all makefiles again.

Bram Moolenaar

unread,
Jun 21, 2021, 3:08:49 PM6/21/21
to vim/vim, Subscribed

Closed #8411 via 226b28b.

Reply all
Reply to author
Forward
0 new messages