Skip to content

Commit

Permalink
Merge pull request #87 from ledoge/build-instructions
Browse files Browse the repository at this point in the history
Update build instructions
  • Loading branch information
yuk7 committed Jan 26, 2021
2 parents b1d5dce + e01d8b6 commit 14760e7
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions DEVELOPERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,20 @@

#### Visual Studio or Build Tools 2017+

Use `Developer Command Prompt for Visual Studio` or run these in the Windows Command Prompt
Use `x64 Native Tools Command Prompt for VS 2017` or run this in the Windows Command Prompt (replace `2017` with `2019` for VS 2019)
```cmd
:: initialize x64 build environment
CALL "%ProgramFiles(x86)%\\Microsoft Visual Studio\\2017\\Community\\VC\\Auxiliary\\Build\\vcvarsall.bat" x64
```

Generate wslapi.lib
```cmd
lib /nologo /def:wslapi.def /machine:X64
```

To compile Launcher.exe
```cmd
cl /nologo /O2 /W4 /WX /Ob2 /Oi /Oy /Gs- /GF /Gy /Tc main.c /Fe:Launcher.exe Advapi32.lib Shell32.lib shlwapi.lib
cl /nologo /O2 /W4 /WX /Ob2 /Oi /Oy /Gs- /GF /Gy /Tc main.c /Fe:Launcher.exe Advapi32.lib Shell32.lib shlwapi.lib wslapi.lib
```

Optionally, to add an icon to the exe, create and link a resource with
Expand All @@ -26,7 +31,7 @@ rc /nologo res\%YourDistroName%\res.rc
:: compile to %YourDistroName%.exe
cl /nologo /O2 /W4 /WX /Ob2 /Oi /Oy /Gs- /GF /Gy /Tc main.c /Fe:%YourDistroName%.exe ^
Advapi32.lib Shell32.lib shlwapi.lib res\%YourDistroName%\res.res
Advapi32.lib Shell32.lib shlwapi.lib wslapi.lib res\%YourDistroName%\res.res
```

### MinGW
Expand All @@ -35,20 +40,20 @@ Install x86_64 version of MSYS2(https://www.msys2.org).
Run these commands in msys shell
```bash
$ pacman -S mingw-w64-x86_64-toolchain # install tool chain
$ gcc -std=c99 --static -lshlwapi main.c -o Launcher.exe # compile main.c
$ gcc -std=c99 --static main.c -lshlwapi -lwslapi -o Launcher.exe # compile main.c
```

Optionally, to add an icon to the exe, create and link a resource with
```bash
YourDistroName=Fedora
$ YourDistroName=Fedora
$ windres res/$YourDistroName/res.rc res.o # compile resource
$ gcc -std=c99 --static -lshlwapi main.c -o ${YourDistroName}.exe res.o # compile main.c
$ gcc -std=c99 --static main.c -lshlwapi -lwslapi -o ${YourDistroName}.exe res.o # compile main.c
```

### Linux (cross compile)
Install mingw-w64 toolchain include gcc-mingw-w64-x86-64.

Run this command in shell
```bash
$ x86_64-w64-mingw32-gcc -std=c99 --static -lshlwapi main.c -o Launcher.exe # compile main.c
$ x86_64-w64-mingw32-gcc -std=c99 --static main.c -lshlwapi -lwslapi -o Launcher.exe # compile main.c
```

0 comments on commit 14760e7

Please sign in to comment.