pocoproject / poco

The POCO C++ Libraries are powerful cross-platform C++ libraries for building network- and internet-based applications that run on desktop, server, mobile, IoT, and embedded systems.
https://pocoproject.org
Other
8.04k stars 2.11k forks source link

MacOS ARM64 build error: symbol `fdopen` is duplicated defined #4586

Closed JackyWoo closed 2 weeks ago

JackyWoo commented 2 weeks ago

Describe the bug Env: MacOS 14.4.1 ARM64 clang 18, build project with cmake.

symbol fdopen is duplicated defined.

In file included from /Users/wujianchao5/project/jd/poco/Foundation/src/zutil.c:10:
In file included from /Users/wujianchao5/project/jd/poco/Foundation/src/gzguts.h:21:
/Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk/usr/include/stdio.h:220:7: error: expected identifier or '('
  220 | FILE    *fdopen(int, const char *) __DARWIN_ALIAS_STARTING(__MAC_10_6, __IPHONE_2_0, __DARWIN_ALIAS(fdopen));
      |          ^
/Users/wujianchao5/project/jd/poco/Foundation/src/zutil.h:147:33: note: expanded from macro 'fdopen'
  147 | #        define fdopen(fd,mode) NULL /* No fdopen() */
      |                                 ^
/opt/homebrew/Cellar/llvm/18.1.6/lib/clang/18/include/__stddef_null.h:26:16: note: expanded from macro 'NULL'
   26 | #define NULL ((void*)0)
      |                ^
In file included from /Users/wujianchao5/project/jd/poco/Foundation/src/zutil.c:10:
In file included from /Users/wujianchao5/project/jd/poco/Foundation/src/gzguts.h:21:
/Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk/usr/include/stdio.h:220:7: error: expected ')'
/Users/wujianchao5/project/jd/poco/Foundation/src/zutil.h:147:33: note: expanded from macro 'fdopen'
  147 | #        define fdopen(fd,mode) NULL /* No fdopen() */
      |                                 ^
/opt/homebrew/Cellar/llvm/18.1.6/lib/clang/18/include/__stddef_null.h:26:16: note: expanded from macro 'NULL'
   26 | #define NULL ((void*)0)
andrewauclair commented 2 weeks ago

Looks like this is also zlib. You could try setting POCO_UNBUNDLED and provide your own version of zlib and use the latest available from their repo to see if it solves the issue.

JackyWoo commented 2 weeks ago

@andrewauclair thanks for your suggestion. I tried to build zlib in my Mac and it successed. So I suggest to update zlib version in Poco. What do you think.

/cc @aleks-f

matejk commented 2 weeks ago

Automated compile and testrun actions on GitHub (M1 MacOS 14.5, Apple clang version 15.0.0 (clang-1500.3.9.4) complete just fine just fine.

https://github.com/pocoproject/poco/actions/runs/9463808045/job/26069810114

I also just tested again the code from branch 1.13.3 on my M1 MacBook Pro and did not see any issues that you report.

matejk commented 2 weeks ago

Where did you install clang 18 from?

Latest XCode 15.4 installs clang 15.

JackyWoo commented 2 weeks ago

I use regular clang but not apple clang. I installed it by brew install llvm@18.

matejk commented 2 weeks ago

I recommend to switch to clang provided by XCode.

JackyWoo commented 2 weeks ago

Thanks.
Actually I use Poco in my project RaftKeeper as a git submodule and RaftKeeper only support regular clang. I think maybe others may have the same issue.