首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >在mingw上使用ncursesw6

在mingw上使用ncursesw6
EN

Stack Overflow用户
提问于 2018-02-20 16:41:42
回答 1查看 5.5K关注 0票数 3

我试图在windows上使用ncursesw6来编译一个程序(mingw和msys)。

这个程序已经在linux上和windows上使用ncurses,但是今天我尝试修改它以使用新的ncursesw6,但是它没有工作。

我在makefile里试过这个:

代码语言:javascript
运行
复制
# -*- MakeFile -*-

# MACRO = substitute with this

# export

export  OS = linux
export  TST = false
export  DBG = false

 ifeq ($(OS), linux)
export  CC = gcc
export  CFLAGS = -std=c11 -O3 -march=native
export  LIBS = -l ncurses -l pthread -l m

 else
  ifeq ($(OS), win)
CFLAGS_NCURSESW = -D_XOPEN_SOURCE=500 -D_POSIX_C_SOURCE=199506L -I$(HOME)/ncurses6_mingw64/include/ncursesw -I$(HOME)/ncurses6_mingw64/include
LIBS_NCURSESW = -L$(HOME)/ncurses6_mingw64/lib -Wl,--enable-auto-import -lncursesw -lpsapi
export  CC = gcc.exe
export  CFLAGS = -std=c11 -O3 $(CFLAGS_NCURSESW)
export  LIBS = -lm $(LIBS_NCURSESW)
  endif
 endif

在制作的链接阶段,我得到了这些错误:

代码语言:javascript
运行
复制
make[1]: Entering directory `/home/LNV/EstDis-2.b.2/win'
gcc.exe -std=c11 -O3 -D_XOPEN_SOURCE=500 -D_POSIX_C_SOURCE=199506L -I /home/LNV/ncurses6_mingw64/include/ncursesw -I /home/LNV/ncurses6_mingw64/include ..//obj//main.o ..//libalx//obj//alx_file.o ..//libalx//obj//alx_getnum.o ..//libalx//obj//alx_math.o ..//libalx//obj//alx_ncur.o ..//modules//about//obj//about.o ..//modules//calc//obj//calc.o ..//modules//ctrl//obj//start.o ..//modules//tui//obj//dist.o ..//modules//tui//obj//menus.o -o estdis.exe -lm -L /home/LNV/ncurses6_mingw64/lib -Wl,--enable-auto-import -lncursesw -lpsapi
..//libalx//obj//alx_ncur.o:alx_ncur.c:(.text+0x4): undefined reference to `initscr'
..//libalx//obj//alx_ncur.o:alx_ncur.c:(.text+0x9): undefined reference to `nonl'
..//libalx//obj//alx_ncur.o:alx_ncur.c:(.text+0xe): undefined reference to `cbreak'

更多的错误意味着ncurses没有正确地联系起来(我认为)。

ncurses6_mingw64目录位于$HOME/

编辑:这是一棵$HOME树:

代码语言:javascript
运行
复制
/home/LNV$ tree
.
├── EstDis-2.b.2
│   ├── bin
│   │   ├── estdis
│   │   └── Makefile
│   ├── inc/
│   ├── libalx/
│   ├── LICENSE.txt
│   ├── Makefile
│   ├── modules/
│   ├── obj/
│   ├── README.txt
│   ├── src/
│   ├── tst/
│   └── win
│       └── Makefile
└── ncurses6_mingw64
    ├── bin
    │   ├── libformw6.dll
    │   ├── libmenuw6.dll
    │   ├── libncursesw6.dll
    │   ├── libpanelw6.dll
    │   └── ncursesw6-config
    ├── include
    │   └── ncursesw
    │       ├── curses.h
    │       ├── eti.h
    │       ├── form.h
    │       ├── menu.h
    │       ├── nc_mingw.h
    │       ├── nc_tparm.h
    │       ├── ncurses_dll.h
    │       ├── ncurses.h
    │       ├── ncurses_mingw.h
    │       ├── panel.h
    │       ├── termcap.h
    │       ├── term_entry.h
    │       ├── term.h
    │       ├── tic.h
    │       └── unctrl.h
    └── lib
        ├── libformw.a
        ├── libformw.dll.a
        ├── libmenuw.a
        ├── libmenuw.dll.a
        ├── libncursesw.a
        ├── libncursesw.dll.a
        ├── libpanelw.a
        └── libpanelw.dll.a

当我在msys上运行它时,ncursesw6_config告诉我们应该如何使用它(我认为它完全坏了):

代码语言:javascript
运行
复制
LNV@DESKTOP ~
$ ./ncurses6_mingw64/bin/ncursesw6-config
Usage: ncursesw6-config [options]

Options:
    --prefix    echos the package-prefix of ncursesw
    --exec-prefix   echos the executable-prefix of ncursesw

    --cflags    echos the C compiler flags needed to compile with ncursesw
    --libs      echos the libraries needed to link with ncursesw

    --version   echos the release+patchdate version of ncursesw
    --abi-version   echos the ABI version of ncursesw
    --mouse-version echos the mouse-interface version of ncursesw

    --bindir    echos the directory containing ncursesw programs
    --datadir   echos the directory containing ncursesw data
    --includedir    echos the directory containing ncursesw header files
    --libdir    echos the directory containing ncursesw libraries
    --mandir    echos the directory containing ncursesw manpages
    --terminfo  echos the $TERMINFO terminfo database path
    --terminfo-dirs echos the $TERMINFO_DIRS directory list
    --termpath  echos the $TERMPATH termcap list

    --help      prints this message

LNV@DESKTOP ~
$ ./ncurses6_mingw64/bin/ncursesw6-config  --cflags
-D_XOPEN_SOURCE=500 -D_POSIX_C_SOURCE=199506L -I/include/ncursesw -I/include

LNV@DESKTOP ~
$ ./ncurses6_mingw64/bin/ncursesw6-config  --libs
-L/lib -Wl,--enable-auto-import -lncursesw -lpsapi

$

我在前面添加了$HOME/ncursesw_mingw64 64/,因为很明显它是错误的,但其他部分,我照搬了它,因为我对它不太了解。

EDIT2: --我在makefile中对此进行了注释,但仍然给出了相同的错误:

代码语言:javascript
运行
复制
# -I$(HOME)/ncurses6_mingw64/include/ncursesw -I$(HOME)/ncurses6_mingw64/include

如果我将它更改为-I/include/ncursesw -I/include,这是配置告诉我的,错误是:

代码语言:javascript
运行
复制
..//src//alx_file.c:30:21: fatal error: curses.h: No such file or directory

出什么问题了?

解决了:使用提供的ncurses包并运行其配置文件来知道正确的CFLAGS和LIBS解决了问题。

然而,--我认为这将是一个单独的问题,但是有一个问题:我可以运行双击生成的.exe,但是msys无法运行它;当我做./win/estdis.exe时,它会给出一个问题:./win/estdis.exeError opening terminal: cygwin.

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-02-22 00:50:47

这似乎是从ncurses主页下载了一个示例交叉编译的构建。这些配置假设为典型的MinGW配置,其中/bin中有DLL,/include下有头部,/lib中有链接库。

可以从另一个位置使用它,但是您必须修改ncursesw6-config脚本以反映新的位置。另外,DLL必须位于$PATH上的某个目录中。如果不是,这可能不会干扰链接,但会阻止结果程序运行。

在脚本中,有这样一个部分:

代码语言:javascript
运行
复制
prefix=""
exec_prefix="${prefix}"

bindir="${exec_prefix}/bin"
includedir="${prefix}/include"
libdir="${exec_prefix}/lib"
datarootdir="${prefix}/share"
datadir="${datarootdir}"
mandir="${datarootdir}/man"

根据目录树的说明,您可能希望将第一行更改为

代码语言:javascript
运行
复制
prefix=/home/LNV/ncurses6_mingw64

再加上

代码语言:javascript
运行
复制
/home/LNV/ncurses6_mingw64/bin

到您的PATH环境变量。

顺便说一句,MinGW有一个用于ncurses的包,您可以考虑使用.

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48890109

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档