tinycc-devel
[Top][All Lists]
Advanced

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

Re: [Tinycc-devel] Is static linking functional?


From: lifenjoiner
Subject: Re: [Tinycc-devel] Is static linking functional?
Date: Tue, 24 Jun 2014 19:33:24 +0800

Hi Wendell P,

The original problem here is not the same as you previous supposed to, and 
would not be solved in that way. You need to explore why it can't find the 
library. It doesn't mean the lib has a wrong format.


> Wendell P
> Sent: Tuesday, June 24, 2014 3:08 AM
> 
> On Sun, Jun 22, 2014, at 11:40 AM, grischka wrote:
> > Why should we comment about the usability of -static if you
> > don't even know that it means?
> 
> I'll admit I'm confused by the operation of the "-static" switch in TCC.
> 
>     tcc app.c lib.a
> 
> outputs an "app.exe" but
> 
>     tcc -static app.c lib.a
> 
> gives an error
> 
>     tcc: error: cannot find library: msvcrt
> 
> 
> From looking at these lines in tccpe.c, it seems that should not happen.
> --------------------------
>     if (0 == s1->nostdlib) {
>         static const char *libs[] = {
>             "libtcc1.a", "msvcrt", "kernel32", "", "user32", "gdi32",
>             NULL
>         };
>         const char **pp, *p;
>         for (pp = libs; 0 != (p = *pp); ++pp) {
>             if (0 == *p) {
>                 if (PE_DLL != pe_type && PE_GUI != pe_type)
>                     break;

>             } else if (pp == libs ? tcc_add_dll(s1, p, 0) :
>             tcc_add_library(s1, p)) {
<---------------here-------------------------------------------------

>                 tcc_error_noabort("cannot find library: %s", p);
>                 break;
>             }
>         }
>     }
> --------------------------

tcc_add_library() will be run. 

---------
LIBTCCAPI int tcc_add_library(TCCState *s, const char *libraryname)
{
#ifdef TCC_TARGET_PE
    const char *libs[] = { "%s/%s.def", "%s/lib%s.def", "%s/%s.dll", 
"%s/lib%s.dll", "%s/lib%s.a", "%s/%s.c", NULL };
    const char **pp = s->static_link ? libs + 4 : libs;
    const char *filename;
#else
    const char *libs[] = { "%s/lib%s.so", "%s/lib%s.a", NULL };
    const char **pp = s->static_link ? libs + 1 : libs;
#endif
......
}
---------

And, specified by switch "-static":

---------
PUB_FUNC int tcc_parse_args(TCCState *s, int argc, char **argv)
{
......
        case TCC_OPTION_static:
            s->static_link = 1;
......
}
---------

Now you see? I think this is grischka meant.







reply via email to

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