0

我已经使用 Microsoft Visual Studio 2008 为 c++ 编译了 NTL inifite 精度整数算术库。我按照说明在此站点上使用 Visual Studio 界面而不是从命令提示符处进行了操作。实际上,我宁愿从命令提示符处执行此操作,但我不知道该怎么做。

无论如何,我编译了库,现在我想在命令提示符下使用该库编译一个程序。我正在尝试编译的程序已在 linux 系统上进行了测试,我在其中使用以下内容对其进行了编译

c++ -I/appl/htopopt/Linux_x86_64/NTL-5.4.2/include mpqs.cpp main.cpp -o main -L/appl/htopopt/Linux_x86_64/NTL-5.4.2/lib -lntl -L/appl/htopopt/Linux_x86_64/gmp-4.2.1/lib -lgmp -lm

没关系 gmp 的东西,我没有在 Windows 上安装它。这纯粹是一个可选的东西,可以让 NTL 运行得更快。无论如何,这在 linux 上运行良好。现在在 Windows 上我写了以下内容

cl /EHsc /I D:\Downloads\WinNTL-5_5_2\include mpqs.cpp main.cpp /link /LIBPATH:"D:\Documents\Visual Studio 2008\Projects\ntl\Debug"

但这会导致以下错误:

mpqs.cpp
mpqs.cpp(38) : error C2039: 'find_smooth_vals' : is not a member of 'QS'
        d:\desktop\qs\mpqs.h(12) : see declaration of 'QS'
mpqs.cpp(41) : error C2065: 'M' : undeclared identifier
mpqs.cpp(41) : error C2065: 'n' : undeclared identifier
mpqs.cpp(42) : error C2065: 'sieve_table' : undeclared identifier
mpqs.cpp(42) : error C2228: left of '.size' must have class/struct/union
        type is ''unknown-type''
mpqs.cpp(43) : error C2065: 'sieve_table' : undeclared identifier
mpqs.cpp(44) : error C2065: 'qx_table' : undeclared identifier
mpqs.cpp(44) : error C3861: 'test_smoothness': identifier not found
mpqs.cpp(45) : error C2065: 'smooth_indices' : undeclared identifier
mpqs.cpp(45) : error C2228: left of '.push_back' must have class/struct/union
        type is ''unknown-type''
main.cpp
Generating Code...

好像,我的mpqs.h文件没有包含在编译过程中?另外我不明白为什么它抱怨向量类型的 .push_back() ?

非常感谢您的帮助!

4

1 回答 1

0

mpqs.h 肯定包含在内,因为输出要求您参考它。

看到 MPQS.h 似乎没有包含在 NTL 库中……你写的吗?如果是这样,您可以发布代码吗?

另外,您不应该在构建中的某处包含库文件吗?

编辑:没有函数 find_smooth_values 那么为什么要让 MSVC 找到它呢?我不确定为什么在 GCC 下编译但它显然丢失了。我猜其他错误是由于这个错误引起的。错误告诉你一些事情。你应该听他们的。

push_back 失败是因为它不知道您尝试 push_back 的类型是什么。这又可能是由于 find_smooth_values 不存在这一事实造成的。尝试将函数原型添加到 QS 类中。这可能会解决您的所有问题。

至于库,在编译成功之前它不会使用该库。所以现在不要担心这个。进入那里并修复 MSVC 报告的错误!

于 2010-04-12T10:16:18.637 回答