0

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

LeaG
  • 13
  • 2
  • ***See `config.log' for more details*** What does the config.log tell you? – drescherjm Jun 08 '23 at 14:45
  • Did you do this step: `C:\Program Files (x86)\Microsoft Visual Studio 14\VC\bin\x86_amd64\vcvarsx86_amd64.bat` The path will be different for VS2022: `"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsamd64_x86.bat"` – drescherjm Jun 08 '23 at 14:49
  • `./configure: line 3097: cl: command not found` looks to be the problem as it says the the msvc compiler can not be found.. I believe my second comment is very relevant. It does not seem like you executed the `vcvarsamd64_x86.bat` script that sets environment variables that will allow for the compiler to be found. – drescherjm Jun 08 '23 at 15:01
  • Since you are using powershell instead of cmd.exe this question may be the real problem: [https://stackoverflow.com/questions/2124753/how-can-i-use-powershell-with-the-visual-studio-command-prompt](https://stackoverflow.com/questions/2124753/how-can-i-use-powershell-with-the-visual-studio-command-prompt) – drescherjm Jun 08 '23 at 15:04
  • @drescherjm Thank you! It seems to have built and installed, though I don't know how to use the library in my VS project. `using icu::UnicodeString;` and the like does not work. Neither does `include ` and the like. I am still new so maybe I just don't understand how using libraries works. (I am used to python where installing is extremely simplified as you probably know.) – LeaG Jun 08 '23 at 16:29
  • I expect its the same as any other library. Add entries for your `"C/C++->General->Additional Include Directories"` and add the required libraries in your `Linker->Input` also remember the msvc configurations (Release, Debug ...) are separate and usually there are different libraries for Debug and Release because these 2 configurations are incompatible with each other. – drescherjm Jun 08 '23 at 16:45
  • @drescherjm I have now done this (https://imgur.com/a/17QbxsV) though I still can't use the library. – LeaG Jun 08 '23 at 18:40
  • It's very odd to have the same folder for the "Additional Include Directories" and "Additional Library Directories" I am not sure that is correct. – drescherjm Jun 08 '23 at 18:43
  • @drescherjm Okay, I just realised that vcpkg can do it for me, I probably misspelled it before. Also, the user guide does not mention it what so ever, so that isn't helpful. Anyway, that fixed it so that's fine. – LeaG Jun 08 '23 at 19:10
  • Contrary to the posted answer, there is no reason to get Cygwin involved here – ICU has come with Windows [for a few years now](https://learn.microsoft.com/en-us/windows/win32/intl/international-components-for-unicode--icu-)... If you're using VS, on Windows, there's nothing to build or install; just include the header and add `icu.lib` to your linker inputs. – ildjarn Jun 11 '23 at 06:12

1 Answers1

-1

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

matzeri
  • 8,062
  • 2
  • 15
  • 16