[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Tinycc-devel] Sugggestion: Add lib type *.c for tcc_add_library() o
From: |
lifenjoiner |
Subject: |
Re: [Tinycc-devel] Sugggestion: Add lib type *.c for tcc_add_library() on windows ('-l' option parse) |
Date: |
Thu, 19 Jun 2014 16:07:10 +0800 |
Hi grischka,
What about document in 'tcc-win32.txt' by adding a libraries section as bellow.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Import Definition Files:
------------------------
To link with Windows system DLLs, TCC uses import definition
files (.def) instead of libraries.
The included 'tiny_impdef' program may be used to make additional
.def files for any DLL. For example:
tiny_impdef.exe opengl32.dll
Put opengl32.def into the tcc/lib directory. Specify -lopengl32 at
the TCC commandline to link a program that uses opengl32.dll.
Libraries:
----------
TCC supports ELF object files and COFF resource files.
MinGW gcc produces COFF object files, which tcc doesn't understand.
And library (.a) files need compiled and made in this format.
*
c file also can be library by runtime compiling for linking.
"-l" option searching priority is:
name.def > libname.def > name.dll > libname.dll > name.c
In the same dir, if a same name def file found and dll file not found,
c file will be searched and added if found.
Header Files:
-------------
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> grischka wrote:
> address@hidden wrote:
>
> > "w32api" is really useful, but NOT convenient for TCC to build the libs.
>
> Try to write the documentation for the behavior of the patch below
> and then we can ask people what is more convenient:
> - to read and understand that documentation or
> - to type one more filename on the tcc command-line
>
> -- gr
>
> > ---------------- whole tcc_add_library() ----------------------
> > /* the library name is the same as the argument of the '-l' option */
> > 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
> > while (*pp) {
> > if (0 == tcc_add_library_internal(s, *pp,
> > /*+*/ libraryname, 0, s->library_paths, s->nb_library_paths)) {
> > /*+*/#ifdef TCC_TARGET_PE
> > /*+*/ /* extra search for c file together with def file if there
> is no dll */
> > /*+*/ if (pp < libs + 2) {
> > /*+*/ filename =
> tcc_strdup(s->target_deps[s->nb_target_deps - 1]);
> > /*+*/ strcpy(tcc_fileextension(filename), ".dll");
> > /*+*/ if (tcc_open(s, filename) < 0) {
> > /*+*/ strcpy(tcc_fileextension(filename), ".c");
> > /*+*/ tcc_add_file_internal(s, filename, 0);
> > /*+*/ } else
> > /*+*/ tcc_close();
> > /*+*/ }
> > /*+*/#endif
> > return 0;
> > /*+*/ }
> > ++pp;
> > }
> > return -1;
> > }
> > ---------------- replace all "/*+*/" to "" ------------------