terminate stay resident programs in ubuntu

Asked by prasad.ram on 2011-03-05

hi sir i am learning c programming in windows we can write interrupts through c programming like mouse ,keyboard ,int86 interrupts and we can write tsr's(terminate state resident program ) by the help of dos.h header file and using pointers like far ,huge ,near .i would like to how can i do these in ubuntu for this what are the required header files and pointers please tell me

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu gcc-defaults Edit question
Assignee:
No assignee Edit question
Solved by:
mycae
Solved:
2011-03-18
Last query:
2011-03-18
Last reply:
2011-03-15
Ubfan (ubfan1) said : #1

Install the build-essential package if you are missing the system headers. They may be present in a default install for the c language anyway. You have quiet a different environment to learn for programming -- no more direct interfacing with the hardware, you use the operating system calls instead, no more far, near, pointer nonsense or tsr kluges, it's a flat address space. It will be a much simpler environment to program with the OS doing most of the really low level things.

mycae (mycae) said : #2

TSRs disappeared with DOS 6. Windows 95 introduced protected memory access.
https://secure.wikimedia.org/wikipedia/en/wiki/Terminate_and_Stay_Resident

Unix has had protected memory access for a very very long time (before dos 6), and thus no-one will support TSR programs any more.

You are running in a multi-tasking environment, in so-called "user land". You need to use the kernel API functions, or libraries over that (eg X) to do what you want.

Direct interfacing to hardware is now disallowed in all modern operating systems of any size, as this is a major security and stability problem.

prasad.ram (prasad-ram126) said : #3

thanks for giving me valuable suggestions and windos 7 supports the
interrupts and TSR's also ok what ever it is I would like to learn these
interrupts in ubuntu how it is possible ?
and another is there any books or websites for learning API functions ?

On Sat, Mar 5, 2011 at 11:24 PM, mycae <<email address hidden>
> wrote:

> Your question #147943 on Ubuntu changed:
> https://answers.launchpad.net/ubuntu/+question/147943
>
> mycae proposed the following answer:
> TSRs disappeared with DOS 6. Windows 95 introduced protected memory access.
> https://secure.wikimedia.org/wikipedia/en/wiki/Terminate_and_Stay_Resident
>
> Unix has had protected memory access for a very very long time (before
> dos 6), and thus no-one will support TSR programs any more.
>
> You are running in a multi-tasking environment, in so-called "user
> land". You need to use the kernel API functions, or libraries over that
> (eg X) to do what you want.
>
> Direct interfacing to hardware is now disallowed in all modern
> operating systems of any size, as this is a major security and stability
> problem.
>
> --
> If this answers your question, please go to the following page to let us
> know that it is solved:
> https://answers.launchpad.net/ubuntu/+question/147943/+confirm?answer_id=1
>
> If you still need help, you can reply to this email or go to the
> following page to enter your feedback:
> https://answers.launchpad.net/ubuntu/+question/147943
>
> You received this question notification because you are a direct
> subscriber of the question.
>

What do you mean when you say that Windows 7 supports TSR's? Are you perhaps using the term "TSR" to mean something else? Windows 7 does provide some facilities to run old DOS programs, but that's not the same thing as saying that a Windows 7 application can be (or use) a TSR.

As others have said, applications running normally in any modern operating system, including Windows 7 and Ubuntu, are restricted in their access to hardware and to memory. In particular, they cannot access memory arbitrarily, but only specifically defined ranges of memory assigned to them. That is sufficient for most things you want your application to do, and there is no performance or other advantage associated with bypassing this restriction.

If you wish to get around that restriction, then you'll need to write drivers. In a Linux-based OS like Ubuntu, those are implemented by Linux kernel modules. There are many important and valid uses for kernel modules, but if you just want your program to run in the background and provide services, making it be (or use) a kernel module would be unnecessary and highly undesirable. Disadvantages associated with writing an application that needlessly installs and uses its own driver include greatly increased development time, instability and insecurity (for the entire system it's running or even just installed on), and all your users being extremely pissed off. ;-)

If you want to learn to writer Linux kernel modules, you might be interested to read the Linux Kernel Module Programming Guide:
http://tldp.org/LDP/lkmpg/2.6/html/lkmpg.html

If you just want your programs to daemonize (i.e. to run in the background and not be dependent on or controlled by whatever process created it), the way to do it will depend on what language you're using and what, if any, additional framework/API you're using. But you'll likely find this useful:
http://www.qgd.unizh.ch/~dpotter/howto/daemonize

Back in the DOS days, we often used TSR's to provide functionality on demand. I remember having a calculator program that operated as a TSR, so that when I was in WordPerfect 5.1 (or any other application) and I wanted to calculate something, I could press a certain key combination (I don't remember what it was) to bring up the calculator, without any interruption to my word processing. Otherwise, I would have had to quit WordPerfect and go back to the command prompt (command.com back then). Those were the days! As illustrated by this example, the functionality of a TSR is somewhere between meaningless and pointless in the context of a modern multitasking operating system. On the other hand, having an application be out of the way, doing its job, but available to be called up by the user is still very useful. To the extent to which switching out of it and making some other application the foreground one (either in the sense of it being the foreground window, or in the sense of it being the foreground job using commands like "fg" and "jobs" in the Terminal) is sufficient--which is most of the time--it is not necessary to do anything special. (Also, a user who wishes to switch between different applications in the same Terminal in a more free-form way, or to start an application in one Terminal, close the Terminal, and keep using it in some other Terminal, the program "screen" is provided.)

For graphical applications that "run in the background" a lot, there is often the desire to be a bit less impinging on the user. So if what you want is to write a graphical application that stays out of the way (in particular, out of the Window List in Ubuntu, also called the taskbar) when it's not needed, but is available to the user when they want it, then you should simply make your application use a notification area icon. This is a standard GUI element, available in multiple operating systems (in particular, both in Windows and Ubuntu). The way you'd do it depends on what framework or API you're using to code your graphical user interface.

"and another is there any books or websites for learning API functions ?"

There are thousands of books for learning API functions. An API is an Application Programming Interface, and there are hundreds of different API's, used for many different purposes.

A lot of the useful things you can make your application do are provided by the API that is guaranteed to be provided on any computer that can run applications written in the language you're using. In particular, for C, this is the Standard C Library, and for C++, this is the Standard C++ Library (which contains, and sometimes is referred to interchangeably with, the Standard Template Library, since much of the Standard C++ Library's functionality is provided by templates). You've asked previous questions about C++, so I suspect that's the language (or one of the languages) you're using. You may be pleased to hear that in the upcoming C++ standard, the Standard Library will provide even more functionality, such as the ability to create and manage threads and perform synchronization without ever having to use (or make your program's source code depend on) other API's (such as those provided by the operating system or by an additional framework).

If you want to use the POSIX API (which provides what some people call the "core UNIX functionality" of a Unix-like operating system), your system's implementation is documented in your system manpages (section 2), and the official standards that have been released for the POSIX API are available at https://www2.opengroup.org/ogsys/jsp/publications/mainPage.jsp. In particular, these may interest you: https://www2.opengroup.org/ogsys/jsp/publications/SearchResults.jsp?search=posix&Search=Search+Publications

When seeking documentation on the POSIX API, I usually find that searching with Google for what I'm looking for (for example, the name of the function or header file that I want information on) with the added term "site:opengroup.org" (without the quotes) brings up the page I'm looking for. Keep in mind that you may get multiple results for the same topic, corresponding to standards released on different dates. To get you started, the Google Search http://www.google.com/search?sourceid=chrome&client=ubuntu&channel=cs&ie=UTF-8&q=site:opengroup.org+%22unistd.h%22 results a number of possibly useful hits, of which http://pubs.opengroup.org/onlinepubs/009695399/basedefs/unistd.h.html is probably most useful. (That's the part of the 2004 standard documenting the header file that contains definitions for many of the important POSIX API functions.)

The POSIX API provides minimalist API function wrappers for a number of Linux kernel calls (e.g. sbrk). This is the preferred way to use these calls from a C or C++ program. Many of these calls are quite low-level and should be avoided when possible, which is almost always. For example, rather than manually using sbrk to allocate heap memory (and writing your own application-specific scheme for keeping track of what memory is allocated and when to allocate and deallocate memory), you should instead use malloc (or calloc, when that's more appropriate) and free in C, or new/new[] and delete/delete[] in C++. (You can also use any combination of malloc/calloc, new, and new[] in the same C++ program, so long as you never deallocate malloced/calloced memory except with free, never deallocate new'd memory except with delete, and never deallocate new[]'d memory except with delete[].) If you're using a framework (like glib/GTK+), it may provide an additional mechanism for allocating and deallocating memory and performing various other functions also implemented in your Standard Library. So may some special-purpose API's (even if not providing general purpose frameworks).

To return momentarily to the topic of learning the POSIX API, you should of course consider getting a book on that, rather than starting out learning from the references sources. I don't consider myself qualified to recommend such a book, however. But you can search for them online, and perhaps someone else here can make a good recommendation. Often such books have phrases such as "UNIX Programming" in their titles; they don't necessarily have "POSIX" in their titles. (And they don't necessary teach strictly to the standard, but that's generally OK.) Some have "Linux" in their titles instead of "Unix", if they're specifically oriented toward Linux-based systems.

Especially if you're writing graphical programs, you'll likely want to use a framework that helps you do that. (Such frameworks are typically useful for other things besides GUI programming, too, which is why I said that in such a strange-seeming way.) In Windows, it is sometimes reasonable to code programs directly in the Windows API (also often called the "Win32 API"), which corresponds conceptually to the POSIX API in some ways and to the X11 API in others (see http://en.wikipedia.org/wiki/X11 if you don't know what X11 means; see http://linuxgazette.net/issue78/tougher.html for some information about how the X11 API works). However, creating Windows (and widgets, such as buttons and text boxes) in the X11 API is extremely arduous, because the X11 API doesn't have any concept of what a button, text box, list box, etc. are. You'd have to code all the behavior for each type of widget into your program. Besides being hard, it's also bad programming practice to needlessly reimplement such functionality in all your programs. You could write your own library to implement them, but then your programs would have an extra dependency. Furthermore, and this is really the point: There are several very good libraries that already exist, for this, and you should use them (or one of them, anyway). These libraries are used by many programs, so they're already present on many users' computers, and even if not present, installing them is not too big a deal, since they are provided by packages in every major distribution. If your program is packaged for a distribution, then you can make it so that any such needed framework is installed automatically when your program is installed. (For porting such an application to Microsoft Windows, you can usually bundle the framework's libraries with your application, and your application's installer than install them if they're needed...or even maintain a local copy of the framework specific to and used only by your program.)

The GTK+ framework is very good, and is the most popular GUI framework. See http://en.wikipedia.org/wiki/Gtk%2B and http://www.gtk.org/. Almost every Linux-based desktop system already has it installed. Originally developed for the raster graphics editor GIMP (http://www.gimp.org/), GTK+ is the foundation of the GNOME desktop environment, which Ubuntu uses. (It is also the foundation of the desktop environments Xfce and LXDE). Programs that use GTK+ typically "look right" in the context of the other applications the user is running. If you're programming with C++ then gtkmm is the specific API that you want, for writing GTK+ programs. See http://www.gtkmm.org/ and the information, tutorials, and books recommended therein. (The book recommendations contain books for related things, too, so make sure you know what you're buying. For example, The C++ Programming Language by Bjarne Stroustrup is an awesome book for learning C++ -- provided that you already have a general knowledge of computer programming topics, as this book is certainly not written with absolute beginners in mind -- but The C++ Programming Language doesn't actually teach you how to apply your C++ skills to using the gtkmm framework.) You don't *necessarily* have to buy a book at all--the resources at http://www.gtkmm.org/en/documentation.html are very good.

The second most popular portable GUI framework is Qt (see http://en.wikipedia.org/wiki/Qt_(framework) and http://qt.nokia.com/). Another popular framework is wxWidgets (see http://en.wikipedia.org/wiki/Wxwidgets and http://wxwidgets.org/).

prasad.ram (prasad-ram126) said : #5

thanks for giving me a valuable information and it is very useful for me but
you a gave me a bunch of information so i am little bit confuse actually i
would like to construct a small game with c program in that i would write a
code for arrow keys (left,right,up,down) and functional keys
(Ctrl,shift,tab) and mouse for with in windows we write interrupts so what
is the replacement in ubuntu ?.

After that i would make it as GUI for that what frame work i need please
tell me only one which has less limitations (means which support any
language and with this we can construct any type of frame work)? if i made
any trouble for you please excuse me

On Sun, Mar 6, 2011 at 10:43 PM, Eliah Kagan <
<email address hidden>> wrote:

> Your question #147943 on Ubuntu changed:
> https://answers.launchpad.net/ubuntu/+question/147943
>
> Status: Open => Answered
>
> Eliah Kagan proposed the following answer:
> What do you mean when you say that Windows 7 supports TSR's? Are you
> perhaps using the term "TSR" to mean something else? Windows 7 does
> provide some facilities to run old DOS programs, but that's not the same
> thing as saying that a Windows 7 application can be (or use) a TSR.
>
> As others have said, applications running normally in any modern
> operating system, including Windows 7 and Ubuntu, are restricted in
> their access to hardware and to memory. In particular, they cannot
> access memory arbitrarily, but only specifically defined ranges of
> memory assigned to them. That is sufficient for most things you want
> your application to do, and there is no performance or other advantage
> associated with bypassing this restriction.
>
> If you wish to get around that restriction, then you'll need to write
> drivers. In a Linux-based OS like Ubuntu, those are implemented by Linux
> kernel modules. There are many important and valid uses for kernel
> modules, but if you just want your program to run in the background and
> provide services, making it be (or use) a kernel module would be
> unnecessary and highly undesirable. Disadvantages associated with
> writing an application that needlessly installs and uses its own driver
> include greatly increased development time, instability and insecurity
> (for the entire system it's running or even just installed on), and all
> your users being extremely pissed off. ;-)
>
> If you want to learn to writer Linux kernel modules, you might be
> interested to read the Linux Kernel Module Programming Guide:
> http://tldp.org/LDP/lkmpg/2.6/html/lkmpg.html
>
> If you just want your programs to daemonize (i.e. to run in the background
> and not be dependent on or controlled by whatever process created it), the
> way to do it will depend on what language you're using and what, if any,
> additional framework/API you're using. But you'll likely find this useful:
> http://www.qgd.unizh.ch/~dpotter/howto/daemonize
>
> Back in the DOS days, we often used TSR's to provide functionality on
> demand. I remember having a calculator program that operated as a TSR,
> so that when I was in WordPerfect 5.1 (or any other application) and I
> wanted to calculate something, I could press a certain key combination
> (I don't remember what it was) to bring up the calculator, without any
> interruption to my word processing. Otherwise, I would have had to quit
> WordPerfect and go back to the command prompt (command.com back then).
> Those were the days! As illustrated by this example, the functionality
> of a TSR is somewhere between meaningless and pointless in the context
> of a modern multitasking operating system. On the other hand, having an
> application be out of the way, doing its job, but available to be called
> up by the user is still very useful. To the extent to which switching
> out of it and making some other application the foreground one (either
> in the sense of it being the foreground window, or in the sense of it
> being the foreground job using commands like "fg" and "jobs" in the
> Terminal) is sufficient--which is most of the time--it is not necessary
> to do anything special. (Also, a user who wishes to switch between
> different applications in the same Terminal in a more free-form way, or
> to start an application in one Terminal, close the Terminal, and keep
> using it in some other Terminal, the program "screen" is provided.)
>
> For graphical applications that "run in the background" a lot, there is
> often the desire to be a bit less impinging on the user. So if what you
> want is to write a graphical application that stays out of the way (in
> particular, out of the Window List in Ubuntu, also called the taskbar)
> when it's not needed, but is available to the user when they want it,
> then you should simply make your application use a notification area
> icon. This is a standard GUI element, available in multiple operating
> systems (in particular, both in Windows and Ubuntu). The way you'd do it
> depends on what framework or API you're using to code your graphical
> user interface.
>
> "and another is there any books or websites for learning API functions
> ?"
>
> There are thousands of books for learning API functions. An API is an
> Application Programming Interface, and there are hundreds of different
> API's, used for many different purposes.
>
> A lot of the useful things you can make your application do are provided
> by the API that is guaranteed to be provided on any computer that can
> run applications written in the language you're using. In particular,
> for C, this is the Standard C Library, and for C++, this is the Standard
> C++ Library (which contains, and sometimes is referred to
> interchangeably with, the Standard Template Library, since much of the
> Standard C++ Library's functionality is provided by templates). You've
> asked previous questions about C++, so I suspect that's the language (or
> one of the languages) you're using. You may be pleased to hear that in
> the upcoming C++ standard, the Standard Library will provide even more
> functionality, such as the ability to create and manage threads and
> perform synchronization without ever having to use (or make your
> program's source code depend on) other API's (such as those provided by
> the operating system or by an additional framework).
>
> If you want to use the POSIX API (which provides what some people call
> the "core UNIX functionality" of a Unix-like operating system), your
> system's implementation is documented in your system manpages (section
> 2), and the official standards that have been released for the POSIX API
> are available at
> https://www2.opengroup.org/ogsys/jsp/publications/mainPage.jsp. In
> particular, these may interest you:
>
> https://www2.opengroup.org/ogsys/jsp/publications/SearchResults.jsp?search=posix&Search=Search+Publications
>
> When seeking documentation on the POSIX API, I usually find that
> searching with Google for what I'm looking for (for example, the name of
> the function or header file that I want information on) with the added
> term "site:opengroup.org" (without the quotes) brings up the page I'm
> looking for. Keep in mind that you may get multiple results for the same
> topic, corresponding to standards released on different dates. To get
> you started, the Google Search
>
> http://www.google.com/search?sourceid=chrome&client=ubuntu&channel=cs&ie=UTF-8&q=site:opengroup.org+%22unistd.h%22
> results a number of possibly useful hits, of which
> http://pubs.opengroup.org/onlinepubs/009695399/basedefs/unistd.h.html is
> probably most useful. (That's the part of the 2004 standard documenting
> the header file that contains definitions for many of the important
> POSIX API functions.)
>
> The POSIX API provides minimalist API function wrappers for a number of
> Linux kernel calls (e.g. sbrk). This is the preferred way to use these
> calls from a C or C++ program. Many of these calls are quite low-level
> and should be avoided when possible, which is almost always. For
> example, rather than manually using sbrk to allocate heap memory (and
> writing your own application-specific scheme for keeping track of what
> memory is allocated and when to allocate and deallocate memory), you
> should instead use malloc (or calloc, when that's more appropriate) and
> free in C, or new/new[] and delete/delete[] in C++. (You can also use
> any combination of malloc/calloc, new, and new[] in the same C++
> program, so long as you never deallocate malloced/calloced memory except
> with free, never deallocate new'd memory except with delete, and never
> deallocate new[]'d memory except with delete[].) If you're using a
> framework (like glib/GTK+), it may provide an additional mechanism for
> allocating and deallocating memory and performing various other
> functions also implemented in your Standard Library. So may some
> special-purpose API's (even if not providing general purpose
> frameworks).
>
> To return momentarily to the topic of learning the POSIX API, you should
> of course consider getting a book on that, rather than starting out
> learning from the references sources. I don't consider myself qualified
> to recommend such a book, however. But you can search for them online,
> and perhaps someone else here can make a good recommendation. Often such
> books have phrases such as "UNIX Programming" in their titles; they
> don't necessarily have "POSIX" in their titles. (And they don't
> necessary teach strictly to the standard, but that's generally OK.) Some
> have "Linux" in their titles instead of "Unix", if they're specifically
> oriented toward Linux-based systems.
>
> Especially if you're writing graphical programs, you'll likely want to
> use a framework that helps you do that. (Such frameworks are typically
> useful for other things besides GUI programming, too, which is why I
> said that in such a strange-seeming way.) In Windows, it is sometimes
> reasonable to code programs directly in the Windows API (also often
> called the "Win32 API"), which corresponds conceptually to the POSIX API
> in some ways and to the X11 API in others (see
> http://en.wikipedia.org/wiki/X11 if you don't know what X11 means; see
> http://linuxgazette.net/issue78/tougher.html for some information about
> how the X11 API works). However, creating Windows (and widgets, such as
> buttons and text boxes) in the X11 API is extremely arduous, because the
> X11 API doesn't have any concept of what a button, text box, list box,
> etc. are. You'd have to code all the behavior for each type of widget
> into your program. Besides being hard, it's also bad programming
> practice to needlessly reimplement such functionality in all your
> programs. You could write your own library to implement them, but then
> your programs would have an extra dependency. Furthermore, and this is
> really the point: There are several very good libraries that already
> exist, for this, and you should use them (or one of them, anyway). These
> libraries are used by many programs, so they're already present on many
> users' computers, and even if not present, installing them is not too
> big a deal, since they are provided by packages in every major
> distribution. If your program is packaged for a distribution, then you
> can make it so that any such needed framework is installed automatically
> when your program is installed. (For porting such an application to
> Microsoft Windows, you can usually bundle the framework's libraries with
> your application, and your application's installer than install them if
> they're needed...or even maintain a local copy of the framework specific
> to and used only by your program.)
>
> The GTK+ framework is very good, and is the most popular GUI framework.
> See http://en.wikipedia.org/wiki/Gtk%2B and http://www.gtk.org/. Almost
> every Linux-based desktop system already has it installed. Originally
> developed for the raster graphics editor GIMP (http://www.gimp.org/),
> GTK+ is the foundation of the GNOME desktop environment, which Ubuntu
> uses. (It is also the foundation of the desktop environments Xfce and
> LXDE). Programs that use GTK+ typically "look right" in the context of
> the other applications the user is running. If you're programming with
> C++ then gtkmm is the specific API that you want, for writing GTK+
> programs. See http://www.gtkmm.org/ and the information, tutorials, and
> books recommended therein. (The book recommendations contain books for
> related things, too, so make sure you know what you're buying. For
> example, The C++ Programming Language by Bjarne Stroustrup is an awesome
> book for learning C++ -- provided that you already have a general
> knowledge of computer programming topics, as this book is certainly not
> written with absolute beginners in mind -- but The C++ Programming
> Language doesn't actually teach you how to apply your C++ skills to
> using the gtkmm framework.) You don't *necessarily* have to buy a book
> at all--the resources at http://www.gtkmm.org/en/documentation.html are
> very good.
>
> The second most popular portable GUI framework is Qt (see
> http://en.wikipedia.org/wiki/Qt_(framework) and http://qt.nokia.com/).
> Another popular framework is wxWidgets (see
> http://en.wikipedia.org/wiki/Wxwidgets and http://wxwidgets.org/).
>
> --
> If this answers your question, please go to the following page to let us
> know that it is solved:
> https://answers.launchpad.net/ubuntu/+question/147943/+confirm?answer_id=3
>
> If you still need help, you can reply to this email or go to the
> following page to enter your feedback:
> https://answers.launchpad.net/ubuntu/+question/147943
>
> You received this question notification because you are a direct
> subscriber of the question.
>

Ubfan (ubfan1) said : #6

Sounds like you would be interested in the ncurses functionality. Google it, I didn't see much in the man pages on Ubuntu.

mycae (mycae) said : #7

For writing small 2D games, I would recommend SDL; although I believe we already started going down this road in a different question.

There are good resources on SDL at the game programming wiki.
http://gpwiki.org/index.php/Main_Page

prasad.ram (prasad-ram126) said : #8

sir i think you miss under stand what i mean ?you said that related to 2D
graphics which i don't want ?ok leave it
i explain one problem

                          12 15 6 7
                          14 13 11 9
                          1 2 5 3
                          4 8 10 _

here is the game it consists of 4 rows and 4 columns and at 4th row 4th
column we have a blank
you arrange them into ascending order by using arrow keys and the answers
is like this

                           1 2 3 4
                           5 6 7 8
                           9 10 11 12
                          13 14 15 _
for that purpose i am asking how to code for arrow keys actually in
windows(turbo c ) we use interrupts but i am very much interested in ubuntu
so please tell me how to write interrupts ?

On Tue, Mar 8, 2011 at 3:03 AM, mycae
<email address hidden>wrote:

> Your question #147943 on Ubuntu changed:
> https://answers.launchpad.net/ubuntu/+question/147943
>
> Status: Open => Answered
>
> mycae proposed the following answer:
> For writing small 2D games, I would recommend SDL; although I believe we
> already started going down this road in a different question.
>
> There are good resources on SDL at the game programming wiki.
> http://gpwiki.org/index.php/Main_Page
>
> --
> If this answers your question, please go to the following page to let us
> know that it is solved:
> https://answers.launchpad.net/ubuntu/+question/147943/+confirm?answer_id=6
>
> If you still need help, you can reply to this email or go to the
> following page to enter your feedback:
> https://answers.launchpad.net/ubuntu/+question/147943
>
> You received this question notification because you are a direct
> subscriber of the question.
>

prasad.ram (prasad-ram126) said : #9

sir i am waiting for your answer please send me as a possible
once i want to explain my program
we display the numbers as shown below

                         12 15 6 7
                         14 13 11 9
                         1 2 5 3
                         4 8 10 _

then if you press up arrow 3 and _ will swap or exchange i.e is like this

                         12 15 6 7
                         14 13 11 9
                         1 2 5 _
                         4 8 10 3

i want to implement arrow keys what are the basics if it is xp we write an
interrupts i am so interested in unix so please tell me

On Tue, Mar 8, 2011 at 11:24 PM, prasad.ram <
<email address hidden>> wrote:

> Your question #147943 on Ubuntu changed:
> https://answers.launchpad.net/ubuntu/+question/147943
>
> Status: Answered => Open
>
> You are still having a problem:
> sir i think you miss under stand what i mean ?you said that related to 2D
> graphics which i don't want ?ok leave it
> i explain one problem
>
>
> 12 15 6 7
> 14 13 11 9
> 1 2 5 3
> 4 8 10 _
>
> here is the game it consists of 4 rows and 4 columns and at 4th row 4th
> column we have a blank
> you arrange them into ascending order by using arrow keys and the answers
> is like this
>
> 1 2 3 4
> 5 6 7 8
> 9 10 11 12
> 13 14 15 _
> for that purpose i am asking how to code for arrow keys actually in
> windows(turbo c ) we use interrupts but i am very much interested in ubuntu
> so please tell me how to write interrupts ?
>
>
> On Tue, Mar 8, 2011 at 3:03 AM, mycae
> <email address hidden>wrote:
>
> > Your question #147943 on Ubuntu changed:
> > https://answers.launchpad.net/ubuntu/+question/147943
> >
> > Status: Open => Answered
> >
> > mycae proposed the following answer:
> > For writing small 2D games, I would recommend SDL; although I believe we
> > already started going down this road in a different question.
> >
> > There are good resources on SDL at the game programming wiki.
> > http://gpwiki.org/index.php/Main_Page
> >
> > --
> > If this answers your question, please go to the following page to let us
> > know that it is solved:
> >
> https://answers.launchpad.net/ubuntu/+question/147943/+confirm?answer_id=6
> >
> > If you still need help, you can reply to this email or go to the
> > following page to enter your feedback:
> > https://answers.launchpad.net/ubuntu/+question/147943
> >
> > You received this question notification because you are a direct
> > subscriber of the question.
> >
>
> --
> You received this question notification because you are a direct
> subscriber of the question.
>

mycae (mycae) said : #10

If you want an easy, but non-portable solution, you can just cheat and pass the terminal clear codes (VT100 code) to the print function to erase a line, like this guy has done:

http://projects.ericshalov.com/tools/cursor.c

Alternatively, as mentioned by someone else, try looking at the "ncurses" library. I have linked to the how-to guide for it here:
http://www.tldp.org/HOWTO/NCURSES-Programming-HOWTO/init.html

you can install the development component of the library (and the library itself) with

sudo apt-get install ncurses-dev

prasad.ram (prasad-ram126) said : #11

sir please send me reply

On Sun, Mar 13, 2011 at 5:49 AM, marcobra (Marco Braida) <
<email address hidden>> wrote:

> Your question #147943 on gcc-defaults in ubuntu changed:
> https://answers.launchpad.net/ubuntu/+source/gcc-defaults/+question/147943
>
> Project: Ubuntu => gcc-defaults in ubuntu
>
> Summary changed to:
> terminate stay resident programs in ubuntu
>
> --
> You received this question notification because you are a direct
> subscriber of the question.
>

Best mycae (mycae) said : #12

We have replied as best we can. Indeed we have done everything but write the program for you -- that is for you to do, as it is a learning experience.

prasad.ram (prasad-ram126) said : #13

Thanks mycae, that solved my question.

prasad.ram (prasad-ram126) said : #14

i use the command for installing ncurses library which is given by you

admin@ramki:~$ sudo apt-get install ncurses-dev
[sudo] password for admin:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'libncurses5-dev' instead of 'ncurses-dev'
libncurses5-dev is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 314 not upgraded.
that means it is already installed
and i do a basic "hello world "program but it gives that

hello_world.c:(.text+0xa): undefined reference to `initscr'
hello_world.c:(.text+0x16): undefined reference to `printw'
hello_world.c:(.text+0x1b): undefined reference to `stdscr'
hello_world.c:(.text+0x23): undefined reference to `wrefresh'
hello_world.c:(.text+0x28): undefined reference to `stdscr'
hello_world.c:(.text+0x30): undefined reference to `wgetch'
hello_world.c:(.text+0x35): undefined reference to `endwin'
collect2: ld returned 1 exit status
i did not know about the program and the program is

#include <ncurses.h>
int main()
{
        initscr(); /* Start curses mode */
        printw("Hello World !!!"); /* Print Hello World */
        refresh(); /* Print it on to the real screen */
        getch(); /* Wait for user input */
        endwin(); /* End curses mode */
        return 0;
}
 and find this program in the given below link which was given by you
http://www.tldp.org/HOWTO/NCURSES-Programming-HOWTO/init.html
 i run this program because i want to know is it ncursess library installed
or not and how to use it please tell me what is the reason weather program
is wrong or it is not installed correctly

On Sun, Mar 13, 2011 at 5:01 AM, mycae <<email address hidden>
> wrote:

> Your question #147943 on Ubuntu changed:
> https://answers.launchpad.net/ubuntu/+question/147943
>
> Status: Open => Answered
>
> mycae proposed the following answer:
> If you want an easy, but non-portable solution, you can just cheat and
> pass the terminal clear codes (VT100 code) to the print function to
> erase a line, like this guy has done:
>
> http://projects.ericshalov.com/tools/cursor.c
>
>
> Alternatively, as mentioned by someone else, try looking at the "ncurses"
> library. I have linked to the how-to guide for it here:
> http://www.tldp.org/HOWTO/NCURSES-Programming-HOWTO/init.html
>
> you can install the development component of the library (and the
> library itself) with
>
> sudo apt-get install ncurses-dev
>
> --
> If this answers your question, please go to the following page to let us
> know that it is solved:
> https://answers.launchpad.net/ubuntu/+question/147943/+confirm?answer_id=9
>
> If you still need help, you can reply to this email or go to the
> following page to enter your feedback:
> https://answers.launchpad.net/ubuntu/+question/147943
>
> You received this question notification because you are a direct
> subscriber of the question.
>

You should post this as a separate question (https://answers.launchpad.net/ubuntu/+source/gcc-defaults/+addquestion) and, in addition to all the information provided above, please also provide the command you entered (which presumably starts with "gcc") to compile the program.

If you want people here to know about this new question, then after posting it, you could post a comment here with a link to the new question. But the topic of this question is really very general -- now you're asking about a highly specific problem building against ncurses, which is really a different topic.