Tiny Core Linux

Tiny Core Extensions => TCE Talk => Topic started by: Pats on January 01, 2010, 07:49:44 AM

Title: Creating TCL extention in simple steps !
Post by: Pats on January 01, 2010, 07:49:44 AM
I develop app in Win platform. I want to convert one of the accounting app  - say xyz.cpp from Win2k ( written in C++)  into TCL ext - which I should be able to use in TCLs - say v2.4 or may be v2.6.
So how to go abt it ?
Suppose for example, how to convert a simple app -Hello World - written in Win C++ ti TCL ext which when loaded and run thru TCLs terminal will output - Hello World -  !
So being a layman in Linux and TCL development,but pl show me the path to the message thread already answered here or better still explain here in a step-by-step Tutorial format - if possible !
Thanks !
~ Pats

Title: Re: Creating TCL extention in simple steps !
Post by: curaga on January 01, 2010, 08:33:49 AM
Do you wish to use wine or do a true linux port?

Either way, we have good instructions in the wiki for the extension part: http://tinycorelinux.com/wiki/tiki-index.php?page=Creating+Extensions

To this case mainly part 3, creating a tcz, would apply. It assumes your directory hierarchy is in /tmp/package.
Title: Re: Creating TCL extention in simple steps !
Post by: Pats on January 01, 2010, 08:45:16 AM
Since I have taken a plunge in Linux waters recently , I want a pure Linux only app ext on Linux platform - no WINE !
Off-cource I can compile and run small .c or .cpp programs in Linux, but that is all, not much exposure to nitty-gytties of Linux development. :)
Anyhow I will go thru the link you have given and revert back here in case of difficulties - which I vary much is expecting ! :)
~ Pats
Title: Re: Creating TCL extention in simple steps !
Post by: curaga on January 01, 2010, 09:22:40 AM
Porting an app from win to lin is a very complex topic. You're likely to find more info on that via google.

In short, if you only used ANSI/whatever the standard for C++ is, and no windows-only apis, it just might compile from the start on linux. The only things to add would be ifdef'ed sections for used paths, for example.

But, it's never that easy in practise :P


This book (Advanced Linux Programming) is available online for free:
http://www.advancedlinuxprogramming.com/
Title: Re: Creating TCL extention in simple steps !
Post by: Pats on January 01, 2010, 11:57:57 AM
Quote
Either way, we have good instructions in the wiki for the extension part: http://tinycorelinux.com/wiki/tiki-index.php?page=Creating+Extensions
Thanks !
Quite complicated process for a new entrant to linux like me !
But I have to go thru that all, I think - it would have been a great help for newbees if the link above would have a simple practical step-by-step example ( like Hello World ) to build a TCL sample .tce or .tcz  !

Any-how, I sounds a little lazy to be spoon-feed, I think !  ;)

Quote
This book (Advanced Linux Programming) is available online for free:
Yah , this seems to be a good link. Wil go thru this book after the download !
Quote
But, it's never that easy in practise
Correct, sometime back, I had developed a Automated Q/A  bank app for a nearby school management in Linux. So that little experience may help me to understand Linux Programming,I hope !
Anyhow , thanks for the guidance and your lots of patience to un-tiredly explain ( in a down-to-earth fashion ) to so many newbees like me !

~ Pats
Title: Re: Creating TCL extention in simple steps !
Post by: bmarkus on January 01, 2010, 12:07:33 PM
If you want to create applications I propose Python. Easy to learn, it has nice syntax and great data structures additionaly to the huge number of modules (functions) so you do not have to deal with lower levels. With Python you can make your first applications in a short time and learn while developing. It offers short development cycle and success.

Python applications run on other platforms too. On WINDOWS you can comple it to .EXE etc.

If you havn't done yet, try it.


http://python.org/
Title: Re: Creating TCL extention in simple steps !
Post by: Pats on January 01, 2010, 12:35:37 PM
Quote
Python applications run on other platforms too. On WINDOWS you can comple it to .EXE etc.
Thanks ! I had tried my hand in Python long back . Though it is easy, but I am used to C , C++, VC++ world after graduating from BASIC , COBOL etc.
And C is something which nobody can forget even in sleep ! :)

Most of my apps are in C++ and VC++, so programming C is not a problem for me, but kindly help me to get accustomed to port my little-bit C know-how to Linux platform.
Pl do not get bored with my silly Qs abt Linux. Who knows one day I may be able to develop a workable  extention for TCL, I hope . :)
( I have already started some Linux Programming in C )

~Pats

Title: Re: Creating TCL extention in simple steps !
Post by: Pats on January 14, 2010, 11:11:26 PM
Hi curaga !
Your suggestion and link for the Adv. Programming is really fantastic for Linx Programming. I really enjoyed reading the book ! I even ported one of my non-GUI BookShop Invenory app in C from Win Platform to Linux. Working fantastic.
As suggested by bmarkus I also re-tried my hand on Python ! Enjoyed  - thanks !

By the way -  I would like to know from experienced guys like you and others abt which langueses and tools you prefer to develop GUI and non-GUI apps in Linux ?
Also some more links for good online books on Lin. Programming for GUI as well as non-GUI development will be highly appriciated - so kindly give suggestion in that direction.
Thanks !
~ Pats
Title: Re: Creating TCL extention in simple steps !
Post by: spence91 on January 15, 2010, 05:41:44 AM
Personally all the apps i make (both for work and pleasure) are written in python these days. I usually start off with a command line interface simply because it's easy, and also it's nice to be able to pipe stdin/stdout to wherever you want.
With the 'optparse' standard python library it's extremely easy to parse flags/options etc...
http://docs.python.org/library/optparse.html

once it's finished and it needs a frontend then i'll just knock something up in TK.

The reason for using python is because of the speed of development and because it's quite a simple language to pick up and use, i often struggle when it comes to c/c++.
Title: Re: Creating TCL extention in simple steps !
Post by: curaga on January 15, 2010, 06:16:54 AM
For quick prototyping or smaller stuff I use bash, and Xdialog if it needs a GUI.

Then it's C, and graphics with mostly fltk, gtk+, sdl.

I've heard Qt is rather easy if you like C++, with its Creator IDE.
Title: Re: Creating TCL extention in simple steps !
Post by: Pats on January 15, 2010, 10:45:13 AM
@spence91:
Thanks for the optParser link. It is so easy like C++ or Java..
Just do like:

<code>
from optparse import OptionParser
[...]
def main():
    usage = "usage: %prog [options] arg"
    parser = OptionParser(usage)
    parser.add_option("-f", "--file", dest="filename",
                      help="read data from FILENAME")
    parser.add_option("-v", "--verbose",
                      action="store_true", dest="verbose")
    parser.add_option("-q", "--quiet",
                      action="store_false", dest="verbose")
    [...]
    (options, args) = parser.parse_args()
    if len(args) != 1:
        parser.error("incorrect number of arguments")
    if options.verbose:
        print "reading %s..." % options.filename
    [...]

if __name__ == "__main__":
    main()
</code>

Wow !

@curaga:
Thanks ! I just wanted this to know:

Then it should be C, and graphics with mostly fltk, gtk+, sdl.

Although - nothing against Python, but I just wanted to integrate my little C, C++, Access database knowledge with some good front-end devpment tool ( like  fltk, gtk+ ) to avoid another learning curve - so I think I should better start from TK ! By the way is there much diff btwn fltk, gtk ? Which should I prefer for long term interest.

Since most of my apps are database-centric, one of the friends suggested me to try mySQL-PHP combo, which I know a little-bit on Windoz, but not done any serious efforts in that direction.
If there are no serious issues to use Access database with C, C++ and fltk etc, then I would like to stick to C !

Thats why I am trying to guess, which tools should I use for devlpment in Linux for long term view !

Presently I have started using emacs for editing and compiling my C code, instead of command-line gcc or g++ ! is it OK ? How you guys compile-run-debug-output your code ?

Thanks !

~ Pats
Title: Re: Creating TCL extention in simple steps !
Post by: Arslan S. on January 15, 2010, 11:39:28 AM
for GUI if you look for simplicity fox toolkit is a nice one written in C++
http://www.fox-toolkit.org/ (http://www.fox-toolkit.org/)
Title: Re: Creating TCL extention in simple steps !
Post by: bmarkus on January 15, 2010, 12:02:26 PM
Check PyGTK at http://www.pygtk.org/
Title: Re: Creating TCL extention in simple steps !
Post by: curaga on January 15, 2010, 12:40:43 PM
Ya, there's a huge abundance of choice out there, and YMMV :)

Most of the gui toolkits have bindings to most languages anyway.
Title: Re: Creating TCL extention in simple steps !
Post by: bmarkus on January 15, 2010, 12:56:55 PM
Another possibility is wxWidgets http://wxwidgets.org/ possibly with wxPython, wxPerl or one of the many supported languages if you do not want to use C.
Title: Re: Creating TCL extention in simple steps !
Post by: Pats on January 15, 2010, 10:51:02 PM
bmarkus, curaga, Aslan !
Thanks for the guidance ! Going thru diff links given here - lot of reading , I think !
Some more Qs:
Which debuger is easy to use for a newbee - pdb ?

second, I want to use gnumeric object (open gnumeric sheet, put some rows/columns and @sum formula at the end of the rows ) in my sample app, can we do it (it can be in C, C++ or Python/TC anything ) like in Win ? If yes, how ? Some links pl.

Thanks !
~ Pats
Title: Re: Creating TCL extention in simple steps !
Post by: Pats on August 15, 2010, 05:25:08 AM
My sincere thanks to all the guys here, who responded to my this message abt programming front-end in Linux

At last, after more than 3 months of practicing with FLTK and Gnome/GTK, I have developed my 1st full-fledged commercial app - using C++/FLTK combo.
But before distributing this Linux Commercial app. , I would like to know abt any Licencing policies. Should I have to take any care before selling my app to my customers - either from TCLinux, FLTK, or GCC/C++ developers ?

I will install TC2.5 with my app pre-loaded in /home/tc directory with a second ext2 Linux partition.
Pl guide.
Thnks !
Note: I am using built-in libs/*.h files of fltk in TC2.5

~ Pats
Title: Re: Creating TCL extention in simple steps !
Post by: curaga on August 15, 2010, 06:23:23 AM
You need to say you use FLTK in your app documentation, about box or similar. http://fltk.org/COPYING.php

For your app there's nothing else, unless you use other libraries / code.


For distributing TC, you need to also provide sources (2.x/release/src); either include them with the app, or host them somewhere and include a link. Pointing to upstream sources (ie. us) is not allowed in the GPL.
Title: Re: Creating TCL extention in simple steps !
Post by: Pats on August 15, 2010, 07:03:04 AM
Um...! Extremely sorry abt my ignorance in Linux, but I must clarify my situation.
Since, I will be statically compiling my C++ code with GCC3.2 headers and libs(compiletc.tcz), will it need any extra mention abt GCC3.2 copyright ?
Secondly, the intended customers of mine, know nothing abt LinuxOS or TCL2.5, but do you think, still should I distribute the TC sources along with TC2.5 ?
And lastly, since I am using built-in FLTK libs from TC2.5, will it require mentioning abt FLTK in my About window ?
( Off-cource I do not mind mentioning copy-right GPL licences of the respective owners of the products ! :) )

I have converted my commercial app into TC extention, and I will be distributing only the binaries.
This app is related to Medical Practitioners.

Thnks !

~Pats
Title: Re: Creating TCL extention in simple steps !
Post by: curaga on August 15, 2010, 09:25:10 AM
Um...! Extremely sorry abt my ignorance in Linux, but I must clarify my situation.
Since, I will be statically compiling my C++ code with GCC3.2 headers and libs(compiletc.tcz), will it need any extra mention abt GCC3.2 copyright ?

Compiling everything statically? It wouldn't make sense to link basic libs like libc or libstdc++ statically.
Any GCC runtime libs are however governed by the runtime exception, which means you can just ignore them even if statically linked.

Quote
Secondly, the intended customers of mine, know nothing abt LinuxOS or TCL2.5, but do you think, still should I distribute the TC sources along with TC2.5 ?

You can also host them online somewhere. What matters is that if they want to, they can have the TC sources.

Quote
And lastly, since I am using built-in FLTK libs from TC2.5, will it require mentioning abt FLTK in my About window ?

Yes, or docs. It's what the FLTK people themselves ask.

Quote
( Off-cource I do not mind mentioning copy-right GPL licences of the respective owners of the products ! :) )

I have converted my commercial app into TC extention, and I will be distributing only the binaries.
This app is related to Medical Practitioners.

Thnks !

~Pats

Title: Re: Creating TCL extention in simple steps !
Post by: Pats on August 15, 2010, 11:06:13 PM
Thanks, really !

(By the way, I think - curaga means a person who cures all ( ailments, problems etc.) !
How true !!  :)

~Pats