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.
#include<stdio.h>
#include<graphics.h>
void boundfil(int x, int y, int fill, int old)
{
if(getpixel(x,y)!=old && getpixel(x,y)!=fill)
{
putpixel(x,y,fill);
boundfil(x+1,y,fill,old);
delay(10);
boundfil(x-1,y,fill,old);
boundfil(x,y+1,fill,old);
boundfil(x,y-1,fill,old);
}
}
main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"");
rectangle(100,200,450,400);
boundfil(101,201,5,15);
getch();
closegraph();
}
When I am trying to execute this progrm in Ubuntu the graphics window comes and suddenly disposes when am trying to input the values..
and the error is.."a.out: ../../src/xcb_io.c:249: process_responses: Assertion `(((long) (dpy->last_request_read) - (long) (dpy->request)) <= 0)' failed.
Aborted
"
Anybody can help me..?
Click here to see the post LQ members have rated as the most helpful post in this thread.
by the way.Friend
you might be a student,and your coding actually compatible with turbo C in Windows but not with gcc in Ubuntu linux.
because,graphics.h is not available in linux gcc.
but i know some people really interested to use turbo c in linux with help of emulators.
ok for that people my best solution.
Go to the terminal:
Code:
sudo aptitude install dosbox
APT will now download and install DOSBOX.
You can also use Synaptic as usual.
after downloading,Unpack the achieve
Keep the installation files inside a folder of your home directory named "setup".
Open up dosbox, its under Applications > Games
Type in :
Code:
mount c ~
c:
cd setup
install.exe
This will start the setup of Turbo C.
After setup is finished , do this:
Code:
c:
cd TC\bin
tc.exe
Now everytime you want to run Turbo C++ start DOSBOX and then type in the following:
Code:
mount C ~
c:
cd TC\bin
tc.exe
To maximise full screen hit 'Alt+Enter' and to go back to medium size again hit 'Alt+Enter'. DOSBOX has a habit of capturing the mouse pointer, once you click within DOSBOX you cannot move it away from the winow. To go back to Ubuntu hit 'Alt+Enter' twice.
'Alt+X' will close Turbo C.
Hope I have helped
I think it would be a much better idea to learn GTK+ or Qt (if you're interested in GUI applications), or SDL or Allegro if you're interested in game programming).
Actually the above code works well in my college system(debian linux).But when I tried it at home in my Ubuntu 10.10 pc,it is showing the error that i mentioned above...I am not really interested in installing Turbo C++ or any similar software to run it. anyway i shall install any additional libraries or edit any system files to make it work. Can anyone help me now..........???
There is no part of the C language that includes graphics of any sort. To use C for any graphical purpose requires add-on libraries that are not part of the C language, and are very much platform dependent. You cannot expect graphical applications to be portable across host CPUs, compilers, or host OS's. If your code worked on some Linux system, it was because someone had installed some kind of supporting infrastructure to permit it. Applications written for Borland/DOS/Windows are generally wholly incompatible with any standard or convention in the Linux world.
If it is your intention to develop graphical software for Linux, it behooves you to make use of the extensive existing infrastructure provided by virtually any Linux installation that includes an X-based GUI. To create interactive graphics using a toolkit like that provided by Turbo C would require you to re-invent a tremendous amount (more that one person could accomplish in a lifetime) of work that has already been done and is a recognized standard supported by a cast of thousands. If you want to use the C language, your easiest route to creation of GUI applications for Linux would be GTK+. For drawing lines and circles and the likes of that, there are various ways to draw graphics on GTK canvas widgets. Personally, I like the use of SVG for 'presentation' graphics.
There is no part of the C language that includes graphics of any sort. To use C for any graphical purpose requires add-on libraries that are not part of the C language, and are very much platform dependent. You cannot expect graphical applications to be portable across host CPUs, compilers, or host OS's. If your code worked on some Linux system, it was because someone had installed some kind of supporting infrastructure to permit it. Applications written for Borland/DOS/Windows are generally wholly incompatible with any standard or convention in the Linux world.
If it is your intention to develop graphical software for Linux, it behooves you to make use of the extensive existing infrastructure provide by virtually any Linux installation that includes an X-based GUI. To create interactive graphics using a toolkit like that provided by Turbo C would require you to re-invent a tremendous amount (more that one person could accomplish in a lifetime) of work that has already been done and is a recognized standard supported by a cast of thousands. If you want to use the C language, your easiest route to creation of GUI applications for Linux would be GTK+. For drawing lines and circles and the likes of that, there are various ways to draw graphics on GTK canvas widgets. Personally, I like the use of SVG for 'presentation' graphics.
--- rod.
actually vineesh is a indian computer science student like i was.
in order to do his practical exams well in college,he have to practice his codes well.
i gotta help him.
actually vineesh is a indian computer science student like i was.
in order to do his practical exams well in college,he have to practice his codes well.
i gotta help him.
I installed all packages for the working of C Graphics like libgraph..
I did all things in my ubuntu system that i had done in debian linux....
The problem is regarding to ubuntu only...
please help me....
by the way.Friend
you might be a student,and your coding actually compatible with turbo C in Windows but not with gcc in Ubuntu linux.
because,graphics.h is not available in linux gcc.
but i know some people really interested to use turbo c in linux with help of emulators.
ok for that people my best solution.
Go to the terminal:
Code:
sudo aptitude install dosbox
APT will now download and install DOSBOX.
You can also use Synaptic as usual.
after downloading,Unpack the achieve
Keep the installation files inside a folder of your home directory named "setup".
Open up dosbox, its under Applications > Games
Type in :
Code:
mount c ~
c:
cd setup
install.exe
This will start the setup of Turbo C.
After setup is finished , do this:
Code:
c:
cd TC\bin
tc.exe
Now everytime you want to run Turbo C++ start DOSBOX and then type in the following:
Code:
mount C ~
c:
cd TC\bin
tc.exe
To maximise full screen hit 'Alt+Enter' and to go back to medium size again hit 'Alt+Enter'. DOSBOX has a habit of capturing the mouse pointer, once you click within DOSBOX you cannot move it away from the winow. To go back to Ubuntu hit 'Alt+Enter' twice.
'Alt+X' will close Turbo C.
Hope I have helped
install.exe didnt work in dosbox...
The following error occurs..
"This program must be run under Microsoft windows.."
Distribution: Ubuntu 11.4,DD-WRT micro plus ssh,lfs-6.6,Fedora 15,Fedora 16
Posts: 3,233
Rep:
you might be able to get away with using a copy of windows 3.1, i can't provide a link to one due to legal reasons, but copies should be relatively readily available on the internet, and win3.1 can be installed on dosbox pretty easily, trust me i've done it
You've got to tell us a little more about what you're trying to do before we can help you. Baxzius acts like maybe he understands, but none of the rest of us do. You have to help us out before we can help you.
Here's what I know:
1. This is clearly coded for "Turbo C" graphics, an obsolete library (Borland Graphics) for an obsolete platform (DOS, and only DOS). It's not applicable to Windows, it's certainly not applicable to Linux:
Code:
#include<stdio.h>
#include<graphics.h>
void boundfil(int x, int y, int fill, int old)
{
if(getpixel(x,y)!=old && getpixel(x,y)!=fill)
...
main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"");
rectangle(100,200,450,400);
...
2. One possible solution for running a DOS .exe under Linux is to get a "virtual DOS PC" program, such as dosbox. This is what Baxzius was talking about. If you did this, you could use a (DOS) Turbo C compiler, create a (DOS) .exe, and run it in (the virtual) dosbox. It does NOT look like this is what you're doing.
3. Instead, it looks like you've found a library called "libgraph"; it looks like it emulates Turbo C graphics under X Windows.
Q: Where exactly did you get this "libgraph"?
4. It sounds like your "libgraph" installation is working under Debian, but not under Ubuntu.
Q: Is this correct?
Q: Exactly how did you install "libgraph" in Debian? In Ubuntu?
Q: Exactly what version of Ubuntu Linux are you running?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.