2009-04-18 16:20:27 +04:00
|
|
|
|
|
|
|
TinyCC
|
|
|
|
======
|
|
|
|
|
|
|
|
This file contains specific information for usage of TinyCC
|
|
|
|
under MS-Windows. See tcc-doc.html to have all the features.
|
|
|
|
|
|
|
|
|
|
|
|
Installation from the binary ZIP package:
|
|
|
|
-----------------------------------------
|
|
|
|
Unzip the package to a directory of your choice.
|
|
|
|
|
|
|
|
|
|
|
|
Set the system PATH:
|
|
|
|
--------------------
|
|
|
|
To be able to invoke the compiler from everywhere on your computer by
|
|
|
|
just typing "tcc", please add the directory containing tcc.exe to your
|
|
|
|
system PATH.
|
|
|
|
|
|
|
|
|
2013-08-29 00:55:05 +04:00
|
|
|
Include and library search paths
|
|
|
|
--------------------------------
|
|
|
|
On windows, the standard "include" and "lib" directories are searched
|
|
|
|
relatively from the location of the executables (tcc.exe, libtcc.dll).
|
|
|
|
|
|
|
|
|
2009-04-18 16:20:27 +04:00
|
|
|
Examples:
|
|
|
|
---------
|
|
|
|
Open a console window (DOS box) and 'cd' to the examples directory.
|
|
|
|
|
|
|
|
For the 'Fibonacci' example type:
|
|
|
|
|
|
|
|
tcc fib.c
|
|
|
|
|
|
|
|
For the 'Hello Windows' GUI example type:
|
|
|
|
|
|
|
|
tcc hello_win.c
|
|
|
|
|
2010-01-14 22:55:34 +03:00
|
|
|
For the 'Hello DLL' example type
|
2009-04-18 16:20:27 +04:00
|
|
|
|
|
|
|
tcc -shared dll.c
|
2017-02-18 11:55:34 +03:00
|
|
|
tcc -impdef dll.dll (optional)
|
2009-04-18 16:20:27 +04:00
|
|
|
tcc hello_dll.c dll.def
|
|
|
|
|
2010-01-14 22:55:34 +03:00
|
|
|
|
2013-02-12 22:13:28 +04:00
|
|
|
Using libtcc as JIT compiler in your program
|
|
|
|
--------------------------------------------
|
|
|
|
Check out the 'libtcc_test' example:
|
|
|
|
|
|
|
|
- Running it from source:
|
|
|
|
tcc -I libtcc libtcc/libtcc.def -run examples/libtcc_test.c
|
|
|
|
|
|
|
|
- Compiling with TCC:
|
|
|
|
tcc examples/libtcc_test.c -I libtcc libtcc/libtcc.def
|
|
|
|
|
|
|
|
- Compiling with MinGW:
|
2016-10-02 02:39:07 +03:00
|
|
|
gcc examples/libtcc_test.c -I libtcc libtcc.dll -o libtcc_test.exe
|
2013-02-12 22:13:28 +04:00
|
|
|
|
|
|
|
- Compiling with MSVC:
|
|
|
|
lib /def:libtcc\libtcc.def /out:libtcc.lib
|
|
|
|
cl /MD examples/libtcc_test.c -I libtcc libtcc.lib
|
2009-04-18 16:20:27 +04:00
|
|
|
|
|
|
|
|
|
|
|
Import Definition Files:
|
|
|
|
------------------------
|
|
|
|
To link with Windows system DLLs, TCC uses import definition
|
|
|
|
files (.def) instead of libraries.
|
|
|
|
|
2017-02-18 11:55:34 +03:00
|
|
|
The now built-in 'tiny_impdef' program may be used to make
|
|
|
|
additional .def files for any DLL. For example
|
2009-04-18 16:20:27 +04:00
|
|
|
|
2017-02-18 11:55:34 +03:00
|
|
|
tcc -impdef [-v] opengl32.dll [-o opengl32.def]
|
2009-04-18 16:20:27 +04:00
|
|
|
|
|
|
|
Put opengl32.def into the tcc/lib directory. Specify -lopengl32 at
|
|
|
|
the TCC commandline to link a program that uses opengl32.dll.
|
|
|
|
|
|
|
|
|
|
|
|
Header Files:
|
|
|
|
-------------
|
|
|
|
The system header files (except _mingw.h) are from the MinGW
|
|
|
|
distribution:
|
|
|
|
|
|
|
|
http://www.mingw.org/
|
|
|
|
|
|
|
|
From the windows headers, only a minimal set is included. If you need
|
2009-11-30 17:23:09 +03:00
|
|
|
more, get MinGW's "w32api" package. Extract the files from "include"
|
|
|
|
into your "tcc/include/winapi" directory.
|
2009-04-18 16:20:27 +04:00
|
|
|
|
|
|
|
|
|
|
|
Resource Files:
|
|
|
|
---------------
|
|
|
|
TCC can link windows resources in coff format as generated by MinGW's
|
|
|
|
windres.exe. For example:
|
|
|
|
|
|
|
|
windres -O coff app.rc -o appres.o
|
|
|
|
tcc app.c appres.o -o app.exe
|
|
|
|
|
|
|
|
|
|
|
|
Tiny Libmaker:
|
|
|
|
--------------
|
2017-02-18 11:55:34 +03:00
|
|
|
The now built-in tiny_libmaker tool by Timovj Lahde can be used as
|
2009-04-18 16:20:27 +04:00
|
|
|
'ar' replacement to make a library from several object files:
|
|
|
|
|
2017-02-18 11:55:34 +03:00
|
|
|
tcc -ar [rcsv] library objectfiles ...
|
2009-04-18 16:20:27 +04:00
|
|
|
|
|
|
|
|
2013-02-08 22:07:11 +04:00
|
|
|
Compilation from source:
|
|
|
|
------------------------
|
|
|
|
* You can use the MinGW and MSYS tools available at
|
|
|
|
http://www.mingw.org
|
various stuff
win32/Makefile ("for cygwin") removed
- On cygwin, the normal ./configure && make can be used with either
cygwin's "GCC for Win32 Toolchain"
./configure --cross-prefix=i686-w64-mingw32-
or with an existing tcc:
./configure --cc=<old-tccdir>/tcc.exe
tcctest.c:
- exclude test_high_clobbers() on _WIN64 (does not work)
tests2/95_bitfield.c:
- use 'signed char' for ARM (where default 'char' is unsigned)
tests:
- remove -I "expr" diff option to allow tests with
busybox-diff.
libtcc.c, tcc.c:
- removed -iwithprefix option. It is supposed to be
combined with -iprefix which we don't have either.
tccgen.c:
- fix assignments and return of 'void', as in
void f() {
void *p, *q;
*p = *q:
return *p;
}
This appears to be allowed but should do nothing.
tcc.h, libtcc.c, tccpp.c:
- Revert "Introduce VIP sysinclude paths which are always searched first"
This reverts commit 1d5e386b0a78393ac6b670c209a185849ec798a1.
The patch was giving tcc's system includes priority over -I which
is not how it should be.
tccelf.c:
- add DT_TEXTREL tag only if text relocations are actually
used (which is likely not the case on x86_64)
- prepare_dynamic_rel(): avoid relocation of unresolved
(weak) symbols
tccrun.c:
- for HAVE_SELINUX, use two mappings to the same (real) file.
(it was so once except the RX mapping wasn't used at all).
tccpe.c:
- fix relocation constant used for x86_64 (by Andrei E. Warentin)
- #ifndef _WIN32 do "chmod 755 ..." to get runnable exes on cygwin.
tccasm.c:
- keep forward asm labels static, otherwise they will endup
in dynsym eventually.
configure, Makefile:
- mingw32: respect ./configure options --bindir --docdir --libdir
- allow overriding tcc when building libtcc1.a and libtcc.def with
make XTCC=<tcc program to use>
- use $(wildcard ...) for install to allow installing just
a cross compiler for example
make cross-arm
make install
- use name <target>-libtcc1.a
build-tcc.bat:
- add options: -clean, -b bindir
2017-10-11 19:13:43 +03:00
|
|
|
http://www.mingw-w64.org
|
|
|
|
http://www.msys2.org
|
2013-02-08 22:07:11 +04:00
|
|
|
|
2013-02-12 22:13:28 +04:00
|
|
|
Untar the TCC archive and type in the MSYS shell:
|
|
|
|
./configure [--prefix installpath]
|
|
|
|
make
|
|
|
|
make install
|
2013-02-08 22:07:11 +04:00
|
|
|
|
2017-02-13 21:03:29 +03:00
|
|
|
The default install location is c:\Program Files\tcc
|
2013-02-08 22:07:11 +04:00
|
|
|
|
various stuff
win32/Makefile ("for cygwin") removed
- On cygwin, the normal ./configure && make can be used with either
cygwin's "GCC for Win32 Toolchain"
./configure --cross-prefix=i686-w64-mingw32-
or with an existing tcc:
./configure --cc=<old-tccdir>/tcc.exe
tcctest.c:
- exclude test_high_clobbers() on _WIN64 (does not work)
tests2/95_bitfield.c:
- use 'signed char' for ARM (where default 'char' is unsigned)
tests:
- remove -I "expr" diff option to allow tests with
busybox-diff.
libtcc.c, tcc.c:
- removed -iwithprefix option. It is supposed to be
combined with -iprefix which we don't have either.
tccgen.c:
- fix assignments and return of 'void', as in
void f() {
void *p, *q;
*p = *q:
return *p;
}
This appears to be allowed but should do nothing.
tcc.h, libtcc.c, tccpp.c:
- Revert "Introduce VIP sysinclude paths which are always searched first"
This reverts commit 1d5e386b0a78393ac6b670c209a185849ec798a1.
The patch was giving tcc's system includes priority over -I which
is not how it should be.
tccelf.c:
- add DT_TEXTREL tag only if text relocations are actually
used (which is likely not the case on x86_64)
- prepare_dynamic_rel(): avoid relocation of unresolved
(weak) symbols
tccrun.c:
- for HAVE_SELINUX, use two mappings to the same (real) file.
(it was so once except the RX mapping wasn't used at all).
tccpe.c:
- fix relocation constant used for x86_64 (by Andrei E. Warentin)
- #ifndef _WIN32 do "chmod 755 ..." to get runnable exes on cygwin.
tccasm.c:
- keep forward asm labels static, otherwise they will endup
in dynsym eventually.
configure, Makefile:
- mingw32: respect ./configure options --bindir --docdir --libdir
- allow overriding tcc when building libtcc1.a and libtcc.def with
make XTCC=<tcc program to use>
- use $(wildcard ...) for install to allow installing just
a cross compiler for example
make cross-arm
make install
- use name <target>-libtcc1.a
build-tcc.bat:
- add options: -clean, -b bindir
2017-10-11 19:13:43 +03:00
|
|
|
Cygwin can be used too with its mingw cross-compiler installed:
|
|
|
|
./configure --cross-prefix=i686-w64-mingw32-
|
|
|
|
(the prefix may vary)
|
|
|
|
|
2013-02-08 22:07:11 +04:00
|
|
|
* Alternatively you can compile TCC with just GCC from MinGW using
|
2017-02-13 21:03:29 +03:00
|
|
|
> build-tcc.bat (from the win32 directory)
|
|
|
|
|
|
|
|
Also MSVC can be used with the "VSTools Developer Command Prompt":
|
|
|
|
> build-tcc.bat -c cl
|
2013-02-08 22:07:11 +04:00
|
|
|
|
various stuff
win32/Makefile ("for cygwin") removed
- On cygwin, the normal ./configure && make can be used with either
cygwin's "GCC for Win32 Toolchain"
./configure --cross-prefix=i686-w64-mingw32-
or with an existing tcc:
./configure --cc=<old-tccdir>/tcc.exe
tcctest.c:
- exclude test_high_clobbers() on _WIN64 (does not work)
tests2/95_bitfield.c:
- use 'signed char' for ARM (where default 'char' is unsigned)
tests:
- remove -I "expr" diff option to allow tests with
busybox-diff.
libtcc.c, tcc.c:
- removed -iwithprefix option. It is supposed to be
combined with -iprefix which we don't have either.
tccgen.c:
- fix assignments and return of 'void', as in
void f() {
void *p, *q;
*p = *q:
return *p;
}
This appears to be allowed but should do nothing.
tcc.h, libtcc.c, tccpp.c:
- Revert "Introduce VIP sysinclude paths which are always searched first"
This reverts commit 1d5e386b0a78393ac6b670c209a185849ec798a1.
The patch was giving tcc's system includes priority over -I which
is not how it should be.
tccelf.c:
- add DT_TEXTREL tag only if text relocations are actually
used (which is likely not the case on x86_64)
- prepare_dynamic_rel(): avoid relocation of unresolved
(weak) symbols
tccrun.c:
- for HAVE_SELINUX, use two mappings to the same (real) file.
(it was so once except the RX mapping wasn't used at all).
tccpe.c:
- fix relocation constant used for x86_64 (by Andrei E. Warentin)
- #ifndef _WIN32 do "chmod 755 ..." to get runnable exes on cygwin.
tccasm.c:
- keep forward asm labels static, otherwise they will endup
in dynsym eventually.
configure, Makefile:
- mingw32: respect ./configure options --bindir --docdir --libdir
- allow overriding tcc when building libtcc1.a and libtcc.def with
make XTCC=<tcc program to use>
- use $(wildcard ...) for install to allow installing just
a cross compiler for example
make cross-arm
make install
- use name <target>-libtcc1.a
build-tcc.bat:
- add options: -clean, -b bindir
2017-10-11 19:13:43 +03:00
|
|
|
or with an existing tcc (needs to be in a different directory)
|
2017-02-13 21:03:29 +03:00
|
|
|
> build-tcc.bat -c some-tcc-dir\tcc.exe
|
2013-02-08 22:07:11 +04:00
|
|
|
|
2017-02-13 21:03:29 +03:00
|
|
|
Also you can copy/install everything into another directory:
|
|
|
|
> build-tcc.bat -i <dir>
|
2013-02-08 22:07:11 +04:00
|
|
|
|
2009-04-18 16:20:27 +04:00
|
|
|
Limitations:
|
|
|
|
------------
|
|
|
|
- On the object file level, currently TCC supports only the ELF format,
|
|
|
|
not COFF as used by MinGW and MSVC. It is not possible to exchange
|
2017-02-18 11:55:34 +03:00
|
|
|
object files or libraries between TCC and these compilers.
|
2009-04-18 16:20:27 +04:00
|
|
|
|
2017-02-18 11:55:34 +03:00
|
|
|
However libraries for TCC from objects by TCC can be made using
|
|
|
|
tcc -ar lib.a files.o ,,,
|
2009-04-18 16:20:27 +04:00
|
|
|
|
2017-02-18 11:55:34 +03:00
|
|
|
- No leading underscore is generated in the ELF symbols.
|
2009-04-18 16:20:27 +04:00
|
|
|
|
|
|
|
Documentation and License:
|
|
|
|
--------------------------
|
|
|
|
TCC is distributed under the GNU Lesser General Public License. (See
|
|
|
|
COPYING file or http://www.gnu.org/licenses/lgpl-2.1.html)
|
|
|
|
|
|
|
|
TinyCC homepage is at:
|
|
|
|
|
|
|
|
http://fabrice.bellard.free.fr/tcc/
|
|
|
|
|
|
|
|
|
|
|
|
WinAPI Help and 3rd-party tools:
|
|
|
|
--------------------------------
|
|
|
|
The Windows API documentation (Win95) in a single .hlp file is
|
|
|
|
available on the lcc-win32 site as "win32hlp.exe" or from other
|
|
|
|
locations as "win32hlp_big.zip".
|
|
|
|
|
|
|
|
A nice RAD tool to create windows resources (dialog boxes etc.) is
|
|
|
|
"ResEd", available at the RadASM website.
|
|
|
|
|
|
|
|
|
|
|
|
--- grischka
|