Reputation:
I am working on a project which uses ncurses. I am wondering if there is a way to use this library without installing it on a machine? What I mean is that instead of installing it, is there a way to have .h files and compile them in a makefile and use them?
Thank you in advanced for your response
Upvotes: 0
Views: 1818
Reputation: 117258
It seems like you need to build it yourself, so here's how it can be done:
/usr/local
, but I assume you don't have admin rights, so you can create a local
in your home directory instead.
cd ~
mkdir local
mkdir ~/repos
cd ~/repos
ncurses
git clone https://github.com/mirror/ncurses.git
cd ncurses
ncurses
local
directory, with wide character (UTF-8) and threading support. You can experiment with other options (but note that it'll effect the naming of the directories and libraries). It also configures ncurses
to create static libraries (it's the default).
./configure --prefix ~/local --enable-widec --with-pthread
Build and install:
make -j
make -j install
Your ~/local
directory should now look like this:
bin include lib share
When compiling your own programs, add
-I ~/local/include -I ~/local/include/ncursestw -L ~/local/lib
to the command line. Note the t
(for threads) and w
(for wide) on the directory.
When linking, you need to link with ncursestw
, dl
and pthread
.
Example:
g++ -I ~/local/include -I ~/local/include/ncursestw -L ~/local/lib \
-o prog prog.cpp -lncursestw -ldl -pthread
Note that linking with the pthread
library is best done with -pthread
not -lpthread
(*)
Upvotes: 3