Ticket Change Details
Overview

Artifact ID: 321d35e5f7e0c05c61578f9dba611807581228134c0c33700a9bbe93806eebb4
Ticket: 604bb68b5c25a5c670b2f89dba68b92f7c57cb62
How to build Tcl tls on Windows 64 bit (VisualStudio 12) from scratch?
User & Date: oehhar on 2020-10-20 16:11:58
Changes

  1. icomment:
    Here is the patch starting from checkin [9c32a526ed] for your convenience.
    
    Enjoy,
    Harald
    
    <verbatim>
    Index: tls.c
    ==================================================================
    --- tls.c
    +++ tls.c
    @@ -1774,11 +1774,11 @@
      *	 create the ssl command, initialise ssl context
      *
      *-------------------------------------------------------------------
      */
     
    -int Tls_Init(Tcl_Interp *interp) {
    +DLLEXPORT int Tls_Init(Tcl_Interp *interp) {
     	const char tlsTclInitScript[] = {
     #include "tls.tcl.h"
                 0x00
     	};
     
    @@ -1834,11 +1834,11 @@
      *		A standard Tcl error code.
      *
      *------------------------------------------------------*
      */
     
    -int Tls_SafeInit(Tcl_Interp *interp) {
    +DLLEXPORT int Tls_SafeInit(Tcl_Interp *interp) {
     	dprintf("Called");
     	return(Tls_Init(interp));
     }
     
     /*
    
    Index: tls.h
    ==================================================================
    --- tls.h
    +++ tls.h
    @@ -21,9 +21,9 @@
     #include <tcl.h>
     
     /*
      * Initialization routines -- our entire public C API.
      */
    -int Tls_Init(Tcl_Interp *interp);
    -int Tls_SafeInit(Tcl_Interp *interp);
    +DLLEXPORT int Tls_Init(Tcl_Interp *interp);
    +DLLEXPORT int Tls_SafeInit(Tcl_Interp *interp);
     
     #endif /* _TLS_H */
    
    ADDED   win/README.txt
    Index: win/README.txt
    ==================================================================
    --- win/README.txt
    +++ win/README.txt
    @@ -0,0 +1,66 @@
    +	Windows DLL Build instructions using nmake build system
    +	2020-10-15 [email protected]
    +
    +Properties:
    +- 32 bit DLL
    +- VisualStudio 2015
    +Note: Vuisual C++ 6 does not build OpenSSL (long long syntax error)
    +- Cygwin32 (temporary helper, please help to replace by tclsh)
    +- OpenSSL statically linked to TCLTLS DLL.
    +Note: Dynamic linking also works but results in a DLL dependeny on OPENSSL DLL's
    +
    +1) Build OpenSSL static libraries:
    +
    +OpenSSL source distribtution unpacked in:
    +c:\test\tcltls\Openssl_1_1_1h
    +
    +- Install Perl from http://strawberryperl.com/download/5.32.0.1/strawberry-perl-5.32.0.1-32bit.msi
    +  to C:\perl
    +  (ActivePerl failed due to missing 32 bit console module)
    +- Install NASM Assembler:
    +
    +https://www.nasm.us/pub/nasm/releasebuilds/2.15.05/win32/nasm-2.15.05-installer-x86.exe
    +  to C:\Program Files (x86)\NASM
    +  
    +-> Visual Studio x86 native prompt.
    +
    +set Path=%PATH%;C:\Program Files (x86)\NASM;C:\Perl\perl\bin
    +
    +perl Configure VC-WIN32 --prefix=c:\test\tcltls\openssl --openssldir=c:\test\tcltls\openssldir no-shared no-filenames threads
    +
    +nmake
    +nmake test
    +namke install
    +
    +2) Build TCLTLS
    +
    +Unzip distribution in:
    +c:\test\tcltls\tcltls-1.7.22
    +
    +-> start cygwin bash prompt
    +
    +cd /cygdrive/c/test/tcltls/tcltls-1.7.22
    +./gen_dh_params > dh_params.h
    +
    +od -A n -v -t xC < 'tls.tcl' > tls.tcl.h.new.1
    +sed 's@[^0-9A-Fa-f]@@g;s@..@0x&, @g' < tls.tcl.h.new.1 > tls.tcl.h
    +rm -f tls.tcl.h.new.1
    +
    +-> Visual Studio x86 native prompt.
    +
    +cd C:\test\tcltls\tcltls-1.7.22\win
    +
    +nmake -f makefile.vc TCLDIR=c:\test\tcl8610 SSL_INSTALL_FOLDER=C:\test\tcltls\openssl
    +
    +nmake -f makefile.vc install TCLDIR=c:\test\tcl8610 INSTALLDIR=c:\test\tcltls SSL_INSTALL_FOLDER=C:\test\tcltls\openssl
    +
    +tls.c: 
    +Lines 1779, 1839: replace
    +int Tls_Init by
    +DLLEXPORT int  Tls_Init
    +
    +tls.h: same change
    +
    +lappend auto_path {C:\test\tcltls\tls1.7.22}
    +package require tls
    +
    
    ADDED   win/makefile.vc
    Index: win/makefile.vc
    ==================================================================
    --- win/makefile.vc
    +++ win/makefile.vc
    @@ -0,0 +1,24 @@
    +# call nmake with additional parameter SSL_INSTALL_FOLDER= with the
    +# OpenSSL instalation folder following.
    +
    +PROJECT=tls
    +DOTVERSION = 1.7.22
    +
    +PRJ_INCLUDES	= -I"$(SSL_INSTALL_FOLDER)\include"
    +PRJ_DEFINES =  -D NO_SSL2 -D NO_SSL3 -D _CRT_SECURE_NO_WARNINGS
    +
    +PRJ_LIBS = \
    +	"$(SSL_INSTALL_FOLDER)\lib\libssl.lib" \
    +	"$(SSL_INSTALL_FOLDER)\lib\libcrypto.lib" \
    +	WS2_32.LIB GDI32.LIB ADVAPI32.LIB CRYPT32.LIB USER32.LIB
    +
    +PRJ_OBJS = $(TMP_DIR)\tls.obj \
    +               $(TMP_DIR)\tlsBIO.obj \
    +               $(TMP_DIR)\tlsIO.obj \
    +               $(TMP_DIR)\tlsX509.obj
    +
    +!include "rules-ext.vc"
    +!include "targets.vc"
    +
    +pkgindex: default-pkgindex
    +
    
    ADDED   win/targets.vc
    Index: win/targets.vc
    ==================================================================
    --- win/targets.vc
    +++ win/targets.vc
    @@ -0,0 +1,98 @@
    +#------------------------------------------------------------- -*- makefile -*-
    +# targets.vc --
    +#
    +# Part of the nmake based build system for Tcl and its extensions.
    +# This file defines some standard targets for the convenience of extensions
    +# and can be optionally included by the extension makefile.
    +# See TIP 477 (https://core.tcl-lang.org/tips/doc/trunk/tip/477.md) for docs.
    +
    +$(PROJECT): setup pkgindex $(PRJLIB)
    +
    +!ifdef PRJ_STUBOBJS
    +$(PROJECT): $(PRJSTUBLIB)
    +$(PRJSTUBLIB): $(PRJ_STUBOBJS)
    +	$(LIBCMD) $**
    +
    +$(PRJ_STUBOBJS):
    +	$(CCSTUBSCMD) %s
    +!endif # PRJ_STUBOBJS
    +
    +!ifdef PRJ_MANIFEST
    +$(PROJECT): $(PRJLIB).manifest
    +$(PRJLIB).manifest: $(PRJ_MANIFEST)
    +	@nmakehlp -s << $** >$@
    +@MACHINE@	  $(MACHINE:IX86=X86)
    +<<
    +!endif
    +
    +!if "$(PROJECT)" != "tcl" && "$(PROJECT)" != "tk"
    +$(PRJLIB): $(PRJ_OBJS) $(RESFILE)
    +!if $(STATIC_BUILD)
    +       $(LIBCMD) $**
    +!else
    +       $(DLLCMD) $**
    +       $(_VC_MANIFEST_EMBED_DLL)
    +!endif
    +       -@del $*.exp
    +!endif
    +
    +!if "$(PRJ_HEADERS)" != "" && "$(PRJ_OBJS)" != ""
    +$(PRJ_OBJS): $(PRJ_HEADERS)
    +!endif
    +
    +# If parent makefile has defined stub objects, add their installation
    +# to the default install
    +!if "$(PRJ_STUBOBJS)" != ""
    +default-install: default-install-stubs
    +!endif
    +
    +# Unlike the other default targets, these cannot be in rules.vc because
    +# the executed command depends on existence of macro PRJ_HEADERS_PUBLIC
    +# that the parent makefile will not define until after including rules-ext.vc
    +!if "$(PRJ_HEADERS_PUBLIC)" != ""
    +default-install: default-install-headers
    +default-install-headers:
    +	@echo Installing headers to '$(INCLUDE_INSTALL_DIR)'
    +	@for %f in ($(PRJ_HEADERS_PUBLIC)) do @$(COPY) %f "$(INCLUDE_INSTALL_DIR)"
    +!endif
    +
    +!if "$(DISABLE_STANDARD_TARGETS)" == ""
    +DISABLE_STANDARD_TARGETS = 0
    +!endif
    +
    +!if "$(DISABLE_TARGET_setup)" == ""
    +DISABLE_TARGET_setup = 0
    +!endif
    +!if "$(DISABLE_TARGET_install)" == ""
    +DISABLE_TARGET_install = 0
    +!endif
    +!if "$(DISABLE_TARGET_clean)" == ""
    +DISABLE_TARGET_clean = 0
    +!endif
    +!if "$(DISABLE_TARGET_test)" == ""
    +DISABLE_TARGET_test = 0
    +!endif
    +!if "$(DISABLE_TARGET_shell)" == ""
    +DISABLE_TARGET_shell = 0
    +!endif
    +
    +!if !$(DISABLE_STANDARD_TARGETS)
    +!if !$(DISABLE_TARGET_setup)
    +setup: default-setup
    +!endif
    +!if !$(DISABLE_TARGET_install)
    +install: default-install
    +!endif
    +!if !$(DISABLE_TARGET_clean)
    +clean: default-clean
    +realclean: hose
    +hose: default-hose
    +distclean: realclean default-distclean
    +!endif
    +!if !$(DISABLE_TARGET_test)
    +test: default-test
    +!endif
    +!if !$(DISABLE_TARGET_shell)
    +shell: default-shell
    +!endif
    +!endif # DISABLE_STANDARD_TARGETS
    
    </verbatim>
    
  2. login: "oehhar"
  3. mimetype: "text/x-fossil-wiki"
  4. username: "oehhar"