我试图在windows上使用ncursesw6来编译一个程序(mingw和msys)。
这个程序已经在linux上和windows上使用ncurses,但是今天我尝试修改它以使用新的ncursesw6,但是它没有工作。
我在makefile里试过这个:
# -*- 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
在制作的链接阶段,我得到了这些错误:
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树:
/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告诉我们应该如何使用它(我认为它完全坏了):
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中对此进行了注释,但仍然给出了相同的错误:
# -I$(HOME)/ncurses6_mingw64/include/ncursesw -I$(HOME)/ncurses6_mingw64/include
如果我将它更改为-I/include/ncursesw -I/include
,这是配置告诉我的,错误是:
..//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.exe
:Error opening terminal: cygwin.
发布于 2018-02-22 00:50:47
这似乎是从ncurses主页下载了一个示例交叉编译的构建。这些配置假设为典型的MinGW配置,其中/bin
中有DLL,/include
下有头部,/lib
中有链接库。
可以从另一个位置使用它,但是您必须修改ncursesw6-config
脚本以反映新的位置。另外,DLL必须位于$PATH
上的某个目录中。如果不是,这可能不会干扰链接,但会阻止结果程序运行。
在脚本中,有这样一个部分:
prefix=""
exec_prefix="${prefix}"
bindir="${exec_prefix}/bin"
includedir="${prefix}/include"
libdir="${exec_prefix}/lib"
datarootdir="${prefix}/share"
datadir="${datarootdir}"
mandir="${datarootdir}/man"
根据目录树的说明,您可能希望将第一行更改为
prefix=/home/LNV/ncurses6_mingw64
再加上
/home/LNV/ncurses6_mingw64/bin
到您的PATH
环境变量。
顺便说一句,MinGW有一个用于ncurses的包,您可以考虑使用.
https://stackoverflow.com/questions/48890109
复制相似问题