tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] using tcc as a cross compiler for Windows


From: Luigi Rizzo
Subject: Re: [Tinycc-devel] using tcc as a cross compiler for Windows
Date: Tue, 16 Feb 2010 16:13:57 +0100
User-agent: Mutt/1.4.2.3i

On Tue, Feb 16, 2010 at 03:39:21PM +0100, grischka wrote:
> Luigi Rizzo wrote:
> >not sure how useful this is but it seems relatively simple to
> >use tcc as a cross compiler for Windows, by doing (tried on FreeBSD):
> 
> That is because everything you need to compile windows programs is
> contained in the tcc source.  It is less simple with the other targets
> because they mostly rely on headers and libraries of the target system.
> 
> >
> >     gmake CONFIG_WIN32=1 _WIN32=1 tcc
> >     cp tcc tcc.exe
> >     gmake CONFIG_WIN32=1 _WIN32=1 libtcc1.a
> 
> _WIN32=1 has no effect, has it?

you are right, it was part of my attempt to build tiny_impdef.
_WIN32 is not needed.

> >
> >Building tiny_impdef is slightly harder but apparently the compiler
> >is happy enough with a copy of msvcrt.dll and kernel32.dll
> 
> windows system dlls are not necessary for compilation.

they seem definitely necessary for linking though, see below:

> >Putting tcc, libtcc1.a and the *dll in the same directory you can do
> >
> >     ./tcc -I win32/include -L .  myprog.c
> 
> That should be
>       ./tcc -B win32 myprog.c

Taking a random c program, . is the directory with tcc sources
compiled as above, and libtcc1.a :

        > ./tcc -Bwin32 -L . ~/c-src/card.c 
        In file included from /home/luigi/c-src/card.c:44:
        In file included from win32/include/stdio.h:9:
        win32/include/_mingw.h:21: error: include file 'stddef.h' not found

put more include paths:

        > ./tcc -Iwin32 -Iwin32/include  ~/c-src/card.c 
        tcc: error: cannot find library: tcc1
        tcc: error: cannot find library: msvcrt
        tcc: error: cannot find library: kernel32
        tcc: error: _start not defined

now tell tcc where libtcc1.a is

        > ./tcc -Iwin32 -Iwin32/include ~/c-src/card.c -L .
        tcc: error: cannot find library: msvcrt
        tcc: error: cannot find library: kernel32
        tcc: error: undefined symbol 'sscanf'
        tcc: error: undefined symbol 'strlen'
        tcc: error: undefined symbol 'printf'
        tcc: error: undefined symbol 'open'
        tcc: error: undefined symbol '_imp___iob'
        tcc: error: undefined symbol 'fprintf'
        tcc: error: undefined symbol 'exit'
        tcc: error: undefined symbol '_controlfp'
        tcc: error: undefined symbol '__set_app_type'
        tcc: error: undefined symbol '__getmainargs'

and finally, add -L with a path where the mscvrt.dll and kernel32.dll

        > ./tcc -Iwin32 -Iwin32/include ~/c-src/card.c -L . -L ../win-bin/

this works fine

        cheers
        luigi




reply via email to

[Prev in Thread] Current Thread [Next in Thread]