C - MADV_HUGEPAGE编译错误

时间:2016-07-09 01:10:41

标签: 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

现在编译!我删除了hugepages的东西并编译 - 但它是一个具有.exe文件名的Linux可执行文件。它需要cygwin dlls才能运行。

1 个答案:

答案 0 :(得分:1)

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