Skip to content

Compilation failure for odbc on Windows 11 ARM64 (aarch64) due to MultiByteToWideChar type mismatch in nanodbc.cpp #966

@denis-or

Description

@denis-or

The installation of the odbc package consistently fails when attempting to compile the C++ source code, both for the stable CRAN version and the development version from GitHub.

The error occurs during the compilation of the nanodbc/nanodbc.cpp file, specifically at the call to the Windows API function MultiByteToWideChar. The compiler (aarch64-w64-mingw32.static.posix-clang++) reports a type mismatch between the type nanodbc is providing (char16_t *) and the type expected by the system header (LPWSTR, which is defined as wchar_t *).

This suggests an issue with the definition or handling of wide character types (UTF-8/Wide Char) within the specific context of the ARM64 compilation toolchain.

Operating System Windows 11 Home
CPU Architecture ARM64 / Snapdragon (Asus Vivobook S5)
R Version R 4.5.2 aarch64 (Native ARM64 installation)
Compilation Toolchain Rtools45-aarch64 (or the installed aarch64 version)
R Package Attempted odbc (both CRAN version and r-dbi/odbc)
Installation Method install.packages("odbc") and/or pak::pak("r-dbi/odbc")

`> pak::pak("r-dbi/odbc")
✔ Loading metadata database ... done

→ Will install 1 package.
→ Will download 1 package with unknown size.

  • odbc 1.6.3.9000 [bld][cmp][dl] (GitHub: c8a2e26)
    ℹ Getting 1 pkg with unknown size
    ✔ Got odbc 1.6.3.9000 (source) (982.68 kB)
    ✔ Downloaded 1 package (982.68 kB) in 901ms
    ℹ Packaging odbc 1.6.3.9000
    ✔ Packaged odbc 1.6.3.9000 (3.1s)
    ℹ Building odbc 1.6.3.9000
    ✖ Failed to build odbc 1.6.3.9000 (22s)
    Error:
    ! error in pak subprocess
    Caused by error in stop_task_build(state, worker):
    ! Failed to build source package odbc.
    Full installation output:
  • installing source package 'odbc' ...
    ** this is package 'odbc' version '1.6.3.9000'
    staged installation is only possible with locking
    ** using non-staged installation
    ** libs
    aarch64-w64-mingw32.static.posix-clang++ -std=gnu++17 -O2 -Wall -Wall -pedantic -fdiagnostics-color=always -Wall -Iinclude -std=c++11 -pthread -O -fPIC -MMD -c -o time_zone_if.o src/time_zone_if.cc
    aarch64-w64-mingw32.static.posix-clang++ -std=gnu++17 -O2 -Wall -Wall -pedantic -fdiagnostics-color=always -Wall -Iinclude -std=c++11 -pthread -O -fPIC -MMD -c -o time_zone_impl.o src/time_zone_impl.cc
    aarch64-w64-mingw32.static.posix-clang++ -std=gnu++17 -O2 -Wall -Wall -pedantic -fdiagnostics-color=always -Wall -Iinclude -std=c++11 -pthread -O -fPIC -MMD -c -o time_zone_info.o src/time_zone_info.cc
    aarch64-w64-mingw32.static.posix-clang++ -std=gnu++17 -O2 -Wall -Wall -pedantic -fdiagnostics-color=always -Wall -Iinclude -std=c++11 -pthread -O -fPIC -MMD -c -o time_zone_libc.o src/time_zone_libc.cc
    aarch64-w64-mingw32.static.posix-clang++ -std=gnu++17 -O2 -Wall -Wall -pedantic -fdiagnostics-color=always -Wall -Iinclude -std=c++11 -pthread -O -fPIC -MMD -c -o time_zone_lookup.o src/time_zone_lookup.cc
    aarch64-w64-mingw32.static.posix-clang++ -std=gnu++17 -O2 -Wall -Wall -pedantic -fdiagnostics-color=always -Wall -Iinclude -std=c++11 -pthread -O -fPIC -MMD -c -o time_zone_posix.o src/time_zone_posix.cc
    aarch64-w64-mingw32.static.posix-ar -rv libcctz.a time_zone_fixed.o time_zone_format.o time_zone_if.o time_zone_impl.o time_zone_info.o time_zone_libc.o time_zone_lookup.o time_zone_posix.o
    C:/rtools45-aarch64/aarch64-w64-mingw32.static.posix/bin/llvm-ar.exe: warning: creating libcctz.a
    make[1]: Leaving directory '/c/Users/catop/AppData/Local/Temp/RtmpS2ZCUj/R.INSTALL76c81661fb/odbc/src/cctz'
    aarch64-w64-mingw32.static.posix-clang++ -std=gnu++17 -I"C:/PROGRA1/R-AARC1/R-451.1/include" -DNDEBUG -I'C:/Users/catop/AppData/Local/R/aarch64-library/4.5/Rcpp/include' -I"C:/rtools45-aarch64/aarch64-w64-mingw32.static.posix/include" -I. -Icctz/include -Inanodbc -O2 -Wall -Wall -pedantic -fdiagnostics-color=always -c odbc_result.cpp -o odbc_result.o
    aarch64-w64-mingw32.static.posix-clang++ -std=gnu++17 -I"C:/PROGRA
    1/R-AARC1/R-451.1/include" -DNDEBUG -I'C:/Users/catop/AppData/Local/R/aarch64-library/4.5/Rcpp/include' -I"C:/rtools45-aarch64/aarch64-w64-mingw32.static.posix/include" -I. -Icctz/include -Inanodbc -O2 -Wall -Wall -pedantic -fdiagnostics-color=always -c connection.cpp -o connection.o
    aarch64-w64-mingw32.static.posix-clang++ -std=gnu++17 -I"C:/PROGRA1/R-AARC1/R-45~1.1/include" -DNDEBUG -I'C:/Users/catop/AppData/Local/R/aarch64-library/4.5/Rcpp/include' -I"C:/rtools45-aarch64/aarch64-w64-mingw32.static.posix/include" -I. -Icctz/include -Inanodbc -O2 -Wall -Wall -pedantic -fdiagnostics-color=always -DNANODBC_OVERALLOCATE_CHAR -c nanodbc/nanodbc.cpp -o nanodbc.o
    nanodbc/nanodbc.cpp:371:5: error: no matching function for call to 'MultiByteToWideChar'
    371 | MultiByteToWideChar(CP_UTF8, 0, &in[0], static_cast(in.size()), &out[0], size_needed);
    | ^~~~~~~~~~~~~~~~~~~
    C:/rtools45-aarch64/aarch64-w64-mingw32.static.posix/include/stringapiset.h:41:25: note: candidate function not viable: no known conversion from 'value_type *' (aka 'char16_t *') to 'LPWSTR' (aka 'wchar_t *') for 5th argument
    41 | WINBASEAPI int WINAPI MultiByteToWideChar (UINT CodePage, DWORD dwFlags, LPCCH lpMultiByteStr, int cbMultiByte, LPWSTR lpWideCharStr, int cchWideChar);
    | ^ ~~~~~~~~~~~~~~~~~~~~
    1 error generated.
    make: *** [Makevars.win:17: nanodbc.o] Error 1
    ERROR: compilation failed for package 'odbc'
  • removing 'C:/Users/catop/AppData/Local/Temp/Rtmpcr9MP0/pkg-lib2a346bef31f/odbc'`

Any suggests?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions