Skip to content

Cross-compilation with MinGW GCC for Windows on Linux failsΒ #3659

@stephan-cr

Description

@stephan-cr

Describe your environment

I try to cross-compile opentelemetry-cpp 1.21.0 with MinGW GCC 13.2 for Windows on Linux. The underlying problem is still present on "main".

Steps to reproduce

Hard to tell generically, because the Opentelemetry-cpp's dependencies need to be cross-compiled as well. In my case I did it through Conan.

$ conan install conanfile.txt -pr:h mingw --build=missing -s:h build_type=Release
$ cmake -DWITH_OTLP_HTTP=ON -DWITH_OTLP_FILE=ON -DWITH_BENCHMARK=OFF -DWITH_EXAMPLES=OFF -DWITH_EXAMPLES_HTTP=OFF -DWITH_FUNC_TESTS=OFF -DBUILD_W3CTRACECONTEXT_TEST=OFF -DBUILD_TESTING=OFF -S . -B build --toolchain build/Release/generators/conan_toolchain.cmake -DCMAKE_PREFIX_PATH=build/Release/generators -DCMAKE_BUILD_TYPE=Release
$ cmake --build build

My conanfile.txt contains this

[requires]
protobuf/5.27.0
libcurl/[>=7.78.0 <9]
zlib/[>=1.2.11 <2]

[tool_requires]
protobuf/5.27.0

[generators]
CMakeDeps
CMakeToolchain

[layout]
cmake_layout

and my host profile contains:

[settings]
arch=x86_64
compiler=gcc
compiler.cppstd=14
compiler.libcxx=libstdc++11
compiler.threads=posix
compiler.version=13.3
os=Windows

[buildenv]
CC=x86_64-w64-mingw32-gcc-posix
CXX=x86_64-w64-mingw32-g++-posix
RANLIB=x86_64-w64-mingw32-ranlib
RC=x86_64-w64-mingw32-windres

[conf]
tools.build:compiler_executables={"c": "/usr/bin/x86_64-w64-mingw32-gcc-posix", "cpp": "/usr/bin/x86_64-w64-mingw32-g++-posix", "rc": "/usr/bin/x86_64-w64-mingw32-windres"}

What is the expected behavior?

"windows.h" should be all lowercase.

What is the actual behavior?

opentelemetry-cpp/exporters/otlp/src/otlp_file_client.cc:46:12: fatal error: Windows.h: No such file or directory
   46 | #  include <Windows.h>
      |            ^~~~~~~~~~~
compilation terminated.

Additional context

It's debatable whether this should be treated as a bug or feature request. Feel free to change this issue to a feature.

Changing all occurrences "Windows.h" made the code compile.

I could provide a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriage/acceptedIndicates an issue or PR is ready to be actively worked on.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions