ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I would like to move one software from ncurses to some graphical frontend.
GTK would be a nice move, but man,... have you ever seen the output of :
apt-get install --no-install-recommends libgtk2.0-dev
It is not normal that so much will be installed on a machine.
I am worried, seriously, that no one care about this. A bloated applications is for no one of interest, heavy dependencies: no one care at all, slow applications such as gimp or inkscape: no one care. Seriously, there should be some group of people to clean up the messy devel.
u# apt-get install libfltk1.3-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following package was automatically installed and is no longer required:
libxcb-dri2-0
Use 'apt-get autoremove' to remove it.
The following extra packages will be installed:
fltk1.3-doc fluid libfltk-cairo1.3 libfltk-forms1.3 libfltk-gl1.3
libfltk-images1.3 libfltk1.3 libgl1-mesa-dev libglu1-mesa libglu1-mesa-dev
mesa-common-dev
Suggested packages:
libjpeg-dev
The following NEW packages will be installed:
fltk1.3-doc fluid libfltk-cairo1.3 libfltk-forms1.3 libfltk-gl1.3
libfltk-images1.3 libfltk1.3 libfltk1.3-dev libgl1-mesa-dev libglu1-mesa
libglu1-mesa-dev mesa-common-dev
0 upgraded, 12 newly installed, 0 to remove and 1 not upgraded.
Need to get 13.3 MB of archives.
After this operation, 46.9 MB of additional disk space will be used.
Do you want to continue [Y/n]?
Well, it is much better than GTK, much much better, but still it is quite a lot !
ls -lh
total 5.7M
-rw-r--r-- 1 slk141 users 2.3M May 15 13:21 libfltk.a
-rwxr-xr-x 1 slk141 users 1.2M May 15 13:21 libfltk.so.1.3
-rw-r--r-- 1 slk141 users 4.1K May 15 13:20 libfltk_cairo.a
-rw-r--r-- 1 slk141 users 48K May 15 13:21 libfltk_forms.a
-rwxr-xr-x 1 slk141 users 672K May 15 13:21 libfltk_forms.so.1.3
-rw-r--r-- 1 slk141 users 205K May 15 13:21 libfltk_gl.a
-rwxr-xr-x 1 slk141 users 633K May 15 13:21 libfltk_gl.so.1.3
-rw-r--r-- 1 slk141 users 101K May 15 13:21 libfltk_images.a
-rwxr-xr-x 1 slk141 users 658K May 15 13:21 libfltk_images.so.1.3
and this are the static and shared libraries from my slack build
the debian build seems to include the whole documentation, (that's why I have a extra pack for this)
you will not find anything smaller than FLTK,
in fact, you can include the source into your distribution and ship it like that, the build time is acceptable, something you can/will not do with gtk or qt
You shouldn't consider GTK2 as it is deprecated and unmaintained.
If you want GTK you should choose GTK3 that is better supported and the current target of development.
Now if you DON'T want to use GTK there are some good alternatives like FLTK dugan said or Enlightenment Foundation Libraries[0] (EFL) or even Qt[1] that with the new owners and current developments has gotten a huge traction especially against GTKx
You shouldn't consider GTK2 as it is deprecated and unmaintained.
If you want GTK you should choose GTK3 that is better supported and the current target of development.
Now if you DON'T want to use GTK there are some good alternatives like FLTK dugan said or Enlightenment Foundation Libraries[0] (EFL) or even Qt[1] that with the new owners and current developments has gotten a huge traction especially against GTKx
I would like something nice and graphical for the users (because they dont like ncurses / dos like apps).
As portable / cross-platform as possible, and as tiny and dependencies-free as possible.
One dll to add into the directory would be ideal, such as pdcurses.dll and that's all !!
Qt is too much of a beast for that then, do take a look at EFL though they really are portable! they already run in probably any single system you own and then some while being really lightweight both size and performance wise.
Well, it is much better than GTK, much much better, but still it is quite a lot !
How could you possibly say that's "a lot"? I see the X development packages (which you'll need for obvious reasons), and I see the various packages that FLTK itself was split up into. What did you expect? If you're going by the number of Debian packages you need for development, then you're being silly.
Quote:
One dll to add into the directory would be ideal, such as pdcurses.dll and that's all !!
Talk about moving the goalposts. That is a completely unrelated question.
First, have you forgotten that you can statically link executables?
Second, the number of packages you need to start development (on Debian) has nothing to do with the number of DLLs you'll need to distribute with your compiled application on Windows. With Qt on Windows, you distribute about 3 DLLs with your compiled, dynamically linked Qt application. Just put them in the same directory as the executable.
You didn't think that a compiled FLTK application (on Windows) would need a libglu1-mesa DLL and a libglu1-mesa-dev DLL, did you?
What's the reason for wanting a graphical interface? I'm thinking if it's currently using ncurses you probably don't need a widget library. Have you considered SDL?
Thanks there are quite some interesting ones, alternatives. Which one you favor?
Look I just checked what does gtk making using pkg-config, creating there following Include, needed to compile hello.c with gcc. I like very much. So much non needed stuffs. Man, where is simplicity?
/* The authors of this work have released all rights to it and placed it
in the public domain under the Creative Commons CC0 1.0 waiver
(http://creativecommons.org/publicdomain/zero/1.0/).
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Retrieved from: http://en.literateprograms.org/Hello_World_(C,_Xlib)?oldid=19143
*/
#include<X11/Xlib.h>
#include<stdio.h>
#include<stdlib.h>
int main()
{
Display *dpy;
Window rootwin;
Window win;
Colormap cmap;
XEvent e;
int scr;
GC gc;
if(!(dpy=XOpenDisplay(NULL))) {
fprintf(stderr, "ERROR: could not open display\n");
exit(1);
}
scr = DefaultScreen(dpy);
rootwin = RootWindow(dpy, scr);
cmap = DefaultColormap(dpy, scr);
win=XCreateSimpleWindow(dpy, rootwin, 1, 1, 100, 50, 0,
BlackPixel(dpy, scr), BlackPixel(dpy, scr));
XStoreName(dpy, win, "hello");
gc=XCreateGC(dpy, win, 0, NULL);
XSetForeground(dpy, gc, WhitePixel(dpy, scr));
XSelectInput(dpy, win, ExposureMask|ButtonPressMask);
XMapWindow(dpy, win);
while(1) {
XNextEvent(dpy, &e);
if(e.type==Expose && e.xexpose.count<1)
XDrawString(dpy, win, gc, 10, 10, "Hello World!", 12);
else if(e.type==ButtonPress) break;
}
XCloseDisplay(dpy);
return 0;
}
Most of technical people are trying to migrate from windows to Linux now a days , but they are facing lot of problems with Linux . they do not even know the forums and blogs of Linux which would be useful for finding answer to their query. The main problem of open source is choosing right one for user need. Because so many open source softwares are available for a single thing. Surely user need some supportive forum or website to find that one . open Peta is also doing that job. The idea of this post coming to my mind from my college friend . One of my colleague asked me about computer graphics program in Linux using C programming language. the questions is
How to draw line, circle , or 2D graphics in Linux Using C or C++?
I was searching Internet and found some softwares for developing graphics applications in Linux. that softwares are listed here
GTK+ – Gnome Tool Kit
QT - The X toolkit
SVGALIB [ #include<vgagl.h> ]
libgraph [ #include<graphics.h> ]
GTK and QT are simple and used for high level Graphical User Interface [ GUI ] development. SVGALIB and libgraph is used for 2D graphics in Linux . the syntax and functions are some what different for beginners [specially the user from windows ] but most of users familiar with windows graphics.h header file in C and C++ , so we can move for libgraph which is exact one for windows graphics user . libgraph is an implementation of the Turbo C graphics API (graphics.h) on GNU/Linux using SDL [ Simple Direct Media Player ]. The library requires SDL for primitive graphics and SDL. First you need to install the following dependency packages using synaptic package manager in Ubuntu Linux to develop the graphics applications properly.
gcc test.c -lgraph -o superbe
Code:
#include<stdio.h>
#include<graphics.h>
int main() {
//int gd=DETECT,gm;
int gd = DETECT,gm, left=100,top=100,right=200,bottom=200,x= 300,y=150,radius=50;
initgraph(&gd,&gm,NULL);
int i,xx=10;
char str[3]="0";
setbkcolor(WHITE);
setcolor(12); //outline heart
circle(50,50,40);
circle(110,50,40);
line(22,80,80,140);
line(80,140,138,80);
floodfill(50,50,12); //fill heart
floodfill(110,50,12);
floodfill(80,50,12);
floodfill(80,100,12);
// setlinestyle(SOLID_LINE, 0, 2); <---- this is not into LINUX?
line(50,50,200,200);
/* setting text justification - horizontally & vertically */
// how to use this into linux? settextjustify(CENTER_TEXT, CENTER_TEXT);
/* sets font style, direction and size */
// settextstyle(i, i % 2, 5);
setcolor(RED);
rectangle(150, 180, 500, 220);
floodfill(201,201,12);
outtextxy(200 , 200 , " I LOVE GRAPHICS.H ON LINUX");
line(50,50,80,80);
line( 0, 0, 100, 100);
setcolor(YELLOW);
rectangle(left, top -100 , right, bottom -100);
circle(x, y, radius);
bar(left + 300, top -100 , right + 300, bottom -100);
setcolor(BLUE);
line(left - 10, top + 150, left + 410, top + 150);
ellipse(x, y + 200, 0, 360, 100, 50);
setcolor(BLUE);
// draw a white color border with rectangle
rectangle(3 ,3,getmaxx() -3,getmaxy() -3);
setcolor(BLUE); // to set the colour of the text to white
outtextxy(left + 100, top + 325, "My First C Graphics Program");
setcolor(BLUE); // to set the colour of the text to white
//settextstyle(3,0,2); // to set the text to my preferred style
outtextxy(40,10,"text goes here"); // the actual text
//settextstyle(0,0,1); // to return the style to default
setcolor(CYAN);
moveto(200 , 200 );
char msg[4000];
int j ;
rectangle(150, 380, 500, 440 );
floodfill(181,401,12);
j = snprintf( msg, 300 , "background: %d, foreground: %d, maxcolors: %d", getbkcolor(), getcolor(), getmaxcolor());
outtextxy( 180 , 400 , msg );
getch();
closegraph();
return 0;
}
However borland graphics.h might be slow... , no??
Quote:
About
This library is intended to replace the old DOS library that was included Borland C (called BGI, which stands for Borland Graphics Interface). which provides functions for DOS graphics mode. It was extremely slow and it's API wasn't perfect (from modern point of view) but it was very simple to use, so it very well suits for teaching programming basis, where graphics output is needed. Although all it's lacks, it is used even now, because of it's simplicity for teaching purpose.
So, OpenBGI library is intended to replace that old library, by implementing just the same interface but implementing on Microsoft Windows system for use with Visual Studio (6.0, .NET, 2003, 2005, 2008) or MinGW compiler. It has practically the same API as <graphics.h> (that was included in Borland C for DOS) with some extensions (described in Features). That is, it let's simply to switch from old legacy Borland C to modern compilers/IDEs ( Visual Studio 2005 Express Edition, for example) practically without code changing.
There is also some other Windows implementation of that old library (Winbgi, for example), but OpenBGI implementation differs from them in good debug mode support
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.