Compiler errors 编译对`u gmpz_mul_ui';的未定义代码块引用时出错;
所以我试图在这里以代码块的形式编译这段代码:Compiler errors 编译对`u gmpz_mul_ui';的未定义代码块引用时出错;,compiler-errors,codeblocks,gmp,Compiler Errors,Codeblocks,Gmp,所以我试图在这里以代码块的形式编译这段代码: #include <iostream> #include <gmpxx.h> using namespace std; void myfunction (mpz_t result, mpz_t param, unsigned long n) { unsigned long i; mpz_mul_ui (result, param, n); for (i = 1; i < n; i++) mpz
#include <iostream>
#include <gmpxx.h>
using namespace std;
void
myfunction (mpz_t result, mpz_t param, unsigned long n)
{
unsigned long i;
mpz_mul_ui (result, param, n);
for (i = 1; i < n; i++)
mpz_add_ui (result, result, i*7);
}
int
main (void)
{
mpz_t r, n;
mpz_init (r);
mpz_init_set_str (n, "123456", 0);
myfunction (r, n, 20L);
mpz_out_str (stdout, 10, r); printf ("\n");
return 0;
}
现在我已经在谷歌上调查了这个问题,但是我发现那些解决方案似乎不起作用
现在在项目>构建选项>搜索目录>链接器下,我有gmp-6.1.0的位置
我尝试将gmp放在项目>构建选项>链接器设置>其他链接器选项中,但是这不起作用,反而给了我以下信息:
-------------- Build: Debug in orcs (compiler: GNU GCC Compiler)---------------
mingw32-g++.exe -L..\..\Lzip\gmp-6.1.0 -L..\..\Lzip\gmp-6.1.0 -o bin\Debug\orcs.exe obj\Debug\main.o gmp ..\..\Lzip\mybuilddir\.libs\libgmpxx.a
mingw32-g++.exe: error: gmp: No such file or directory
Process terminated with status 1 (0 minute(s), 0 second(s))
1 error(s), 0 warning(s) (0 minute(s), 0 second(s))
我不确定问题出在哪里,因为我很确定所有的东西都安装在默认位置。希望这些信息足以帮助我:)我想你已经将
gmp-6.1.0
提取到。\..\Lzip\gmp-6.1.0
中,并在中构建了它。\..\Lzip\mybuilddir
。请在您的帖子中包含用于构建包的命令。这将使我更容易告诉您如何正确操作。您需要链接到libgmp.a
,而不仅仅是libgmpxx.a
。使用Cygwin,我可以将cd刻录到mybuilddir。然后我执行了以下命令“..\..\lzip\gmp-6.1.0\configure>make>makecheck>makeinstall。一切似乎都做对了,我没有看到任何错误。@Marglisse你能告诉我怎么做吗?如果您只需运行/configure;制作核对;进行安装
则您尚未配置为生成libgmpxx
。为此,您需要/配置--启用cxx
。你就是这么做的,或者你的“..\..\Lzip\mybuilddir\.libs\libgmpxx.a”是从哪里来的?我猜你把gmp-6.1.0
提取到。..\Lzip\gmp-6.1.0
中,并在中构建了它。..\Lzip\mybuilddir
。请在您的帖子中包含用于构建包的命令。这将使我更容易告诉您如何正确操作。您需要链接到libgmp.a
,而不仅仅是libgmpxx.a
。使用Cygwin,我可以将cd刻录到mybuilddir。然后我执行了以下命令“..\..\lzip\gmp-6.1.0\configure>make>makecheck>makeinstall。一切似乎都做对了,我没有看到任何错误。@Marglisse你能告诉我怎么做吗?如果您只需运行/configure;制作核对;进行安装
则您尚未配置为生成libgmpxx
。为此,您需要/配置--启用cxx
。你就是这么做的,或者你的`..\..\Lzip\mybuilddir\.libs\libgmpxx.a`来自哪里?
-------------- Build: Debug in orcs (compiler: GNU GCC Compiler)---------------
mingw32-g++.exe -L..\..\Lzip\gmp-6.1.0 -L..\..\Lzip\gmp-6.1.0 -o bin\Debug\orcs.exe obj\Debug\main.o gmp ..\..\Lzip\mybuilddir\.libs\libgmpxx.a
mingw32-g++.exe: error: gmp: No such file or directory
Process terminated with status 1 (0 minute(s), 0 second(s))
1 error(s), 0 warning(s) (0 minute(s), 0 second(s))