Haskell 堆栈设置 - 无法识别 CPP 程序

Haskell Stack Setup - Can't Recognize CPP Program

我正在学习 Udemy Haskell 课程,其中有一次显示我可以使用 Stack 选项下载 Haskell。当我 运行 遇到问题时,我已经配置了我的 $PATH 和 运行 堆栈设置。

configure: WARNING: configure can't recognize your CPP program, you may need to set --with-hs-cpp-flags=FLAGS explicitly
configure: error: in `/Users/Dylan/.stack/programs/x86_64-osx/ghc-8.0.2.temp/ghc-8.0.2':
configure: error: C compiler cannot create executables

我调查了 .stack/programs/x86_64-osx/ghc-8.0.2.temp/ghc-8.0.2/config.log 并发现了这个...

configure:2234: checking for path to top of build tree
configure:2255: result: /Users/Dylan/.stack/programs/x86_64-osx/ghc-8.0.2.temp/$
configure:2981: checking for perl
configure:2999: found /usr/bin/perl
configure:3011: result: /usr/bin/perl
configure:3070: checking for a BSD-compatible install
configure:3138: result: /usr/bin/install -c
configure:3152: checking whether ln -s works
configure:3156: result: yes
configure:3168: checking for gsed
configure:3199: result: sed
configure:3211: checking XCode version
configure:3222: result: 8.3.3
configure:3226: XCode version component 1: 8
configure:3228: XCode version component 2: 3
configure:3263: checking for gcc
configure:3281: found /usr/bin/gcc
configure:3293: result: /usr/bin/gcc
configure:3573: WARNING: configure can't recognize your CPP program, you may ne$
configure:3623: checking for llc-3.7
configure:3656: result: no
configure:3739: checking for llc
configure:3772: result: no
configure:3872: checking for opt-3.7
configure:3905: result: no
configure:3988: checking for opt
configure:4021: result: no
configure:4120: checking for ld
configure:4138: found /usr/bin/ld
configure:4150: result: /usr/bin/ld
configure:4388: checking for gcc
configure:4415: result: /usr/bin/gcc
configure:4644: checking for C compiler version
configure:4653: /usr/bin/gcc --version >&5

我可以阅读 configure: WARNING: configure can't recognize your CPP program, you may need to set --with-hs-cpp-flags=FLAGS explicitly,但我不确定如何或在哪里阅读。我找到了我的 settings.in 文件...

[("GCC extra via C opts", "@GccExtraViaCOpts@"),
 ("C compiler command", "@SettingsCCompilerCommand@"),
 ("C compiler flags", "@SettingsCCompilerFlags@"),
 ("C compiler link flags", "@SettingsCCompilerLinkFlags@"),
 ("C compiler supports -no-pie", "@SettingsCCompilerSupportsNoPie@"),
 ("Haskell CPP command","@SettingsHaskellCPPCommand@"),
 ("Haskell CPP flags","@SettingsHaskellCPPFlags@"),
 ("ld command", "@SettingsLdCommand@"),
 ("ld flags", "@SettingsLdFlags@"),
 ("ld supports compact unwind", "@LdHasNoCompactUnwind@"),
 ("ld supports build-id", "@LdHasBuildId@"),
 ("ld supports filelist", "@LdHasFilelist@"),
 ("ld is GNU ld", "@LdIsGNULd@"),
 ("ar command", "@SettingsArCommand@"),
 ("ar flags", "@ArArgs@"),
 ("ar supports at file", "@ArSupportsAtFile@"),
 ("touch command", "@SettingsTouchCommand@"),
 ("dllwrap command", "@SettingsDllWrapCommand@"),
 ("windres command", "@SettingsWindresCommand@"),
 ("libtool command", "@SettingsLibtoolCommand@"),
 ("perl command", "@SettingsPerlCommand@"),
 ("cross compiling", "@CrossCompiling@"),
 ("target os", "@HaskellTargetOs@"),
 ("target arch", "@HaskellTargetArch@"),
 ("target word size", "@WordSize@"),
 ("target has GNU nonexec stack", "@HaskellHaveGnuNonexecStack@"),
 ("target has .ident directive", "@HaskellHaveIdentDirective@"),
 ("target has subsections via symbols", "@HaskellHaveSubsectionsViaSymbols@"),
 ("Unregisterised", "@Unregisterised@"),
 ("LLVM llc command", "@SettingsLlcCommand@"),
 ("LLVM opt command", "@SettingsOptCommand@")
 ]

但是,我又不知道如何处理它。对不起,如果我的问题很基础,但我以前没有做过类似的事情,而且我在网上找到的东西很难解释它如何适用于我的情况。

如有任何帮助,我们将不胜感激。

@n.m 评论 link 引导我找到一个问题的答案,建议我检查我的 xCode 列出的开发人员命令行工具版本。原来我的版本没问题,但后来我确实在 .stack/programs/x86_64-osx/ghc-8.0.2.temp/ghc-8.0.2/config.log 中找到了这一行,这让我找到了问题的解决方案。

Agreeing to the Xcode/iOS license requires admin privileges, please run “sudo xcodebuild -license” and then retry this command

sudo xcodebuild -license 让我 运行 stack install 成功了。