On Sep 30, 2005, at 3:45 PM, Alastuey, Lucas wrote:
> hello list: i have compiling problem, i tried to make a
> comunicator class , but i can compiling it. i use CentOS4, and the
> package default of LAM_MPI.
It looks like there are two things wrong with your code:
1) in communicador.h, you should include <string> instead of
<string.h>
2) you need to link in communicador.o with your test_comm.o.
There are
two ways you can do this:
mpiCC test_comm.cpp comunicador.cpp -o ejec
or
mpiCC -c comunicador.cpp
mpiCC -c test_comm.cpp
mpiCC comunicador.o test_comm.o -o ejec
That should help out...
Brian
> here is the error
> ----------------------------------------------------------------------
> ----------------------------------------------------------------------
> ----------------------------
>
> mpiCC test_comm.cpp -o ejec
>
> En el fichero incluÃdo de /usr/lib/gcc/i386-redhat-linux/
> 3.4.3/../../../../include/c++/3.4.3/backward/iostream.h:31,
> de test_comm.cpp:2:
> /usr/lib/gcc/i386-redhat-linux/3.4.3/../../../../include/c++/3.4.3/
> backward/backward_warning.h:32:2: aviso: #warning This file
> includes at least one deprecated or antiquated header. Please
> consider using one of the 32 headers found in section 17.4.1.2 of
> the C++ standard. Examples include substituting the <X> header for
> the <X.h> header for C++ includes, or <iostream> instead of the
> deprecated header <iostream.h>. To disable this warning use -Wno-
> deprecated.
>
> /tmp/ccDKLngT.o(.text+0x128): En la función `main':
> : undefined reference to `comunicador::comunicador()'
> /tmp/ccDKLngT.o(.text+0x13e): En la función `main':
> : undefined reference to `comunicador::get_idnodo()'
> /tmp/ccDKLngT.o(.text+0x155): En la función `main':
> : undefined reference to `comunicador::enviar_individuos(char*,
> int, int)'
> /tmp/ccDKLngT.o(.text+0x16f): En la función `main':
> : undefined reference to `comunicador::recibir_individuos()'
> /tmp/ccDKLngT.o(.text+0x1b5): En la función `main':
> : undefined reference to `comunicador::recibir_individuos()'
> /tmp/ccDKLngT.o(.text+0x1fe): En la función `main':
> : undefined reference to `comunicador::get_idnodo()'
> /tmp/ccDKLngT.o(.text+0x20f): En la función `main':
> : undefined reference to `comunicador::enviar_individuos(char*,
> int, int)'
> /tmp/ccDKLngT.o(.text+0x21e): En la función `main':
> : undefined reference to `comunicador::get_idnodo()'
> /tmp/ccDKLngT.o(.text+0x230): En la función `main':
> : undefined reference to `comunicador::get_n_nodos()'
> /tmp/ccDKLngT.o(.text+0x24c): En la función `main':
> : undefined reference to `comunicador::recibir_individuos()'
> /tmp/ccDKLngT.o(.text+0x297): En la función `main':
> : undefined reference to `comunicador::enviar_individuos(char*,
> int, int)'
> /tmp/ccDKLngT.o(.text+0x2ae): En la función `main':
> : undefined reference to `comunicador::~comunicador()'
> /tmp/ccDKLngT.o(.text+0x2cb): En la función `main':
> : undefined reference to `comunicador::~comunicador()'
> collect2: ld devolvió el estado de salida 1
> mpiCC: No such file or directory
> ----------------------------------------------------------------------
> ----------------------------------------------------------------------
> ------------------------------------------
>
> here is the code of main, to probe the class comunicador
>
> ----------------------------------------------------------------------
> ----------------------------------------------------------------------
> -------------------------------------------
>
> #include <mpi.h>
> #include <iostream.h>
> #include <string.h>
> #include "comunicador.h"
>
> int main(){
>
> int error=1;
> comunicador comm;
> char *maleta="pase por \0";
>
>
> if (comm.get_idnodo()==0){
>
> comm.enviar_individuos(maleta,1,1);
> cout << "--- " << comm.recibir_individuos() << endl;
>
> }else{
>
> char *msg=" id= ";
>
> strcat(msg,comm.recibir_individuos());
> if (error!=0){
> cout << "error en el strcpy " << endl;
> }
> comm.enviar_individuos(msg,comm.get_idnodo()+1,2);
>
> if (comm.get_idnodo()==comm.get_n_nodos()-1){
> strcat(msg,comm.recibir_individuos());
> if (error!=0){
> cout << "error en el strcpy " << endl;
> }
> comm.enviar_individuos(msg,0,2);
> }
> }
> }
>
> ----------------------------------------------------------------------
> ----------------------------------------------------------------------
> --------------------------------------------
>
> and here is the code of the comunicador.h and comunicador.c
>
>
> ----------------------------------------------------------------------
> ----------------------------------------------------------------------
> --------------------------------------------
>
> ///////////////////////////////////////////////////////////
> // comunicador.h
> ///////////////////////////////////////////////////////////
>
> #ifndef __COMUNICADOR_H__
> #define __COMUNICADOR_H__
> #include <mpi.h>
> #include <string.h>
>
>
> // namespace Motor genetico
>
> //--------------------------------------------------------------------
> ---------------
> // Esta clase implementa la comunicación entre islas, esta
> encargada de mandar
> // emigrantes y recibir los migrantes, también tiene la
> responsabilidad de
> // implementar la topología a usar, de modo que la clase aduana no
> le importa
> // adonde van lo emigrantes. Esta clase es la que será implementada
> con MPI.
> //
> //--------------------------------------------------------------------
> ---------------
> class comunicador
> {
> private:
>
> int n_nodos,id_nodo,tag_tipo,largo_buff;
>
> public:
> comunicador();
> ~comunicador();
> //int hilo_escucha();
> //int topologia(int ultimomandado, int tipotopologia);
> int enviar_individuos(char *,int,int ); //
> emigrantes,destino,tipo_mensaje(individuos o numero de nodos)
> char *recibir_individuos();
> int get_idnodo();
> int get_n_nodos();
>
> };
> #endif
>
>
> ///////////////////////////////////////////////////////////
> // comunicador.cpp
> // Implementation of the Class comunicador
> // Created on: 10-Sep-2005 23:39:19
> ///////////////////////////////////////////////////////////
>
> #include "comunicador.h"
>
>
> comunicador::comunicador(){
> largo_buff=666;
> MPI::Init();
> n_nodos=MPI::COMM_WORLD.Get_size();
> id_nodo=MPI::COMM_WORLD.Get_rank();
>
> }
> comunicador::~comunicador(){
> MPI::Finalize();
> }
>
> int comunicador::enviar_individuos(char *emigrantes,int dest,int
> tipo_msg){
> int retorno=0;
>
> MPI::COMM_WORLD.Send(emigrantes,strlen(emigrantes)
> +1,MPI::BYTE,dest,tipo_msg);
>
> return retorno;
> }
>
>
> char *comunicador::recibir_individuos(){
>
> char msg[largo_buff];
> MPI::Status status;
>
> MPI::COMM_WORLD.Recv
> (msg,largo_buff,MPI::BYTE,MPI::ANY_SOURCE,MPI::ANY_TAG,status);
>
> tag_tipo=status.Get_tag();
>
> }
> int comunicador::get_idnodo(){
> return id_nodo;
> }
> int comunicador::get_n_nodos(){
> return n_nodos;
> }
> ----------------------------------------------------------------------
> ----------------------------------------------------------------------
> -------------------------------------------
>
> some ideas ?
>
>
>
> Saludos
> Lucas Alastuey T.
>
> Consultor QA
> Gerencia de Productos y Calidad
> Sonda Sistemas Financieros S.A.
> Fono: 56- 2 - 657 6237
>
>
> _______________________________________________
> This list is archived at http://www.lam-mpi.org/MailArchives/lam/
|