If you use mingw in Windows to compile the current tinycc, an error is returned when embedding the C script:
TCC: File '/C/program files/TCC/libtcc1.a' not found
Doug Currie provides a patch in the TCC email list:
Here is what I did (and reported to the mailing list) last February,
So the patch may not be accurate for more recent versions, but
Issues are the same...
I have been able to create a libtcc. DLL for WINXP using mingw/msys;
The changes that were necessary were very minor. Perhaps this
Description will help others use libtcc on Windows.
First, a small bug to report:
In TCC. c The function tcc_basename () follows the line:
# If! Defined (libtcc)
But the function tcc_basename () is used in pe_build_exports () in
Tccpe. c -- moving the # If line below the function tcc_basename ()
Eliminates a link error building libtcc. dll in PE target mode.
Second, inserting ing and making TCC with msys places a pathname in
Config. h In msys format. For example, I passed the argument
-- Prefix =/C/dev/TCC
To configure; this path was good for building tcc.exe and didn't
Contain any spaces, unlike the default path. This creates the line
# Define config_tccdir "/C/dev/TCC"
In config. H. Manually changing this line
# Define config_tccdir "C:/dev/TCC"
Enables libtcc. DLL to find the include files and libraries once
Library is built. [the application tcc.exe avoids this problem
Setting tcc_lib_path from the application's directory at startup.
Similar solution cocould be used for the library using dllmain.]
So, after configure, fix config_tccdir in config. h and make.
Finally, the library libtcc. dll can be built with the msys command:
Gcc-O2-shared-wall-wl, -- export-all-symbols/
-Mpreferred-Stack-boundary = 2/
-March = i386-falign-functions = 0-fno-strict-aliasing/
-Dtcc_target_pe-dlibtcc-O libtcc. dll TCC. c
Below is a diff of tcc-0.9.23 TCC. C and the changes for libtcc
Tcc_target_pe and DLL location of library files.
Regards,
E
$ Diff-u ../tcc-0.9.23-o/TCC. c TCC. c
--- ../Tcc-0.9.23-o/TCC. c Fri Jun 17 18:09:15 2005
++ TCC. c Tue Feb 28 17:03:44 2006
@-10157,8 + 10157,6 @@
Flag_name, value );
}
-# If! Defined (libtcc)
-
/* Extract the basename of a file */
Static const char * tcc_basename (const char * name)
{
@-10175, 6 + 10173,35 @@
Return P;
}
+ # If defined (libtcc)
+
+ # Ifdef Win32
+ Int _ stdcall dllmain (void * hinstdll, unsigned long fdwreason, void *
Lpvreserved)
+ {
+ If (fdwreason = 1/* dll_process_attach */)
+ {
+/* On Win32, as implemented in main ()
+ We suppose the lib and provided des are at the location of this library
+ */
+ Static char path [1024];
+ Char * P, * D;
+
+ Getmodulefilenamea (hinstdll, path, sizeof path );
+ P = d = strlwr (PATH );
+ While (* D)
+ {
+ If (* D = '//') * D = '/', P = D;
++ D;
+}
+ * P = '/0 ';
+ Tcc_lib_path = path;
+}
+ Return 1/* true */;
+}
+ # Endif
+
+ # Else /*! Libtcc */
Static int64_t getclock_us (void)
{
# Ifdef Win32