英文:
How do I use/install ICU and make use of it in my C++ Visual Studio 2022 project?
问题
我对C++相当新,最近几天一直在尝试使用ICU库。我已经按照ICU GitHub上的这个指南进行了操作,但成果不大。
我发现可以在本机中使用#include <icu.h>
,但不确定它提供了什么功能,以及如何使用它,而且文件似乎已经剥离。这个页面讨论了在Windows上的使用情况,但不是特别具体。
我尝试按照GitHub上使用Cygwin的安装说明进行安装。安装VS2022似乎需要Cygwin。但是我未成功,输出如下:
PS C:\Users\user\Dev\ICU\icu\source> bash ./runConfigureICU Cygwin/MSVC
export CPP= CC=cl CXX=cl CPPFLAGS= CFLAGS=-Gy -MD CXXFLAGS=-Gy -MD LDFLAGS= MAKE=
Running ./configure for Windows with Cygwin using Microsoft Visual C++ compiler
checking for ICU version numbers... release 73.1, library 73.1, unicode version 15.0
checking build system type... x86_64-unknown-cygwin
checking host system type... x86_64-unknown-cygwin
checking whether to build debug libraries... no
checking whether to build release libraries... yes
checking whether the C compiler works... no
configure: error: in `/cygdrive/c/Users/user/Dev/ICU/icu/source':
configure: error: C compiler cannot create executables
See `config.log' for more details
./runConfigureICU: ./configure failed
config.log
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by ICU configure 73.1, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ ./configure
## --------- ##
## Platform. ##
## --------- ##
hostname = desktop
uname -m = x86_64
uname -r = 3.4.6-1.x86_64
uname -s = CYGWIN_NT-10.0-22621
uname -v = 2023-02-14 13:23 UTC
/usr/bin/uname -p = unknown
/bin/uname -X = unknown
/bin/arch = x86_64
/usr/bin/arch -k = unknown
/usr/convex/getsysinfo = unknown
/usr/bin/hostinfo = unknown
/bin/machine = unknown
/usr/bin/oslevel = unknown
/bin/universe = unknown
PATH: /cygdrive/c/Program Files/Eclipse Adoptium/jre-17.0.7.7-hotspot/bin
PATH: /cygdrive/c/windows/system32
PATH: /cygdrive/c/windows
PATH: /cygdrive/c/windows/System32/Wbem
PATH: /cygdrive/c/windows/System32/WindowsPowerShell/v1.0
PATH: /cygdrive/c/windows/System32/OpenSSH
PATH: /cygdrive/c/Program Files/Microsoft VS Code/bin
PATH: /cygdrive/c/Program Files/dotnet
PATH: /cygdrive/c/Program Files/Git/cmd
PATH: /usr/bin
PATH: /cygdrive/c/Program Files/CMake/bin
PATH: /cygdrive/c/Users/user/AppData/Local/Microsoft/WindowsApps
PATH: /cygdrive/c/Users/user/.dotnet/tools
## ----------- ##
## Core tests. ##
## ----------- ##
configure:2706: checking for ICU version numbers
configure:2739: result: release 73.1, library 73.1, unicode version 15.0
configure:2778: checking build system type
configure:2792: result: x86_64-unknown-cygwin
configure:2812: checking host system type
configure:2825: result: x86_64-unknown-cygwin
configure:2883: checking whether to build debug libraries
configure:2895: result: no
configure:2900: checking whether to build release libraries
configure:2912: result: yes
configure:3033: checking for C compiler version
configure:3042: cl --version >&5
./configure: line 3044: cl: command not found
...
(翻译结束,不包括代码部分。)
英文:
I am quite new to C++ and have been trying to use the ICU library for the past few days. I have followed this guide on the ICU GitHub, to little avail.
I found that I can #include <icu.h>
natively, but I am not sure what functionality that provides, and how to use it, and the file looks stripped. This page discusses how it is used on Windows, but it is not particularly specific.
I tried installing it following the instructions on GitHub with Cygwin. The installation for VS2022 seems to require Cygwin . I was unsuccessful, getting this output.
PS C:\Users\user\Dev\ICU\icu\source> bash ./runConfigureICU Cygwin/MSVC
export CPP= CC=cl CXX=cl CPPFLAGS= CFLAGS=-Gy -MD CXXFLAGS=-Gy -MD LDFLAGS= MAKE=
Running ./configure for Windows with Cygwin using Microsoft Visual C++ compiler
checking for ICU version numbers... release 73.1, library 73.1, unicode version 15.0
checking build system type... x86_64-unknown-cygwin
checking host system type... x86_64-unknown-cygwin
checking whether to build debug libraries... no
checking whether to build release libraries... yes
checking whether the C compiler works... no
configure: error: in `/cygdrive/c/Users/user/Dev/ICU/icu/source':
configure: error: C compiler cannot create executables
See `config.log' for more details
./runConfigureICU: ./configure failed
config.log
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by ICU configure 73.1, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ ./configure
## --------- ##
## Platform. ##
## --------- ##
hostname = desktop
uname -m = x86_64
uname -r = 3.4.6-1.x86_64
uname -s = CYGWIN_NT-10.0-22621
uname -v = 2023-02-14 13:23 UTC
/usr/bin/uname -p = unknown
/bin/uname -X = unknown
/bin/arch = x86_64
/usr/bin/arch -k = unknown
/usr/convex/getsysinfo = unknown
/usr/bin/hostinfo = unknown
/bin/machine = unknown
/usr/bin/oslevel = unknown
/bin/universe = unknown
PATH: /cygdrive/c/Program Files/Eclipse Adoptium/jre-17.0.7.7-hotspot/bin
PATH: /cygdrive/c/windows/system32
PATH: /cygdrive/c/windows
PATH: /cygdrive/c/windows/System32/Wbem
PATH: /cygdrive/c/windows/System32/WindowsPowerShell/v1.0
PATH: /cygdrive/c/windows/System32/OpenSSH
PATH: /cygdrive/c/Program Files/Microsoft VS Code/bin
PATH: /cygdrive/c/Program Files/dotnet
PATH: /cygdrive/c/Program Files/Git/cmd
PATH: /usr/bin
PATH: /cygdrive/c/Program Files/CMake/bin
PATH: /cygdrive/c/Users/user/AppData/Local/Microsoft/WindowsApps
PATH: /cygdrive/c/Users/user/.dotnet/tools
## ----------- ##
## Core tests. ##
## ----------- ##
configure:2706: checking for ICU version numbers
configure:2739: result: release 73.1, library 73.1, unicode version 15.0
configure:2778: checking build system type
configure:2792: result: x86_64-unknown-cygwin
configure:2812: checking host system type
configure:2825: result: x86_64-unknown-cygwin
configure:2883: checking whether to build debug libraries
configure:2895: result: no
configure:2900: checking whether to build release libraries
configure:2912: result: yes
configure:3033: checking for C compiler version
configure:3042: cl --version >&5
./configure: line 3044: cl: command not found
configure:3053: $? = 127
configure:3042: cl -v >&5
./configure: line 3044: cl: command not found
configure:3053: $? = 127
configure:3042: cl -V >&5
./configure: line 3044: cl: command not found
configure:3053: $? = 127
configure:3042: cl -qversion >&5
./configure: line 3044: cl: command not found
configure:3053: $? = 127
configure:3073: checking whether the C compiler works
configure:3095: cl -Gy -MD conftest.c >&5
./configure: line 3097: cl: command not found
configure:3099: $? = 127
configure:3137: result: no
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "ICU"
| #define PACKAGE_TARNAME "International Components for Unicode"
| #define PACKAGE_VERSION "73.1"
| #define PACKAGE_STRING "ICU 73.1"
| #define PACKAGE_BUGREPORT "http://icu-project.org/bugs"
| #define PACKAGE_URL "http://icu-project.org"
| /* end confdefs.h. */
|
| int
| main ()
| {
|
| ;
| return 0;
| }
configure:3142: error: in `/cygdrive/c/Users/user/Dev/ICU/icu/source':
configure:3144: error: C compiler cannot create executables
See `config.log' for more details
## ---------------- ##
## Cache variables. ##
## ---------------- ##
ac_cv_build=x86_64-unknown-cygwin
ac_cv_env_build_alias_set=
ac_cv_env_build_alias_value=
ac_cv_env_CC_set=set
ac_cv_env_CC_value=cl
ac_cv_env_CCC_set=
ac_cv_env_CCC_value=
ac_cv_env_CFLAGS_set=set
ac_cv_env_CFLAGS_value='-Gy -MD '
ac_cv_env_CPP_set=
ac_cv_env_CPP_value=
ac_cv_env_CPPFLAGS_set=
ac_cv_env_CPPFLAGS_value=
ac_cv_env_CXX_set=set
ac_cv_env_CXX_value=cl
ac_cv_env_CXXFLAGS_set=set
ac_cv_env_CXXFLAGS_value='-Gy -MD '
ac_cv_env_host_alias_set=
ac_cv_env_host_alias_value=
ac_cv_env_ICULEHB_CFLAGS_set=
ac_cv_env_ICULEHB_CFLAGS_value=
ac_cv_env_ICULEHB_LIBS_set=
ac_cv_env_ICULEHB_LIBS_value=
ac_cv_env_LDFLAGS_set=
ac_cv_env_LDFLAGS_value=
ac_cv_env_LIBS_set=
ac_cv_env_LIBS_value=
ac_cv_env_PKG_CONFIG_LIBDIR_set=
ac_cv_env_PKG_CONFIG_LIBDIR_value=
ac_cv_env_PKG_CONFIG_PATH_set=
ac_cv_env_PKG_CONFIG_PATH_value=
ac_cv_env_PKG_CONFIG_set=
ac_cv_env_PKG_CONFIG_value=
ac_cv_env_target_alias_set=
ac_cv_env_target_alias_value=
ac_cv_host=x86_64-unknown-cygwin
## ----------------- ##
## Output variables. ##
## ----------------- ##
ac_ct_CC=''
ac_ct_CXX=''
AR=''
ARFLAGS=''
bindir='${exec_prefix}/bin'
build_alias=''
build_cpu='x86_64'
build_os='cygwin'
build_vendor='unknown'
build='x86_64-unknown-cygwin'
CC='cl'
CFLAGS='-Gy -MD '
COMPILE_LINK_ENVVAR=''
CPP=''
CPPFLAGS=''
cross_buildroot=''
cross_compiling='no'
CXX='cl'
CXXFLAGS='-Gy -MD '
DATA_PACKAGING_MODE=''
DATA_TRUE=''
datadir='${datarootdir}'
datarootdir='${prefix}/share'
DEFS=''
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
DOXYGEN=''
dvidir='${docdir}'
ECHO_C=''
ECHO_N='-n'
ECHO_T=''
EGREP=''
ENABLE_DEBUG='0'
ENABLE_RELEASE='1'
ENABLE_RPATH=''
ENABLE_SHARED=''
ENABLE_STATIC=''
exec_prefix='NONE'
EXEEXT=''
EXTRAS_TRUE=''
FUZZER_TRUE=''
GENCCODE_ASSEMBLY=''
GREP=''
HAVE_MMAP=''
host_alias=''
host_cpu='x86_64'
host_os='cygwin'
host_vendor='unknown'
host='x86_64-unknown-cygwin'
htmldir='${docdir}'
ICU_ECHO_C=''
ICU_ECHO_N='-n'
ICU_ECHO_T=''
ICUDATA_CHAR=''
ICUIO_TRUE=''
ICULEHB_CFLAGS=''
ICULEHB_LIBS=''
ICULIBSUFFIX=''
ICULIBSUFFIXCNAME=''
includedir='${prefix}/include'
infodir='${datarootdir}/info'
INSTALL_DATA=''
INSTALL_ICU_CONFIG='true'
INSTALL_PROGRAM=''
INSTALL_SCRIPT=''
LAYOUTEX_TRUE=''
LDFLAGS=''
LIB_M=''
LIB_THREAD=''
LIB_VERSION_MAJOR='73'
LIB_VERSION='73.1'
LIBCFLAGS=''
LIBCXXFLAGS=''
libdir='${exec_prefix}/lib'
libexecdir='${exec_prefix}/libexec'
LIBOBJS=''
LIBS=''
localedir='${datarootdir}/locale'
localstatedir='${prefix}/var'
LTLIBOBJS=''
mandir='${datarootdir}/man'
OBJEXT=''
oldincludedir='/usr/include'
PACKAGE_BUGREPORT='http://icu-project.org/bugs'
PACKAGE_NAME='ICU'
PACKAGE_STRING='ICU 73.1'
PACKAGE_TARNAME='International Components for Unicode'
PACKAGE_URL='http://icu-project.org'
PACKAGE_VERSION='73.1'
PACKAGE='icu'
PATH_SEPARATOR=':'
pdfdir='${docdir}'
PKG_CONFIG_LIBDIR=''
PKG_CONFIG_PATH=''
PKG_CONFIG=''
pkgicudatadir=''
platform_make_fragment_name=''
platform_make_fragment=''
platform=''
PLUGINS_TRUE=''
prefix='NONE'
program_transform_name='s,x,x,'
psdir='${docdir}'
PYTHON=''
RANLIB=''
runstatedir='${localstatedir}/run'
SAMPLES_TRUE=''
sbindir='${exec_prefix}/sbin'
SED=''
sharedstatedir='${prefix}/com'
SHELL='/bin/sh'
sysconfdir='${prefix}/etc'
target_alias=''
TESTS_TRUE=''
thepkgicudatadir=''
TOOLS_TRUE=''
U_DEFAULT_SHOW_DRAFT=''
U_DISABLE_RENAMING=''
U_ENABLE_DYLOAD=''
U_ENABLE_TRACING=''
U_HAVE_DATA=''
U_HAVE_DIRENT_H=''
U_HAVE_EXTRAS=''
U_HAVE_FUZZER=''
U_HAVE_ICUIO=''
U_HAVE_INTTYPES_H=''
U_HAVE_LAYOUTEX=''
U_HAVE_LIB_SUFFIX=''
U_HAVE_NL_LANGINFO_CODESET=''
U_HAVE_PLACEMENT_NEW=''
U_HAVE_PLUGINS=''
U_HAVE_POPEN=''
U_HAVE_SAMPLES=''
U_HAVE_STRTOD_L=''
U_HAVE_TESTS=''
U_HAVE_TIMEZONE=''
U_HAVE_TOOLS=''
U_HAVE_TZNAME=''
U_HAVE_TZSET=''
U_HAVE_WCHAR_H=''
U_HAVE_WCSCPY=''
U_IS_BIG_ENDIAN=''
U_MAKE=''
U_NL_LANGINFO_CODESET=''
U_OVERRIDE_CXX_ALLOCATION=''
U_TIMEZONE=''
U_TZNAME=''
U_TZSET=''
UCLN_NO_AUTO_CLEANUP=''
UCONFIG_CFLAGS=''
UCONFIG_CPPFLAGS=''
UCONFIG_CXXFLAGS=''
UNICODE_VERSION='15.0'
VERSION='73.1'
## ----------- ##
## confdefs.h. ##
## ----------- ##
/* confdefs.h */
#define PACKAGE_NAME "ICU"
#define PACKAGE_TARNAME "International Components for Unicode"
#define PACKAGE_VERSION "73.1"
#define PACKAGE_STRING "ICU 73.1"
#define PACKAGE_BUGREPORT "http://icu-project.org/bugs"
#define PACKAGE_URL "http://icu-project.org"
configure: exit 77
答案1
得分: -1
ICU已经作为Cygwin包可用。
请查看最新的开发包内容:https://cygwin.com/packages/x86_64/libicu-devel/libicu-devel-72.1-1
没有理由将"C++ Visual Studio 2022"与"Cygwin"混合使用,而且可能会很繁琐(我不使用Visual Studio)。
Cygwin已经包含了所有必需的开发包:
gcc-core
gcc-c++
make
cmake
还有许多其他包。请查看完整列表:https://cygwin.com/packages/package_list.html
英文:
ICU is already available as Cygwin package
See content of the last development packages
https://cygwin.com/packages/x86_64/libicu-devel/libicu-devel-72.1-1
There is no reason to mix C++ Visual Studio 2022
with Cygwin
and it is likely cumbersome (I do not use Visual Studio).
Cygwin has already all needed packages for development:
gcc-core
gcc-c++
make
cmake
..
and many mores. See full list at
https://cygwin.com/packages/package_list.html
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论