воскресенье, 20 ноября 2016 г.

Using Makefile with MSVC on example of libsqlite3_unicode

Cygwin Makefile can be used for building C programs with Visual Studio C compiler in simple regular way without .sln files.

Here I have an examaple on GitHub: https://github.com/Zensey/sqlite3_unicode
It is an minimized extension w/o external dependencies, which adds support of Unicode to sqlite3 used for search and sort operations with non-latin strings.

To build this extension under Windows platform simply run make in Cygwin terminal or run mk.cmd. Below you can see how this Makefile is arranged. Note, that variable M is used to set target architecture of executable object.
CC = cl
LIBS = kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib
M = /MACHINE:X86
#M = /MACHINE:X64
CFLAGS = /MD /GS /GL /W3 /Gy /Zc:wchar_t /I"..\sqlite-autoconf-3130000" /Gm- /O2 /sdl /fp:precise /D "_WINDLL" /D "_MBCS" /errorReport:prompt /WX- /Zc:forScope /Gd /Oi /EHsc /nologo /c
LINK = /ERRORREPORT:PROMPT /NOLOGO /NXCOMPAT /DYNAMICBASE /OPT:REF /OPT:ICF /IMPLIB:"ext.lib" /DLL /TLBID:1 /LTCG
RM = rm -f
default: all
all: Hello
Hello: sqlite3_unicode.c
$(CC) $(CFLAGS) $(M) sqlite3_unicode.c
link.exe $(LINK) $(M) sqlite3_unicode.obj /OUT:"unicode.dll"
clean veryclean:
$(RM) Hello
view raw Makefile hosted with ❤ by GitHub


вторник, 8 ноября 2016 г.

Setup Syncthing as a service on Windows

To setup and start Syncthing as a service:
- download Syncthing, unpack
- download nssm.exe and put it into directory of syncthing
- put syncthing-svc-setup-win32.bat script into directory of syncthing
- run syncthing-svc-setup-win32.bat as Administrator
set appdir=%~dp0
cd %appdir%
@echo off
@setlocal
nssm.exe install Syncthing syncthing.exe -no-console -no-browser -home="c:\users\litvinov.a\AppData\Local\Syncthing"
nssm set Syncthing AppDirectory %appdir%
nssm.exe edit Syncthing
net start Syncthing
pause