C - MADV_HUGEPAGE 编译错误

标签 c gcc compiler-errors

我试图编译一些 C 代码,只需一个命令就可以在 Linux 上正常工作。

./autogen.sh && ./configure && make

我需要为 Windows 编译它,所以我安装了 cygwin 和我能想到的所有依赖项,现在我收到编译错误。 (make 时出错)。

-cpu-miner.o `test -f 'cpu-miner.c' || echo './'`cpu-miner.c
cpu-miner.c: In function ‘miner_thread’:
cpu-miner.c:1056:139: error: ‘MAP_HUGETLB’ undeclared (first use in this function)
   persistentctx = (struct cryptonight_ctx *)mmap(0, sizeof(struct cryptonight_ctx), PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB | MAP_POPULATE, 0, 0);
                                                                                                                                           ^
cpu-miner.c:1056:139: note: each undeclared identifier is reported only once for each function it appears in
cpu-miner.c:1056:153: error: ‘MAP_POPULATE’ undeclared (first use in this function)
   persistentctx = (struct cryptonight_ctx *)mmap(0, sizeof(struct cryptonight_ctx), PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB | MAP_POPULATE, 0, 0);
                                                                                                                                                         ^
cpu-miner.c:1058:88: error: ‘MADV_HUGEPAGE’ undeclared (first use in this function)
   madvise(persistentctx, sizeof(struct cryptonight_ctx), MADV_RANDOM | MADV_WILLNEED | MADV_HUGEPAGE);
                                                                                        ^
make[2]: *** [Makefile:563: minerd-cpu-miner.o] Error 1

完整代码在这里: https://github.com/wolf9466/cpuminer-multi

按照项目依赖项所述,我使用 gcc、ming-w64、libcurl 和 openssl 安装了 Cygwin,但我被难住了。

(我确实对代码进行了更改以进行优化,但它们是数学上的调整,并且在 Linux 上运行良好,所以我认为这不是问题。)

编辑 1

现在可以编译了!我删除了大页面并编译了它 - 但它是一个具有 .exe 文件名的 Linux 可执行文件。它需要 cygwin dll 才能运行。

最佳答案

“hugepage”功能特定于 Linux,在 Cygwin 中不可用。

关于C - MADV_HUGEPAGE 编译错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38277297/

相关文章:

c - SQLException : Invalid column name 'CreateRequestViewModelRequestId'

c - 在 C 中创建图形的替代方法

c - printf 字符串,可变长度项

gcc - (奇怪?)GCC 预处理器行为

linux - 在 Ubuntu 服务器 12.04.4 上编译 Node.js v0.11.12-release 错误

C程序打印数组中的错误字符

c - GCC 变量在本地范围内未初始化

c - 如何消除一个多余的宏参数

c - ':' token 之前应为 ',' 、 ';' 、 '}' 、 '__attribute__' 或 '='

compiler-errors - TypeScript 编译器不显示 TypeError