Function Declaration and Defintion Problem

Discussion in 'C++' started by Amit_Basnak, Dec 27, 2006.

  1. Amit_Basnak

    Amit_Basnak Guest

    Dear Friends

    I am giving the following command to build the server executableon
    HP-UX
    /opt/aCC/bin/aCC -o SOAPServer SOAPServer.o WFWuListService.o
    WFWuListImpl.o WFWuListStructs.o WFWuList.o
    -I/opt/systinet/server_cpp65/include/ -I../.. +DD64
    /opt/systinet/server_cpp65/lib/libwasp.sl
    /opt/systinet/server_cpp65/lib/libwasp_stl.sl -ldcekt -lpthread

    and Im getting the following error
    ld: Unsatisfied symbol "WF_ListWuClnt" in file WFWuListService.o
    1 errors.
    Which means WFWuListService.cpp, especially the spelling and definition
    of WF_ListWuClnt needs to be checked .

    My header file WFWuMYList1.h has the prototype declaration of
    WF_ListWuClnt function which is

    long WF_ListWuClnt (
    unsigned char *process_id,
    unsigned char *process_step_id,
    unsigned char *cluster_id,
    WF_STRUCT_SEARCH *search_params,
    char incl_active_wu,
    int nbr_requested,
    WF_LIST_WORKUNIT_P_FE *workunit_array
    );

    and in WFWuListService.cpp

    I have
    ------------------------------------------------------------------------------------------------------------------------------------------
    #include <stdlib.h>
    #include <string.h>
    #include <stdio.h>
    #include <sys/time.h>


    #include "WFWuListService.h" // WFWuList Systinet service
    declarations

    #include "WFWuMYList1.h"


    WFWuStructFe WFWuStructDceToSoap(WF_STRUCT_WORKUNIT_FE dceStruct) {

    // define WFWuStructFe
    WFWuStructFe wuStructFe;
    WFWuHandle wuHandle;

    wuHandle->workunit_id = 5;
    wuHandle->workunit_seq = 10;
    wuHandle->updateSerial_num = 12;

    wuStructFe->wf_workunit_handle = wuHandle;

    wuStructFe->ap_batch_id = "12";
    wuStructFe->ap_bene_base_num = "12";
    wuStructFe->ap_customer_name = "Amit" ;
    wuStructFe->ap_customer_num = "0400034";


    return wuStructFe;
    }


    ArrayOfWFWuStructFe WFWuListService::WfListWuClnt:):WFWuHandle &
    handle, const WASP_STD_NS::string & process_id, const
    WASP_STD_NS::string & process_step_id, const WASP_STD_NS::string &
    cluster_id, ::WFStructSearch & search_params, const WASP_STD_NS::string
    & incl_active_wu, int nbr_requested) {

    // Array of workunit structures to return
    ArrayOfWFWuStructFe wuList;

    // time structures to capture the lapsed time for RPC call
    struct timeval first,
    second,
    lapsed;
    struct timezone tzp;

    long tResult = 0;


    char process_id_[7];
    char process_step_id_[7];
    char cluster_id_[4];
    char incl_active_wu_ = 'Y' ;
    int nbr_requested_;

    strcpy((char*)process_id_, (char*)process_id.c_str() );
    process_id_[6]='\0';
    strcpy((char*)process_step_id_, (char*)process_step_id.c_str());
    process_step_id_[6]='\0';
    strcpy((char*)cluster_id_, (char*)cluster_id.c_str());
    cluster_id_[3]='\0';
    nbr_requested_ = nbr_requested;

    WF_STRUCT_SEARCH wf_struct_search_d ;
    memset((void*)&wf_struct_search_d, '\0', sizeof(WF_STRUCT_SEARCH));

    //***** Populate the WF_STRUCT_SEARCH ******

    wf_struct_search_d.workunit_handle.workunit_id =
    search_params->workunit_handle->workunit_id;
    wf_struct_search_d.workunit_handle.workunit_seq =
    search_params->workunit_handle->workunit_seq;
    wf_struct_search_d.workunit_handle.update_serial_num =
    search_params->workunit_handle->updateSerial_num;

    strcpy((char*)wf_struct_search_d.prod_type,(char*)search_params->prod_type.c_str());

    strcpy((char*)wf_struct_search_d.prod_sub_type,(char*)search_params->prod_sub_type.c_str());

    strcpy((char*)wf_struct_search_d.opn_type,(char*)search_params->opn_type.c_str());

    strcpy((char*)wf_struct_search_d.customer_num,(char*)search_params->customer_num.c_str());

    strcpy((char*)wf_struct_search_d.bene_base_num,(char*)search_params->bene_base_num.c_str());

    strcpy((char*)wf_struct_search_d.customer_ref_num,(char*)search_params->customer_ref_num.c_str());

    WF_STRUCT_WORKUNIT_FE *pWufe = NULL;
    WF_LIST_WORKUNIT_FE listWU;
    memset((void*)&listWU, '\0' , sizeof(WF_LIST_WORKUNIT_FE));
    WF_LIST_WORKUNIT_P_FE ptrlistWU ;
    ptrlistWU = &listWU;
    gettimeofday(&first, &tzp);
    tResult = WF_ListWuClnt(
    wfm_binding_h,
    (unsigned char*) (const char*) process_id_,
    (unsigned char*) (const char*) process_step_id_,
    (unsigned char*) (const char*) cluster_id_,
    &wf_struct_search_d,
    incl_active_wu_,
    nbr_requested_,
    &ptrlistWU);
    gettimeofday(&second, &tzp);
    if (first.tv_usec > second.tv_usec) {
    second.tv_usec += 1000000;
    second.tv_sec--;
    }
    lapsed.tv_usec = second.tv_usec - first.tv_usec;
    lapsed.tv_sec = second.tv_sec - first.tv_sec;
    // cout << "Lapsed time for DCE RPC call = " <<
    lapsed.tv_sec*1000 + lapsed.tv_usec/1000 << " msec." << endl;
    int i = 0;
    for (i = 0; i < ptrlistWU->nbr_Workunits_fe; i++) {

    wuList->wFWuStructFe.push_back(WFWuStructDceToSoap(ptrlistWU->lst_Workunit_fe));
    }
    free(ptrlistWU);
    cout << "WFWuListService: Number of records = " <<
    wuList->wFWuStructFe.size() << ", lapsed time = " << lapsed.tv_sec*1000
    + lapsed.tv_usec/1000 << " msec." << endl;
    return wuList;
    }
    }
    ------------------------------------------------------------------------------------------------------------------------------------------

    Am Missing something yet

    Thanks
    Ronan
    Amit_Basnak, Dec 27, 2006
    #1
    1. Advertising

  2. Amit_Basnak

    Earl Purple Guest

    Amit_Basnak wrote:

    > Am Missing something yet
    >
    > Thanks
    > Ronan


    A function body for WF_ListWuClnt perhaps, that has the same prototype
    as the one in your header?
    Or link in an external library that defines it.
    Earl Purple, Dec 27, 2006
    #2
    1. Advertising

  3. Amit_Basnak

    Salt_Peter Guest

    Amit_Basnak wrote:
    > Dear Friends
    >
    > I am giving the following command to build the server executableon
    > HP-UX
    > /opt/aCC/bin/aCC -o SOAPServer SOAPServer.o WFWuListService.o
    > WFWuListImpl.o WFWuListStructs.o WFWuList.o
    > -I/opt/systinet/server_cpp65/include/ -I../.. +DD64
    > /opt/systinet/server_cpp65/lib/libwasp.sl
    > /opt/systinet/server_cpp65/lib/libwasp_stl.sl -ldcekt -lpthread
    >
    > and Im getting the following error
    > ld: Unsatisfied symbol "WF_ListWuClnt" in file WFWuListService.o
    > 1 errors.
    > Which means WFWuListService.cpp, especially the spelling and definition
    > of WF_ListWuClnt needs to be checked .
    >
    > My header file WFWuMYList1.h has the prototype declaration of
    > WF_ListWuClnt function which is
    >
    > long WF_ListWuClnt (
    > unsigned char *process_id,
    > unsigned char *process_step_id,
    > unsigned char *cluster_id,
    > WF_STRUCT_SEARCH *search_params,
    > char incl_active_wu,
    > int nbr_requested,
    > WF_LIST_WORKUNIT_P_FE *workunit_array
    > );
    >
    > and in WFWuListService.cpp
    >
    > I have
    > ------------------------------------------------------------------------------------------------------------------------------------------
    > #include <stdlib.h>
    > #include <string.h>
    > #include <stdio.h>
    > #include <sys/time.h>
    >
    >
    > #include "WFWuListService.h" // WFWuList Systinet service
    > declarations
    >
    > #include "WFWuMYList1.h"
    >
    >
    > WFWuStructFe WFWuStructDceToSoap(WF_STRUCT_WORKUNIT_FE dceStruct) {
    >
    > // define WFWuStructFe
    > WFWuStructFe wuStructFe;
    > WFWuHandle wuHandle;
    >
    > wuHandle->workunit_id = 5;
    > wuHandle->workunit_seq = 10;
    > wuHandle->updateSerial_num = 12;
    >
    > wuStructFe->wf_workunit_handle = wuHandle;
    >
    > wuStructFe->ap_batch_id = "12";
    > wuStructFe->ap_bene_base_num = "12";
    > wuStructFe->ap_customer_name = "Amit" ;
    > wuStructFe->ap_customer_num = "0400034";
    >
    >
    > return wuStructFe;
    > }
    >
    >
    > ArrayOfWFWuStructFe WFWuListService::WfListWuClnt:):WFWuHandle &
    > handle, const WASP_STD_NS::string & process_id, const
    > WASP_STD_NS::string & process_step_id, const WASP_STD_NS::string &
    > cluster_id, ::WFStructSearch & search_params, const WASP_STD_NS::string
    > & incl_active_wu, int nbr_requested) {
    >
    > // Array of workunit structures to return
    > ArrayOfWFWuStructFe wuList;
    >
    > // time structures to capture the lapsed time for RPC call
    > struct timeval first,
    > second,
    > lapsed;
    > struct timezone tzp;
    >
    > long tResult = 0;
    >
    >
    > char process_id_[7];
    > char process_step_id_[7];
    > char cluster_id_[4];
    > char incl_active_wu_ = 'Y' ;
    > int nbr_requested_;
    >
    > strcpy((char*)process_id_, (char*)process_id.c_str() );
    > process_id_[6]='\0';
    > strcpy((char*)process_step_id_, (char*)process_step_id.c_str());
    > process_step_id_[6]='\0';
    > strcpy((char*)cluster_id_, (char*)cluster_id.c_str());
    > cluster_id_[3]='\0';
    > nbr_requested_ = nbr_requested;
    >
    > WF_STRUCT_SEARCH wf_struct_search_d ;
    > memset((void*)&wf_struct_search_d, '\0', sizeof(WF_STRUCT_SEARCH));
    >
    > //***** Populate the WF_STRUCT_SEARCH ******
    >
    > wf_struct_search_d.workunit_handle.workunit_id =
    > search_params->workunit_handle->workunit_id;
    > wf_struct_search_d.workunit_handle.workunit_seq =
    > search_params->workunit_handle->workunit_seq;
    > wf_struct_search_d.workunit_handle.update_serial_num =
    > search_params->workunit_handle->updateSerial_num;
    >
    > strcpy((char*)wf_struct_search_d.prod_type,(char*)search_params->prod_type.c_str());
    >
    > strcpy((char*)wf_struct_search_d.prod_sub_type,(char*)search_params->prod_sub_type.c_str());
    >
    > strcpy((char*)wf_struct_search_d.opn_type,(char*)search_params->opn_type.c_str());
    >
    > strcpy((char*)wf_struct_search_d.customer_num,(char*)search_params->customer_num.c_str());
    >
    > strcpy((char*)wf_struct_search_d.bene_base_num,(char*)search_params->bene_base_num.c_str());
    >
    > strcpy((char*)wf_struct_search_d.customer_ref_num,(char*)search_params->customer_ref_num.c_str());
    >
    > WF_STRUCT_WORKUNIT_FE *pWufe = NULL;
    > WF_LIST_WORKUNIT_FE listWU;
    > memset((void*)&listWU, '\0' , sizeof(WF_LIST_WORKUNIT_FE));
    > WF_LIST_WORKUNIT_P_FE ptrlistWU ;
    > ptrlistWU = &listWU;
    > gettimeofday(&first, &tzp);
    > tResult = WF_ListWuClnt(
    > wfm_binding_h,
    > (unsigned char*) (const char*) process_id_,
    > (unsigned char*) (const char*) process_step_id_,
    > (unsigned char*) (const char*) cluster_id_,
    > &wf_struct_search_d,
    > incl_active_wu_,
    > nbr_requested_,
    > &ptrlistWU);
    > gettimeofday(&second, &tzp);
    > if (first.tv_usec > second.tv_usec) {
    > second.tv_usec += 1000000;
    > second.tv_sec--;
    > }
    > lapsed.tv_usec = second.tv_usec - first.tv_usec;
    > lapsed.tv_sec = second.tv_sec - first.tv_sec;
    > // cout << "Lapsed time for DCE RPC call = " <<
    > lapsed.tv_sec*1000 + lapsed.tv_usec/1000 << " msec." << endl;
    > int i = 0;
    > for (i = 0; i < ptrlistWU->nbr_Workunits_fe; i++) {
    >
    > wuList->wFWuStructFe.push_back(WFWuStructDceToSoap(ptrlistWU->lst_Workunit_fe));
    > }
    > free(ptrlistWU);
    > cout << "WFWuListService: Number of records = " <<
    > wuList->wFWuStructFe.size() << ", lapsed time = " << lapsed.tv_sec*1000
    > + lapsed.tv_usec/1000 << " msec." << endl;
    > return wuList;
    > }
    > }
    > ------------------------------------------------------------------------------------------------------------------------------------------
    >
    > Am Missing something yet
    >


    Try programming in C++ instead. Otherwise ask your question in a C
    newsgroup.
    You have a declaration for long WF_ListWuClnt(...) but i don't see its
    implementation.
    Also,
    a) pointers are evil, use references or const references instead
    b) #include <string>, not <string.h>
    c) #include <cstdlib>
    d) #include <cstudio>
    Salt_Peter, Dec 27, 2006
    #3
  4. Amit_Basnak

    Earl Purple Guest

    Salt_Peter wrote:
    >
    > Try programming in C++ instead. Otherwise ask your question in a C
    > newsgroup.


    Well the code looks more like C with classes, but it certainly doesn't
    pass
    for pure C.

    > You have a declaration for long WF_ListWuClnt(...) but i don't see its
    > implementation.
    > Also,
    > a) pointers are evil, use references or const references instead


    Pointers are not evil. However having to manage memory is evil. Use
    smart-pointers,
    use std::vector instead of arrays and std::string for string handling.

    Use references instead of pointers when the pointer cannot be NULL or
    change what
    it points to. Use pointers when you need to initialise it later, eg
    scoping:

    Foo * ptrToAFoo;
    if ( some_condition_or_other )
    {
    ptrToAFoo = x;
    }
    else
    {
    ptrToAFoo = y;
    }

    and it might not be possible to use ? : notation in the above if it's
    complex.

    void function( const Foo & fooparam, Diagnostics * diagnostic_info =
    NULL );

    The above uses a const reference parameter and a non-const pointer
    parameter.
    The const reference must refer to a valid object. The pointer may be
    NULL if the
    caller doesn't want the function to write diagnostic information.

    > b) #include <string>, not <string.h>


    The equivalent for <string.h> is <cstring> but it's true that most of
    the time you won't
    need the C string library functions. If you do then use <cstring>

    > c) #include <cstdlib>

    Most of the time but I think there might be some POSIX functions in
    <stdlib.h> that
    are not in <cstdlib>. I certainly know there are some POSIX functions
    that haven't
    made it into the C++-equivalent header but I can't remember exactly
    which ones.

    > d) #include <cstudio>

    No, there is no 'u'. It is <cstdio>. Most of the time you won't need
    this header though,
    as you will be using iostream and equivalent instead.
    Earl Purple, Dec 27, 2006
    #4
  5. Amit_Basnak

    Amit_Basnak Guest

    Earl Purple wrote:
    > Amit_Basnak wrote:
    >
    > > Am Missing something yet
    > >
    > > Thanks
    > > Ronan

    >
    > A function body for WF_ListWuClnt perhaps, that has the same prototype
    > as the one in your header?
    > Or link in an external library that defines it.


    Thanks Earl and Peter for your expert advice.
    To give you more back ground , I am building a Server binary
    usingSystinet Server for C++ .
    Thanks for the information. The WF_ListWuClnt() function had
    originally been usedwith DCE
    DCE ( Distributed Computing Environment) calls which uses Interface
    Definition language ( idl) . In WFClnt_dceOnlyRpc.h file this original
    WF_ListWuClnt () call has been defined as below

    extern AppReturnStatus WF_ListWuClnt(
    #ifdef IDL_PROTOTYPES
    /* [in] */ idl_char *process_id,
    /* [in] */ idl_char *process_step_id,
    /* [in] */ idl_char *cluster_id,
    /* [in] */ WF_STRUCT_SEARCH *search_params,
    /* [in] */ idl_char incl_active_wu,
    /* [in] */ idl_short_int nbr_requested,
    /* [out] */ WF_LIST_WORKUNIT_P_FE *workunit_array,
    #endif
    );

    The modifying function I am writing with Systinet Server for C++ does
    not use DCE and hence I converted WF_ListWuClnt () to normal C/C++
    function type as

    long WF_ListWuClnt (
    unsigned char *process_id,
    unsigned char
    *process_step_id,
    unsigned char *cluster_id,
    WF_STRUCT_SEARCH *search_params,
    char
    incl_active_wu,
    int
    nbr_requested,
    WF_LIST_WORKUNIT_P_FE *workunit_array
    );

    and used as in my own header file WFWuMYList1.h which I included in
    the WFWuListService.cpp . And its implementation is concerned , the
    return of WF_ListWuClnt () oflong type has been stored in
    tResult = WF_ListWuClnt(
    wfm_binding_h,
    (unsigned char*) (const char*) process_id_,
    (unsigned char*) (const char*) process_step_id_,
    (unsigned char*) (const char*) cluster_id_,
    &wf_struct_search_d,
    incl_active_wu_,
    nbr_requested_,
    &ptrlistWU);
    which is also in tResult.

    While compiling with aCC under HP-Unix , I didnt get any error , The
    error comes only while building the server executable and that too in
    WFWuListService.o object file and as correctly pointed out by Earl that
    link in an external library that defines it could be missing .
    Thank you again for your time and the efforts that you put in this
    question.
    Please let me know whether the implementation of WF_ListWuClnt( )
    as shown above is correct or needs to be modified .
    Thanks
    Amit
    Amit_Basnak, Dec 28, 2006
    #5
  6. Amit_Basnak

    Amit_Basnak Guest

    Amit_Basnak wrote:
    > Earl Purple wrote:
    > > Amit_Basnak wrote:
    > >
    > > > Am Missing something yet
    > > >
    > > > Thanks
    > > > Ronan

    > >
    > > A function body for WF_ListWuClnt perhaps, that has the same prototype
    > > as the one in your header?
    > > Or link in an external library that defines it.

    >
    > Thanks Earl and Peter for your expert advice.
    > To give you more back ground , I am building a Server binary
    > usingSystinet Server for C++ .
    > Thanks for the information. The WF_ListWuClnt() function had
    > originally been usedwith DCE
    > DCE ( Distributed Computing Environment) calls which uses Interface
    > Definition language ( idl) . In WFClnt_dceOnlyRpc.h file this original
    > WF_ListWuClnt () call has been defined as below
    >
    > extern AppReturnStatus WF_ListWuClnt(
    > #ifdef IDL_PROTOTYPES
    > /* [in] */ idl_char *process_id,
    > /* [in] */ idl_char *process_step_id,
    > /* [in] */ idl_char *cluster_id,
    > /* [in] */ WF_STRUCT_SEARCH *search_params,
    > /* [in] */ idl_char incl_active_wu,
    > /* [in] */ idl_short_int nbr_requested,
    > /* [out] */ WF_LIST_WORKUNIT_P_FE *workunit_array,
    > #endif
    > );
    >
    > The modifying function I am writing with Systinet Server for C++ does
    > not use DCE and hence I converted WF_ListWuClnt () to normal C/C++
    > function type as
    >
    > long WF_ListWuClnt (
    > unsigned char *process_id,
    > unsigned char
    > *process_step_id,
    > unsigned char *cluster_id,
    > WF_STRUCT_SEARCH *search_params,
    > char
    > incl_active_wu,
    > int
    > nbr_requested,
    > WF_LIST_WORKUNIT_P_FE *workunit_array
    > );
    >
    > and used as in my own header file WFWuMYList1.h which I included in
    > the WFWuListService.cpp . And its implementation is concerned , the
    > return of WF_ListWuClnt () oflong type has been stored in
    > tResult = WF_ListWuClnt(
    > wfm_binding_h,
    > (unsigned char*) (const char*) process_id_,
    > (unsigned char*) (const char*) process_step_id_,
    > (unsigned char*) (const char*) cluster_id_,
    > &wf_struct_search_d,
    > incl_active_wu_,
    > nbr_requested_,
    > &ptrlistWU);
    > which is also in tResult.
    >
    > While compiling with aCC under HP-Unix , I didnt get any error , The
    > error comes only while building the server executable and that too in
    > WFWuListService.o object file and as correctly pointed out by Earl that
    > link in an external library that defines it could be missing .
    > Thank you again for your time and the efforts that you put in this
    > question.
    > Please let me know whether the implementation of WF_ListWuClnt( )
    > as shown above is correct or needs to be modified .
    > Thanks
    > Amit



    When I compiled with all WF_ListWuClnt( ) commented , It goes fine and
    no error has been repored.

    Thanks
    Amit
    Amit_Basnak, Dec 28, 2006
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bardo
    Replies:
    3
    Views:
    1,142
    Bardo
    Jul 11, 2004
  2. Rick Razzano

    XSD document for XSD defintion

    Rick Razzano, Sep 26, 2003, in forum: XML
    Replies:
    1
    Views:
    456
    C. M. Sperberg-McQueen
    Sep 26, 2003
  3. Replies:
    4
    Views:
    585
    Jim Langston
    Oct 2, 2006
  4. Chad
    Replies:
    4
    Views:
    284
  5. TriAdmin
    Replies:
    7
    Views:
    122
Loading...

Share This Page