Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Developing U++ » UppHub » New Tiny C Compiler Package
New Tiny C Compiler Package [message #22201] Wed, 24 June 2009 08:21 Go to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Hello all

New Tcc package is available in Bazaar svn.

This package lets Upp users to use C as a scripting language.

It is also included a Tcc Demo Gui package to test it. Here I inclose a screenshot:

index.php?t=getfile&id=1813&private=0

It has been tested in Linux (Gcc) and Windows (MinGW and Msc).

Documentation is included with introduction, methods reference, a documented sample and implementation details.

Best regards
Koldo


Best regards
Iñaki
Re: New Tiny C Compiler Package [message #22244 is a reply to message #22201] Fri, 26 June 2009 19:09 Go to previous messageGo to next message
Mindtraveller is currently offline  Mindtraveller
Messages: 917
Registered: August 2007
Location: Russia, Moscow rgn.
Experienced Contributor

Could you please tell if there is simple way to call "embedded" binary's functions from this c-style script? Is it what you mean by "external" function in the example above?

[Updated on: Fri, 26 June 2009 19:10]

Report message to a moderator

Re: New Tiny C Compiler Package [message #22262 is a reply to message #22244] Sun, 28 June 2009 16:28 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Hello Pavel

From the scripting file you just have to declare and call the function in simple C.

For example lets consider function plus() that is defined in the main program.

In the scripting program it would be:

double plus(double a, double b);	// External function has to be declared

...

	for (i = 0; i < 10000000; ++i)
		ret += 0.000000001*pow2(sqrt(plus(a, 10))); // plus() is called here

...


And in the main program it would be:

// Function to be called from the scripting program is defined here
double plus(double a, double b)
{
    return a + b;
} 

...
	    tcc.AddSymbol("plus", (void *)&plus); // And here we link the library function to the scripting program
...


Best regards
Koldo


Best regards
Iñaki
Re: New Tiny C Compiler Package [message #22322 is a reply to message #22262] Fri, 03 July 2009 16:50 Go to previous messageGo to next message
ptDev is currently offline  ptDev
Messages: 25
Registered: June 2009
Promising Member
I tried the Tcc Gui Demo (didn't even change the source code) and the "Compile and Run" button didn't respond.

I just built the Tcc package before trying the demo, What else do I need to do? Am I doing anything wrong?

[Updated on: Fri, 03 July 2009 16:50]

Report message to a moderator

Re: New Tiny C Compiler Package [message #22323 is a reply to message #22322] Fri, 03 July 2009 18:02 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Hello ptDev

Copy the file libtcc.dll to "C:\WINDOWS\System" or change in main.cpp

Tcc tcc;

for

Tcc tcc("libtcc.dll location with full path");

It was my fault: I did not documented that clearly and I left Tcc tcc; outside the try {} block in main.cpp so that the exception caused for not finding the libtcc.dll was not catched.

Best regards
Koldo


Best regards
Iñaki
Re: New Tiny C Compiler Package [message #22332 is a reply to message #22323] Sat, 04 July 2009 08:58 Go to previous messageGo to next message
ptDev is currently offline  ptDev
Messages: 25
Registered: June 2009
Promising Member
Hi,

I tried again, with libtcc compiled from source with MinGW. Despite building a DLL from there and copying this DLL to the windows path, it still wouldn't work. (It's not recognized as a valid win32 DLL).

How can I make this work with MinGW?
Re: New Tiny C Compiler Package [message #22333 is a reply to message #22332] Sat, 04 July 2009 11:06 Go to previous messageGo to next message
Didier is currently offline  Didier
Messages: 680
Registered: November 2008
Location: France
Contributor
Hi,

'Tcc Gui Demo' works fine in linux Smile
except for one small thing ...The project name: 'Tcc Gui Demo' contains spaces and Upp tries to launch 'Tcc' instead of 'Tcc Gui Demo' which of course does not existe.

This may work on windows but i think avoiding spaces in names is a good precaution

This Tcc wrapper will become very handy, thanks.

Didier


Re: New Tiny C Compiler Package [message #22415 is a reply to message #22333] Mon, 13 July 2009 09:25 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Hello Didier

Thank you for your feedback.

I am surprised as I have put in Bazaar more packages with spaces like:
- OfficeAutomation demo console
- PainterSvg demo
- SysInfo demo console

Perhaps simply nobody has used them in Linux Smile
I use Ubuntu without problems.

If nobody answer I will change all package names to avoid spaces.

Best regards
Koldo


Best regards
Iñaki
Re: New Tiny C Compiler Package [message #22416 is a reply to message #22415] Mon, 13 July 2009 10:06 Go to previous messageGo to next message
Didier is currently offline  Didier
Messages: 680
Registered: November 2008
Location: France
Contributor
Hello Koldo,

I confirm, 'PaiterSvg Demo' & 'SysInfo demo console' have the same problem.
I never tried them before. Rolling Eyes

As for 'OfficeAutomation demo console': it doesn't compile on linux

Re: New Tiny C Compiler Package [message #22417 is a reply to message #22416] Mon, 13 July 2009 10:44 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Didier wrote on Mon, 13 July 2009 10:06

Hello Koldo,

I confirm, 'PaiterSvg Demo' & 'SysInfo demo console' have the same problem.
I never tried them before. Rolling Eyes

As for 'OfficeAutomation demo console': it doesn't compile on linux




Ok Didier

I will change package names aujourd'hui.

Best regards
Koldo


Best regards
Iñaki
Re: New Tiny C Compiler Package [message #22446 is a reply to message #22332] Wed, 15 July 2009 23:28 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
ptDev wrote on Sat, 04 July 2009 08:58

Hi,

I tried again, with libtcc compiled from source with MinGW. Despite building a DLL from there and copying this DLL to the windows path, it still wouldn't work. (It's not recognized as a valid win32 DLL).

How can I make this work with MinGW?


Hello ptDev

The fastest way for you is just copying the libtcc.dll file in \bazaar\Tcc into \windows\system or indicate the libtcc.dll location in the Tcc constructor, so instead of doing:

Tcc tcc;

you would do:

Tcc tcc("c:\\myFolder\\libtcc.dll");

If you prefer to compile it by yourself please give the compiling details to see what happen.

Best regards
Koldo


Best regards
Iñaki
Re: New Tiny C Compiler Package [message #22721 is a reply to message #22446] Sat, 08 August 2009 17:28 Go to previous messageGo to next message
kasome is currently offline  kasome
Messages: 78
Registered: July 2008
Location: Taiwan
Member
The Tiny C Compiler Package is nice....

Could I save the compiled result as an executable file ?

for example,
String program = tcc.GetProgram();
StoreToFile( program, "program.exe" );
Re: New Tiny C Compiler Package [message #22729 is a reply to message #22721] Sun, 09 August 2009 17:30 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
kasome wrote on Sat, 08 August 2009 17:28

The Tiny C Compiler Package is nice....

Could I save the compiled result as an executable file ?

for example,
String program = tcc.GetProgram();
StoreToFile( program, "program.exe" );


Hello Kasome

Yes, no problem.
Let me some days to add it.

Best regards
Koldo


Best regards
Iñaki
Re: New Tiny C Compiler Package [message #22769 is a reply to message #22201] Wed, 12 August 2009 23:46 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Hello Kasome

It is ready, tested in WinXP and Ubuntu, documented and submitted to Bazaar.

The demo program has been adapted to include this option.

It can output native executable files in Linux and Windows, I mean, when compiling the main program under Linux the executable optained will be Linux native (ELF format), and when compiling it in Windows the executable will be Windows native (PE-COFF format).

This way the output program can be simply called and run for example from a terminal.

The main visible changes are in:

void SetOutputExe();
void SetOutputMemory();
	
void Link(const char *fileName = 0);


This fileName is the executable file.

Please read the instructions before using it.

Best regards
Koldo


Best regards
Iñaki
Re: New Tiny C Compiler Package [message #22771 is a reply to message #22201] Thu, 13 August 2009 08:34 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Hello

Two additional things:

- In Linux
To get the executable file you will need to install tcc in the system. It is just from a terminal in Tcc/lib folder running make & make install

- In Windows
Supplied .dll has been updated, so to get the .exe files you would have to use it
If you want to recompile it by yourself it is easier than before. Now you do not need MSYS. With MinGW in the PATH it is enough using the GetDLL.bat file.
The .dll is bigger than before. Just becuase it is compiled now using -O3 with MinGW 4.4.0.

- Now error messages are in different languages, so if you want them in yours please send me the translations

Best regards
Koldo


Best regards
Iñaki
Re: New Tiny C Compiler Package [message #22781 is a reply to message #22771] Fri, 14 August 2009 14:34 Go to previous messageGo to next message
kasome is currently offline  kasome
Messages: 78
Registered: July 2008
Location: Taiwan
Member
Sorry for the delay replying.

Wow!Razz It's perfect. Thanks, koldo.
Re: New Tiny C Compiler Package [message #26433 is a reply to message #22781] Sat, 01 May 2010 12:59 Go to previous messageGo to next message
Didier is currently offline  Didier
Messages: 680
Registered: November 2008
Location: France
Contributor
Hi Koldo,

I've been using Tcc package lately and you introduced a linux regression in SVN 1500 ( 8 month ago Wink ):

In Tcc/libtcc.c you changed:
#ifdef __unix__
#include "lib/Tcc.c"
#endif


Instead of:
#ifdef __unix__
#include "lib/tcc.c"
#endif


Since unix like systems are case aware, and that the filename is "tcc.c" ==> this doesn't compile any more.


I also have a very small correction for you:
In Tcc/Tcc.cpp L201:

instead of:
	unsigned long val;

Put:
	unsigned long val = 0;


This will allow testing if the symbol was found or not.


QUESTION:

Is there a reason for having a separated makefile for the Tcc lib. What I'm thinking about is allowing STATIC linking of this lib just like any other Upp package ?
This would keep from having to install the tcc lib before using the Tcc package

[Updated on: Sat, 01 May 2010 13:40]

Report message to a moderator

Re: New Tiny C Compiler Package [message #26444 is a reply to message #26433] Sun, 02 May 2010 19:53 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Hello Didier

Thank you for your comments. They are now added. For any reason I did not know the x11 emulator I use does not care about file name case.

About the question, I did not understand it well. However I have activated not to include stdlib lib so that now it is not necessary to have tcc package installed. However please test it in your environment if it is ok.

Please any other tcc users confirm me if this change affects you.


Best regards
Iñaki
icon14.gif  Re: New Tiny C Compiler Package [message #26445 is a reply to message #26444] Sun, 02 May 2010 23:15 Go to previous messageGo to next message
Didier is currently offline  Didier
Messages: 680
Registered: November 2008
Location: France
Contributor
Hi Koldo,

Thanks for the quick reply. I gonna try you're modifications right away....


OK, works Fine Cool

All compiles OK and the TCC lib isn't needed any more Thumbs Up , I can now use my small app on several computers !

Thanks
Re: New Tiny C Compiler Package [message #26446 is a reply to message #26445] Mon, 03 May 2010 08:22 Go to previous messageGo to previous message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Excellent Didier Smile

Anyway I will investigate why stdlib is included in a separate .a lib instead of being statically compiled with rest of tcc.


Best regards
Iñaki
Previous Topic: Scatter: To find width bwt any two points.
Next Topic: User configurable menu system
Goto Forum:
  


Current Time: Thu Mar 28 15:33:35 CET 2024

Total time taken to generate the page: 0.01613 seconds