opendal icon indicating copy to clipboard operation
opendal copied to clipboard

bug: cpp bindings can not be compiled in windows

Open CNLHC opened this issue 7 months ago • 1 comments

Describe the bug

  1. c++ standard mismatch

Currently c++ 17 is used at https://github.com/apache/opendal/blob/193a30ec111ec4379b0124a58b63692d018773dc/bindings/cpp/CMakeLists.txt#L51

But Designated Initializers is c++ 20 feature.

https://github.com/apache/opendal/blob/193a30ec111ec4379b0124a58b63692d018773dc/bindings/cpp/src/operator.cpp#L38 https://github.com/apache/opendal/blob/193a30ec111ec4379b0124a58b63692d018773dc/bindings/cpp/src/utils/ffi_converter.cpp#L25

  1. target_link_libraries issue

On windows platform, some extra depdencies are linked to target using plain-style (without PRIVATE or PUBLIC) https://github.com/apache/opendal/blob/193a30ec111ec4379b0124a58b63692d018773dc/bindings/cpp/CMakeLists.txt#L174

But there exist several keyword-style linking. https://github.com/apache/opendal/blob/193a30ec111ec4379b0124a58b63692d018773dc/bindings/cpp/CMakeLists.txt#L174

Using both plain and keyword for the same target is not allowed in cmake

  1. path issue

Regular expression is used to handle path at

https://github.com/apache/opendal/blob/193a30ec111ec4379b0124a58b63692d018773dc/bindings/cpp/CMakeLists.txt#L86

On windows platform, the line terminator can be \r\n. Therefore this regex may generate wrong result with unexpected \r

Steps to Reproduce

Compiling the cpp bindings sample can reproduce this problem

Expected Behavior

cpp bindings sample should be compiled properly.

Additional Context

No response

Are you willing to submit a PR to fix this bug?

  • [x] Yes, I would like to submit a PR.

CNLHC avatar May 29 '25 23:05 CNLHC

I have recently received several reports about the opendal C++ binding on Windows. It might be time for us to introduce Windows CI support for C++.

Xuanwo avatar May 30 '25 01:05 Xuanwo