编译和使用NTL c++;Windows库 < >我用微软Visual Studio 2008编译了C++的NTL型IFNITE整数运算库。如前所述,我是在上使用VisualStudio界面,而不是从命令提示符执行的。实际上,我更愿意从命令提示符下执行,但我不知道如何执行

编译和使用NTL c++;Windows库 < >我用微软Visual Studio 2008编译了C++的NTL型IFNITE整数运算库。如前所述,我是在上使用VisualStudio界面,而不是从命令提示符执行的。实际上,我更愿意从命令提示符下执行,但我不知道如何执行,c++,visual-c++,ntl,C++,Visual C++,Ntl,总之,我编译了库,现在我想从命令提示符下使用库编译一个程序。我试图编译的程序已经在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 cl /E

总之,我编译了库,现在我想从命令提示符下使用库编译一个程序。我试图编译的程序已经在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
cl /EHsc /I D:\Downloads\WinNTL-5_5_2\include mpqs.cpp main.cpp /link /LIBPATH:"D:\Documents\Visual Studio 2008\Projects\ntl\Debug"
别担心gmp的东西,我没有在Windows上安装它。这纯粹是一个可选的东西,将使NTL运行得更快。无论如何,这在linux上运行良好。现在在Windows上,我写了以下内容

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
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()


非常感谢您的帮助

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

因为MPQS.h似乎没有包含在NTL库中。。。是你写的吗?如果是的话,你能把代码贴上去吗

另外,您不应该在构建中的某个地方包含库文件吗

编辑:没有函数find_smooth_值,为什么您希望MSVC找到它?我不知道为什么它会在GCC下编译,但它显然是缺失的。我猜其他的错误都是由这个引起的。错误告诉了你一些事情。你应该听他们的

push_back失败,因为它不知道您尝试将其推回的类型。这也可能是因为find_smooth_值不存在。尝试将函数原型添加到QS类中。这很可能会解决你所有的问题


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

是的,我编写了mpqs.h,它与mpqs.cpp和main.cpp位于同一个目录文件夹中(这是一个使用类mpqs的可运行文件)。我尝试在build命令的末尾添加“ntl.lib”,但它给了我同样的错误。我不确定我是否可以在评论中发布代码,但我将其粘贴到了这里:NTL已经过时了,请改用