LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   how to create static applications with ncurses? (https://www.linuxquestions.org/questions/linux-software-2/how-to-create-static-applications-with-ncurses-463661/)

krmane 07-13-2006 09:35 AM

how to create static applications with ncurses?
 
hello,
I have a library specific question,
cound not figure out where to put this question so first of all I am sorry if this is the wrong place.
I am ready to be flaimed if this is the case but this is very urgent.
I am developing a customised slackware distro for my device. the device is a single board computer with samual c3 processor (intel compatible), 128 mb ddr ram and via chipset.
well, the problem is this.
I have used ncursis library to develop my program.
I will need to statically link my application with ncursis so that I don't need to coppy all that include files and the lib files.
I want to have a single executable in which the ncursis library is included.
it is going to be very difficult for me and tedious to copy all the headers and libraries.
if any one has done a similar thing please let me know how ncursis can be statically linked into my custom program.
thanks,
Krishnakant.

patrokov 07-13-2006 10:06 AM

From the ncurses programming guide: http://www.apmaths.uwo.ca/~xli/ncurses.html
Using ncurses library
To compile your C/C++ programs using ncurses/curses library you need to include the curses header file <curses.h>. For ncurses, you may include either <curses.h> or <ncurses.h>. In some systems, you must include <ncurses.h>.
Code:

#include <curses.h>
To link the programs you need to use the -lcurses or -lncurses option, like
Code:

gcc -lncurses prog.c
This way the program is dynamically linked to the ncurses library. To run it in another computer, the system must have the ncurses library installed. If you want to avoid the trouble, you may have it statically linked. To do that, find the file libncurses.a in /usr/lib and do
Code:

gcc prog.c libncurses.a


All times are GMT -5. The time now is 04:55 AM.