LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-01-2011, 02:09 AM   #1
vineesh314
LQ Newbie
 
Registered: Jul 2011
Posts: 6

Rep: Reputation: Disabled
Angry C Graphics window problem.....


#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.
Old 08-01-2011, 01:09 PM   #2
baxzius
Member
 
Registered: Jan 2010
Location: India
Distribution: ubuntu
Posts: 134
Blog Entries: 1

Rep: Reputation: 21
Wink be happy

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.

Download Turbo C/C++ here
You have to register, but they don't nag and it is hasslefree.

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
 
0 members found this post helpful.
Old 08-01-2011, 01:14 PM   #3
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
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).
 
Old 08-01-2011, 07:37 PM   #4
vineesh314
LQ Newbie
 
Registered: Jul 2011
Posts: 6

Original Poster
Rep: Reputation: Disabled
This code well working in debian linux..
But not working in ubuntu...
The graphics window comes and suddenly disppears when trying to input...

vineesh@vineesh-M61PME-S2:~/c$ gcc ellipse1.c -lgraph
vineesh@vineesh-M61PME-S2:~/c$ ./a.out
a.out: ../../src/xcb_io.c:249: process_responses: Assertion `(((long) (dpy->last_request_read) - (long) (dpy->request)) <= 0)' failed.
Aborted

it is the error...........
 
Old 08-01-2011, 08:27 PM   #5
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Moved: This thread is more suitable in <PROGRAMMING> and has been moved accordingly to help your thread/question get the exposure it deserves.
 
Old 08-02-2011, 06:30 AM   #6
vineesh314
LQ Newbie
 
Registered: Jul 2011
Posts: 6

Original Poster
Rep: Reputation: Disabled
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..........???
 
Old 08-02-2011, 10:28 AM   #7
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
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.

--- rod.

Last edited by theNbomr; 08-06-2011 at 10:29 AM.
 
Old 08-02-2011, 12:43 PM   #8
baxzius
Member
 
Registered: Jan 2010
Location: India
Distribution: ubuntu
Posts: 134
Blog Entries: 1

Rep: Reputation: 21
Quote:
Originally Posted by theNbomr View Post
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.
 
0 members found this post helpful.
Old 08-02-2011, 01:36 PM   #9
vineesh314
LQ Newbie
 
Registered: Jul 2011
Posts: 6

Original Poster
Rep: Reputation: Disabled
Unhappy Ubuntu Graphics problem.....

Quote:
Originally Posted by baxzius View Post
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....
 
Old 08-02-2011, 09:25 PM   #10
vineesh314
LQ Newbie
 
Registered: Jul 2011
Posts: 6

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by baxzius View Post
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.

Download Turbo C/C++ here
You have to register, but they don't nag and it is hasslefree.

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.."
 
Old 08-02-2011, 09:39 PM   #11
frieza
Senior Member
 
Registered: Feb 2002
Location: harvard, il
Distribution: Ubuntu 11.4,DD-WRT micro plus ssh,lfs-6.6,Fedora 15,Fedora 16
Posts: 3,233

Rep: Reputation: 406Reputation: 406Reputation: 406Reputation: 406Reputation: 406
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
 
Old 08-02-2011, 09:59 PM   #12
vineesh314
LQ Newbie
 
Registered: Jul 2011
Posts: 6

Original Poster
Rep: Reputation: Disabled
Help me please...
 
Old 08-02-2011, 10:27 PM   #13
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
vineesh -

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?

Thank you in advance .. PSM

Last edited by paulsm4; 08-02-2011 at 10:28 PM.
 
2 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Use X Window System on LiveCD with Integrated Graphics boopyman Linux From Scratch 17 05-22-2011 11:04 AM
LXer: Xorg's X Window innovation - it's not ALL about the graphics (but there's quite LXer Syndicated Linux News 0 06-02-2009 07:30 AM
nvidia graphics, 2 kernels, 2 window managers is it possible? GlennsPref Linux - Hardware 2 02-04-2009 05:35 PM
Garbled window graphics in Mandrake 9.1 jjcotie Linux - Newbie 1 03-13-2003 11:40 AM
bad graphics in command window poortl9109 Linux - General 7 01-08-2003 12:59 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:40 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration