[英]using ncurses without installing it
我正在開發一個使用 ncurses 的項目。 我想知道是否有辦法在不將其安裝在機器上的情況下使用該庫? 我的意思是,有沒有辦法擁有 .h 文件並在 makefile 中編譯它們並使用它們,而不是安裝它?
預先感謝您的回復
似乎您需要自己構建它,因此可以這樣做:
/usr/local
,但我假設您沒有管理員權限,因此您可以在您的主目錄中創建一個local
目錄。 cd ~ mkdir local
mkdir ~/repos cd ~/repos
ncurses
git clone https://github.com/mirror/ncurses.git cd ncurses
ncurses
local
目錄中,具有寬字符 (UTF-8) 和線程支持。 您可以嘗試其他選項(但請注意,它會影響目錄和庫的命名)。 它還配置ncurses
以創建靜態庫(這是默認設置)。 ./configure --prefix ~/local --enable-widec --with-pthread
構建和安裝:
make -j make -j install
你的~/local
目錄現在應該是這樣的:
bin include lib share
編譯自己的程序時,添加-I ~/local/include -I ~/local/include/ncursestw -L ~/local/lib
到命令行。 請注意目錄上的t
(用於線程)和w
(用於寬)。
鏈接時,您需要鏈接ncursestw
、 dl
和pthread
。
例子:
g++ -I ~/local/include -I ~/local/include/ncursestw -L ~/local/lib \\ -o prog prog.cpp -lncursestw -ldl -pthread
請注意,與pthread
庫的鏈接最好使用-pthread
而不是-lpthread
(*)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.