如何在我的C++ Visual Studio 2022项目中使用/安装ICU并利用它?

huangapple go评论68阅读模式
英文:

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&gt; 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&#39;:
configure: error: C compiler cannot create executables
See `config.log&#39; 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 &gt;&amp;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 &lt;icu.h&gt; 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&gt; 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&#39;:
configure: error: C compiler cannot create executables
See `config.log&#39; 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 &gt;&amp;5
./configure: line 3044: cl: command not found
configure:3053: $? = 127
configure:3042: cl -v &gt;&amp;5
./configure: line 3044: cl: command not found
configure:3053: $? = 127
configure:3042: cl -V &gt;&amp;5
./configure: line 3044: cl: command not found
configure:3053: $? = 127
configure:3042: cl -qversion &gt;&amp;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  &gt;&amp;5
./configure: line 3097: cl: command not found
configure:3099: $? = 127
configure:3137: result: no
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME &quot;ICU&quot;
| #define PACKAGE_TARNAME &quot;International Components for Unicode&quot;
| #define PACKAGE_VERSION &quot;73.1&quot;
| #define PACKAGE_STRING &quot;ICU 73.1&quot;
| #define PACKAGE_BUGREPORT &quot;http://icu-project.org/bugs&quot;
| #define PACKAGE_URL &quot;http://icu-project.org&quot;
| /* end confdefs.h.  */
| 
| int
| main ()
| {
| 
|   ;
|   return 0;
| }
configure:3142: error: in `/cygdrive/c/Users/user/Dev/ICU/icu/source&#39;:
configure:3144: error: C compiler cannot create executables
See `config.log&#39; 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=&#39;-Gy -MD &#39;
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=&#39;-Gy -MD &#39;
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=&#39;&#39;
ac_ct_CXX=&#39;&#39;
AR=&#39;&#39;
ARFLAGS=&#39;&#39;
bindir=&#39;${exec_prefix}/bin&#39;
build_alias=&#39;&#39;
build_cpu=&#39;x86_64&#39;
build_os=&#39;cygwin&#39;
build_vendor=&#39;unknown&#39;
build=&#39;x86_64-unknown-cygwin&#39;
CC=&#39;cl&#39;
CFLAGS=&#39;-Gy -MD &#39;
COMPILE_LINK_ENVVAR=&#39;&#39;
CPP=&#39;&#39;
CPPFLAGS=&#39;&#39;
cross_buildroot=&#39;&#39;
cross_compiling=&#39;no&#39;
CXX=&#39;cl&#39;
CXXFLAGS=&#39;-Gy -MD &#39;
DATA_PACKAGING_MODE=&#39;&#39;
DATA_TRUE=&#39;&#39;
datadir=&#39;${datarootdir}&#39;
datarootdir=&#39;${prefix}/share&#39;
DEFS=&#39;&#39;
docdir=&#39;${datarootdir}/doc/${PACKAGE_TARNAME}&#39;
DOXYGEN=&#39;&#39;
dvidir=&#39;${docdir}&#39;
ECHO_C=&#39;&#39;
ECHO_N=&#39;-n&#39;
ECHO_T=&#39;&#39;
EGREP=&#39;&#39;
ENABLE_DEBUG=&#39;0&#39;
ENABLE_RELEASE=&#39;1&#39;
ENABLE_RPATH=&#39;&#39;
ENABLE_SHARED=&#39;&#39;
ENABLE_STATIC=&#39;&#39;
exec_prefix=&#39;NONE&#39;
EXEEXT=&#39;&#39;
EXTRAS_TRUE=&#39;&#39;
FUZZER_TRUE=&#39;&#39;
GENCCODE_ASSEMBLY=&#39;&#39;
GREP=&#39;&#39;
HAVE_MMAP=&#39;&#39;
host_alias=&#39;&#39;
host_cpu=&#39;x86_64&#39;
host_os=&#39;cygwin&#39;
host_vendor=&#39;unknown&#39;
host=&#39;x86_64-unknown-cygwin&#39;
htmldir=&#39;${docdir}&#39;
ICU_ECHO_C=&#39;&#39;
ICU_ECHO_N=&#39;-n&#39;
ICU_ECHO_T=&#39;&#39;
ICUDATA_CHAR=&#39;&#39;
ICUIO_TRUE=&#39;&#39;
ICULEHB_CFLAGS=&#39;&#39;
ICULEHB_LIBS=&#39;&#39;
ICULIBSUFFIX=&#39;&#39;
ICULIBSUFFIXCNAME=&#39;&#39;
includedir=&#39;${prefix}/include&#39;
infodir=&#39;${datarootdir}/info&#39;
INSTALL_DATA=&#39;&#39;
INSTALL_ICU_CONFIG=&#39;true&#39;
INSTALL_PROGRAM=&#39;&#39;
INSTALL_SCRIPT=&#39;&#39;
LAYOUTEX_TRUE=&#39;&#39;
LDFLAGS=&#39;&#39;
LIB_M=&#39;&#39;
LIB_THREAD=&#39;&#39;
LIB_VERSION_MAJOR=&#39;73&#39;
LIB_VERSION=&#39;73.1&#39;
LIBCFLAGS=&#39;&#39;
LIBCXXFLAGS=&#39;&#39;
libdir=&#39;${exec_prefix}/lib&#39;
libexecdir=&#39;${exec_prefix}/libexec&#39;
LIBOBJS=&#39;&#39;
LIBS=&#39;&#39;
localedir=&#39;${datarootdir}/locale&#39;
localstatedir=&#39;${prefix}/var&#39;
LTLIBOBJS=&#39;&#39;
mandir=&#39;${datarootdir}/man&#39;
OBJEXT=&#39;&#39;
oldincludedir=&#39;/usr/include&#39;
PACKAGE_BUGREPORT=&#39;http://icu-project.org/bugs&#39;
PACKAGE_NAME=&#39;ICU&#39;
PACKAGE_STRING=&#39;ICU 73.1&#39;
PACKAGE_TARNAME=&#39;International Components for Unicode&#39;
PACKAGE_URL=&#39;http://icu-project.org&#39;
PACKAGE_VERSION=&#39;73.1&#39;
PACKAGE=&#39;icu&#39;
PATH_SEPARATOR=&#39;:&#39;
pdfdir=&#39;${docdir}&#39;
PKG_CONFIG_LIBDIR=&#39;&#39;
PKG_CONFIG_PATH=&#39;&#39;
PKG_CONFIG=&#39;&#39;
pkgicudatadir=&#39;&#39;
platform_make_fragment_name=&#39;&#39;
platform_make_fragment=&#39;&#39;
platform=&#39;&#39;
PLUGINS_TRUE=&#39;&#39;
prefix=&#39;NONE&#39;
program_transform_name=&#39;s,x,x,&#39;
psdir=&#39;${docdir}&#39;
PYTHON=&#39;&#39;
RANLIB=&#39;&#39;
runstatedir=&#39;${localstatedir}/run&#39;
SAMPLES_TRUE=&#39;&#39;
sbindir=&#39;${exec_prefix}/sbin&#39;
SED=&#39;&#39;
sharedstatedir=&#39;${prefix}/com&#39;
SHELL=&#39;/bin/sh&#39;
sysconfdir=&#39;${prefix}/etc&#39;
target_alias=&#39;&#39;
TESTS_TRUE=&#39;&#39;
thepkgicudatadir=&#39;&#39;
TOOLS_TRUE=&#39;&#39;
U_DEFAULT_SHOW_DRAFT=&#39;&#39;
U_DISABLE_RENAMING=&#39;&#39;
U_ENABLE_DYLOAD=&#39;&#39;
U_ENABLE_TRACING=&#39;&#39;
U_HAVE_DATA=&#39;&#39;
U_HAVE_DIRENT_H=&#39;&#39;
U_HAVE_EXTRAS=&#39;&#39;
U_HAVE_FUZZER=&#39;&#39;
U_HAVE_ICUIO=&#39;&#39;
U_HAVE_INTTYPES_H=&#39;&#39;
U_HAVE_LAYOUTEX=&#39;&#39;
U_HAVE_LIB_SUFFIX=&#39;&#39;
U_HAVE_NL_LANGINFO_CODESET=&#39;&#39;
U_HAVE_PLACEMENT_NEW=&#39;&#39;
U_HAVE_PLUGINS=&#39;&#39;
U_HAVE_POPEN=&#39;&#39;
U_HAVE_SAMPLES=&#39;&#39;
U_HAVE_STRTOD_L=&#39;&#39;
U_HAVE_TESTS=&#39;&#39;
U_HAVE_TIMEZONE=&#39;&#39;
U_HAVE_TOOLS=&#39;&#39;
U_HAVE_TZNAME=&#39;&#39;
U_HAVE_TZSET=&#39;&#39;
U_HAVE_WCHAR_H=&#39;&#39;
U_HAVE_WCSCPY=&#39;&#39;
U_IS_BIG_ENDIAN=&#39;&#39;
U_MAKE=&#39;&#39;
U_NL_LANGINFO_CODESET=&#39;&#39;
U_OVERRIDE_CXX_ALLOCATION=&#39;&#39;
U_TIMEZONE=&#39;&#39;
U_TZNAME=&#39;&#39;
U_TZSET=&#39;&#39;
UCLN_NO_AUTO_CLEANUP=&#39;&#39;
UCONFIG_CFLAGS=&#39;&#39;
UCONFIG_CPPFLAGS=&#39;&#39;
UCONFIG_CXXFLAGS=&#39;&#39;
UNICODE_VERSION=&#39;15.0&#39;
VERSION=&#39;73.1&#39;
## ----------- ##
## confdefs.h. ##
## ----------- ##
/* confdefs.h */
#define PACKAGE_NAME &quot;ICU&quot;
#define PACKAGE_TARNAME &quot;International Components for Unicode&quot;
#define PACKAGE_VERSION &quot;73.1&quot;
#define PACKAGE_STRING &quot;ICU 73.1&quot;
#define PACKAGE_BUGREPORT &quot;http://icu-project.org/bugs&quot;
#define PACKAGE_URL &quot;http://icu-project.org&quot;
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

huangapple
  • 本文由 发表于 2023年6月8日 22:25:19
  • 转载请务必保留本文链接:https://go.coder-hub.com/76432861.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定