mpich2 visual studio 2013 linker error
mpich2 visual studio 2013 linker error
我想以c 方式使用mpi,所以我有mpich2的cxxpi.cxx代码:
#include "mpi.h"
#include <iostream>
#include <math.h>
using namespace std;
double f(double);
double f(double a) {
return (4.0 / (1.0 + a*a));
}
int main(int argc, char **argv) {
int n, myid, numprocs, i;
double PI25DT = 3.141592653589793238462643;
double mypi, pi, h, sum, x;
double startwtime = 0.0, endwtime;
int namelen;
char processor_name[MPI_MAX_PROCESSOR_NAME];
MPI::Init(argc, argv);
numprocs = MPI::COMM_WORLD.Get_size();
myid = MPI::COMM_WORLD.Get_rank();
MPI::Get_processor_name(processor_name, namelen);
cout << "Process " << myid << " of " << numprocs << " is on " <<
processor_name << endl;
n = 10000; /* default # of rectangles */
if (myid == 0)
startwtime = MPI::Wtime();
MPI::COMM_WORLD.Bcast(&n, 1, MPI_INT, 0);
h = 1.0 / (double) n;
sum = 0.0;
/* A slightly better approach starts from large i and works back */
for (i = myid + 1; i <= n; i += numprocs) {
x = h * ((double) i - 0.5);
sum += f(x);
}
mypi = h * sum;
MPI::COMM_WORLD.Reduce(&mypi, &pi, 1, MPI_DOUBLE, MPI_SUM, 0);
if (myid == 0) {
endwtime = MPI::Wtime();
cout << "pi is approximately " << pi << " Error is " <<
fabs(pi - PI25DT) << endl;
cout << "wall clock time = " << endwtime - startwtime << endl;
}
MPI::Finalize();
return 0;
}
我设置了VS2013项目的属性:
- 属性> vc 目录> include目录>(添加路径)" c: program Files mpich2 include"
- 属性> VC 目录>库目录>(添加路径)" C: Program Files MPICH2 LIB"
- 属性>链接>输入>其他依赖关系>(添加lib)" mpi.lib"
- properties>平台>(设置为)活动(x64)
我有未解决的参考链接器错误。具有相同属性的CPI.C代码毫无问题。我认为问题是在LIBS中需要的,但是我试图找到它们的组合,但并不能解决问题。mpich2具有这样的lib:cxx.lib,fmpich2.lib,fmpich2g.lib,irlog2rlog.lib,mpe.lib,mpi.lib,rlog.lib,traceinput.lib。如何使程序正确工作?
您需要添加另外一个额外的依赖项-cxx.lib
此库包含C 的所有必要绑定。
您可以查看mpich2/示例/cxxpi.vcproj,以发现需要链接此库。
相关文章:
- "error: no matching function for call to"构造函数错误
- C++,OpenCV,尝试显示图像时"OpenCV(4.3.0) Error: Assertion failed (size.width>0 && size.height>0)"此错误
- 使用 LuaBridge 将 LuaJIT 绑定到C++会导致"PANIC: unprotected error"
- 创建类对象时,我得到"error: linker command failed with exit code 1"
- std::map linker error ndk r8c with APP_STL := gnustl_static
- mpich2 visual studio 2013 linker error
- Cygwin 64 G++ -fuse-linker-plugin Error
- opengl on ubuntu Linker error: undefined references
- Apple Mach-O Linker(id) Error
- Apple Mach-O Linker Error with upnpx library
- 我不断收到来自Xcode的错误,说" Apple Mach-O Linker (Id) Error "readIt(std::_1::basic_ifstream<char,std::_1::c
- Linker error for functions expecting const std::string &
- 正在为客户端/服务器编译项目[Linker error]未定义对的引用
- 任何想法来解决"Linker error"不可置信的参考
- QuantLib linker error: QuantLib::Error::Error()
- 当从终端编译c++文件时,clang: error: linker命令失败,退出代码为1(使用-v查看调用)
- 当 nm 只看到一个定义时,为什么"Multiple definitions linker error"
- Boost C++ Libraries linker error libboost_serialization-vc10
- 使用多个框架会产生clang:error:linker命令失败,退出代码为1
- 为什么我的代码有"Apple Mach-O Linker Error?"