Hardships with compiling parrallel programs on serial machine

Hello, everyone.
Sorry for disturbance.
I am trying to compile Hello.world program for mpi using text from dummy mpi package mpi_stubs.
Running g++ -c hello.c goes without problem.
Running g++ -g ./hello.o -o a.out brings
the following:
hello.c:(.text+0x17): undefined reference to `MPI::Init(int&, char**&)'
hello.c:(.text+0x1e): undefined reference to `MPI::COMM_WORLD'
hello.c:(.text+0x23): undefined reference to `MPI::Comm::Get_size() const'
hello.c:(.text+0x2e): undefined reference to `MPI::COMM_WORLD'
hello.c:(.text+0x33): undefined reference to `MPI::Comm::Get_rank() const'
hello.c:(.text+0x47): undefined reference to `MPI_Wtime()'
hello.c:(.text+0x177): undefined reference to `MPI_Wtime()'
hello.c:(.text+0x1cc): undefined reference to `MPI::Finalize()'
collect2: ld returned 1 exit status
Thank you for your attention.
# include <cstdlib>
# include <iostream>
# include <iomanip>

using namespace std;

double MPI_Wtime ( );
namespace MPI
{
void Finalize ( );
void Init ( int &argc, char **&argv );
void Init ( );
double MPI_Wtick ( );
double MPI_Wtime ( );
class Comm
{
public:
int Get_size ( ) const;
int Get_rank ( ) const;
};
extern Comm COMM_WORLD;
}
void timestamp ( );

int main ( int argc, char *argv[] );

//****************************************************************************80

int main ( int argc, char *argv[] )

{
int id;
int p;
double wtime;
//
// Initialize MPI.
//
MPI::Init ( argc, argv );
//
// Get the number of processes.
//
p = MPI::COMM_WORLD.Get_size ( );
//
// Get the individual process ID.
//
id = MPI::COMM_WORLD.Get_rank ( );
//
// Process 0 prints an introductory message.
//
if ( id == 0 )
{
wtime = MPI_Wtime ( );

cout << "\n";
cout << "HELLO_MPI - Master process:\n";
cout << " C++/MPI version\n";
cout << " An MPI example program.\n";
cout << "\n";
cout << " The number of processes is " << p << "\n";
cout << "\n";
}
//
// Every process prints a hello.
//
cout << " Process " << id << " says 'Hello, world!'\n";
//
// Process 0 says goodbye.
//
if ( id == 0 )
{
cout << "\n";
cout << "HELLO_MPI - Master process:\n";
cout << " Normal end of execution: 'Goodbye, world!'\n";
wtime = MPI_Wtime ( ) - wtime;
cout << "\n";
cout << " Elapsed wall clock time = " << wtime << " seconds.\n";
}
//
// Shut down MPI.
//
MPI::Finalize ( );

return 0;
}
Hello, just use the "mpicxx" command instead of "g++" to compile.
Topic archived. No new replies allowed.