Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

How to Compile Winim by Tiny C Compiler

To compile Winim by TCC, of course you need to download the TCC.

You will need the following files:

I suggest put these files into nim\dist, and then modify the nim.cfg. Here is the example:

@if windows:
  @if i386:
    gcc.path = r"$nim\dist\mingw32\bin"
    tcc.path = r"$nim\dist\tcc32"
    gcc.path = r"$nim\dist\mingw64\bin"
    tcc.path = r"$nim\dist\tcc64"

Now, you can try to compile Winim program by TCC:

nim c --cc:tcc --cpu:i386 example.nim


nim c --cc:tcc --cpu:amd64 example.nim

If you enconter an error message about "ftelli64", replace the file libtcc1-64.a and then try again.

How to Add the Resource Files

Winim module links winim32.res or winim64.res by default to force Windows system using ComCtl32.dll version 6, aka enabling the Visual Styles (Since Winim 3.0, you can add -d:noRes to disable it).

Tiny C Compiler supports COFF format res file. However, the problem is it supports only one res file. So, if you add another resource file in your code, for example: {.link "myapp.res".}, the program will fail to execute because it miss the winim32.res or winim64.res. This problem won't happen in gcc or vcc because they both support multiple res files.

How the resolve it? You need to enable the visual style by your self. Here are the steps to do.

  1. Prepare the manifest file. For example:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<description>Your application description here.</description>
  1. Prepare the rc file. For example:
1 24 "myapp.manifest"
1000 ICON "myapp.ico"
  1. Compile the rc file by windres (the tool should be in the gcc path).
windres -O coff myapp.rc -o myapp.res
  1. Request TCC to link this file by add following line in nim code:
{.link "myapp.res".}

That's all. More informations:


Copyright (c) 2016-2019 Kai-Hung Chen, Ward. All rights reserved.

You can’t perform that action at this time.