c - 在 Mac 上构建狡猾的国际象棋引擎

标签 c macos compilation

各位程序员,我从这里下载了 crafty http://craftychess.com/crafty-25.0.zip并尝试从命令行在 Mac(安装了 Xcode)上构建它。

我执行 make -j unix-clang 并得到以下错误:

error: *.profraw: No such file or directory
make[1]: *** [unix-clang] Error 1
make: *** [default] Error 2

在 Makefile 中 unix-clang 是这样定义的:

unix-clang:

@/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/llvm-profdata merge -output=crafty.profdata *.profraw
$(MAKE) -j target=UNIX \ 
    CC=clang CXX=clang++ \ 
    opt='-DTEST -DINLINEASM -DPOPCNT -DCPUS=4' \ 
    CFLAGS='-Wall -Wno-array-bounds -pipe -O3 \
        -fprofile-instr-use=crafty.profdata' \
    CXFLAGS='-Wall -Wno-array-bounds -pipe -O3 \
        -fprofile-instr-use=crafty.profdata' \
    LDFLAGS='$(LDFLAGS) -fprofile-use -lstdc++' \
    crafty-make

有人能帮忙吗?

我尝试用谷歌搜索这个问题,但我发现的所有内容都是针对 Windows 的。

谢谢

1 月 13 日更新:

$ make profile 生成以下内容:

/Applications/Xcode.app/Contents/Developer/usr/bin/make -j unix-clang-profile
/Applications/Xcode.app/Contents/Developer/usr/bin/make -j target=UNIX \
        CC=clang CXX=clang++ \
         opt='-DTEST -DINLINEASM -DPOPCNT -DCPUS=4' \
         CFLAGS='-Wall -Wno-array-bounds -pipe -O3 \
        -fprofile-instr-generate' \
         CXFLAGS='-Wall -Wno-array-bounds -pipe -O3 \
        -fprofile-instr-generate' \
         LDFLAGS=' -fprofile-instr-generate -lstdc++ ' \
        crafty-make
  clang -Wall -Wno-array-bounds -pipe -O3       
  -fprofile-instr-generate -DTEST -DINLINEASM -DPOPCNT -DCPUS=4 -DUNIX -c crafty.c
  clang++ -c -Wall -Wno-array-bounds -pipe -O3      
  -fprofile-instr-generate -DTEST -DINLINEASM -DPOPCNT -DCPUS=4 -DUNIX egtb.cpp
 clang -fprofile-instr-generate -lstdc++  -o crafty crafty.o egtb.o -lm  
 Illegal instruction
 make: *** [profile] Error 132

有什么想法吗?

最佳答案

使用:

$ make profile
$ ./crafty

看起来像是 Makefile 中的错误。

编辑:

您的 CPU 或操作系统不支持汇编代码,因此请更改 Makefile 中的以下行:

unix-clang:
...
opt='-DTEST -DINLINEASM -DPOPCNT -DCPUS=4' \
...

unix-clang:
...
opt='-DTEST -DCPUS=4' \
...

和改变

unix-clang-profile:
...
opt='-DTEST -DINLINEASM -DPOPCNT -DCPUS=4' \
...

unix-clang-profile:
...
opt='-DTEST -DCPUS=4' \
...

然后重做。您还应该阅读 Makefile 的顶部部分以获取其他信息。

关于c - 在 Mac 上构建狡猾的国际象棋引擎,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34754176/

相关文章:

c - 如何链接到C 中的静态库?

c - 文件按行作为字符串输入到数组中

objective-c - 变量是静态的,无需声明,所以,OSX iOS Apple 风格的 C 或 Obj-C?

xCode 8.x 崩溃并显示 "GameScene.sks"文件

objective-c - macOS 上的 Cocoa/Objective-C - 通过 keyDown 处理重音字符 :

arrays - 分配给数组时的编译错误 - VBA (Excel)

c - 使用 EXTERN 使用混合代码的引导加载程序

c - C语言十进制转二进制

c - 在带有多个 malloc() 的二维数组的指针上使用 free() 吗?

java - 通过命令行编译但不是在 ant 中