[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Problem with SizeConstraints in AsnOcts class



Are you linking the MYTYPES.cpp file into your build?  If not, try this instead:

 

g++ -lc++asn1 myApp.cpp MYTYPES.cpp

 

Dave Abarbanel

BAE Systems


From: owner-imc-snacc@xxxxxxxxxxxx [mailto:owner-imc-snacc@xxxxxxxxxxxx] On Behalf Of Andrés Fuentes
Sent: Wednesday, February 28, 2007 11:00 AM
To: Abarbanel, David (US SSA); imc-snacc@xxxxxxx
Subject: RE: Problem with SizeConstraints in AsnOcts class

 

 

For example, I have a file named MYTYPES.asn1:

 

MYTYPES DEFINITIONS ::=

 

BEGIN

 

dSalReq OBJECT-TYPE

        SYNTAX DSalReq

        ACCESS read-write

        STATUS mandatory

        ::= 1001

 

dSalRes OBJECT-TYPE

        SYNTAX DSalRes

        ACCESS read-write

        STATUS mandatory

        ::= 1002

 

 

Primary ::= SEQUENCE

{

        req [1] IMPLICIT INTEGER,

        msgType [2] IMPLICIT INTEGER,

        msg ANY DEFINED BY msgType

}

 

DSalReq ::= SEQUENCE

{

        subs [1] IMPLICIT MyId,

        req [2] IMPLICIT Units,

        min [3] IMPLICIT Units OPTIONAL,

        apply [4] IMPLICIT NULL

}

 

DSalRes ::= SEQUENCE

{

        subs [1] IMPLICIT MyId,

        bStat [2] IMPLICIT BStat

}

 

BStat ::= ENUMERATED

{

        max (0),

        min (1),

        credit (2),

        zero (3)

}

 

MyId ::= OCTET STRING (SIZE(5..20))

 

Units ::= INTEGER

 

END

 

I use esnacc like this:

 

            esnacc -C -M MYTYPES.asn1   (or esnacc -C MYTYPES.asn1 produce the same result).

 

and I obtain the MYTYPES.h and MYTYPES.cpp. Then I change the include headers that correspond the correct directory.

 

I write an application named myApp.cpp:

 

#include "MYTYPES.h"

 

using namespace SNACC;

 

int main(void){

 

        char myBuffer[] = {0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x31,0x32,0x33,0x34,0x35};

        size_t sizeBuffer = sizeof(myBuffer);

 

        MyId  myId(myBuffer,sizeBuffer);

 

        DSalReq myDis = DSalReq();

 

        return 0;

}

 

When I compile it with the command:

 

            g++ -lc++asn1 myApp.cpp

 

I have the following result:

 

/tmp/ccxcpWm4.o(.gnu.linkonce.t._ZN5SNACC4MyIdD1Ev+0xb): In function `SNACC::MyId::~MyId()':

: undefined reference to `vtable for SNACC::MyId'

/tmp/ccxcpWm4.o(.gnu.linkonce.t._ZN5SNACC7DSalReqD1Ev+0xc): In function `SNACC::DSalReq::~DSalReq()':

: undefined reference to `vtable for SNACC::DSalReq'

/tmp/ccxcpWm4.o(.gnu.linkonce.t._ZN5SNACC7DSalReqD1Ev+0x17): In function `SNACC::DSalReq::~DSalReq()':

: undefined reference to `SNACC::DSalReq::Clear()'

/tmp/ccxcpWm4.o(.gnu.linkonce.t._ZN5SNACC7DSalReqC1Ev+0x1a): In function `SNACC::DSalReq::DSalReq()':

: undefined reference to `vtable for SNACC::DSalReq'

/tmp/ccxcpWm4.o(.gnu.linkonce.t._ZN5SNACC7DSalReqC1Ev+0x5d): In function `SNACC::DSalReq::DSalReq()':

: undefined reference to `SNACC::DSalReq::Init()'

/tmp/ccxcpWm4.o(.gnu.linkonce.t._ZN5SNACC4MyIdC1Ev+0x19): In function `SNACC::MyId::MyId()':

: undefined reference to `vtable for SNACC::MyId'

/tmp/ccxcpWm4.o(.gnu.linkonce.t._ZN5SNACC4MyIdC1EPKcj+0x1f): In function `SNACC::MyId::MyId(char const*, unsigned int)':

: undefined reference to `vtable for SNACC::MyId'

collect2: ld returned 1 exit status

 

When I redefine MyId without size the result is:

 

/tmp/cc8XLySG.o(.gnu.linkonce.t._ZN5SNACC7DSalReqD1Ev+0xc): In function `SNACC::DSalReq::~DSalReq()':

: undefined reference to `vtable for SNACC::DSalReq'

/tmp/cc8XLySG.o(.gnu.linkonce.t._ZN5SNACC7DSalReqD1Ev+0x17): In function `SNACC::DSalReq::~DSalReq()':

: undefined reference to `SNACC::DSalReq::Clear()'

/tmp/cc8XLySG.o(.gnu.linkonce.t._ZN5SNACC7DSalReqC1Ev+0x1a): In function `SNACC::DSalReq::DSalReq()':

: undefined reference to `vtable for SNACC::DSalReq'

/tmp/cc8XLySG.o(.gnu.linkonce.t._ZN5SNACC7DSalReqC1Ev+0x5d): In function `SNACC::DSalReq::DSalReq()':

: undefined reference to `SNACC::DSalReq::Init()'

collect2: ld returned 1 exit status

 

Excuse me if it’s an obviously error, I’m new using esnacc and I don’t program very hard in c++.  

 

Thank you for your help.

 

 

Andrés Fuentes

 

 

 


De: owner-imc-snacc@xxxxxxxxxxxx [mailto:owner-imc-snacc@xxxxxxxxxxxx] En nombre de Abarbanel, David (US SSA)
Enviado el: Miércoles, 28 de Febrero de 2007 9:59
Para: Andrés Fuentes; imc-snacc@xxxxxxx
Asunto: RE: Problem with SizeConstraints in AsnOcts class

 

I couldn’t reproduce this problem right off the bat, but if you could provide a little more info that would be great.

 

For instance, what parameters are you passing to the esnacc executable when you compile the ASN.1 module?  Also, if you were to re-define the ASN.1 definition without a size (rather than commenting out the SizeConstraint function), will it still give an error during your build?

 

Regards,

 

Dave Abarbanel

BAE Systems

 


From: owner-imc-snacc@xxxxxxxxxxxx [mailto:owner-imc-snacc@xxxxxxxxxxxx] On Behalf Of Andrés Fuentes
Sent: Monday, February 26, 2007 11:00 AM
To: imc-snacc@xxxxxxx
Subject: Problem with SizeConstraints in AsnOcts class

 

 

Please help me; I have a .asn1 file with the following types:

 

McMsisdn ::= OCTET STRING (SIZE(3..20));

 

I’m using eSNACC 1.7 with patch 1.7.4 with Red Hat Enterprise Linux 4, g++ (GCC) 3.4.3 20041212 (Red Hat 3.4.3-9.EL4).

 

I ran esnacc to obtain the .h and .cpp files. In another file I wrote my application with the following calls:

 

            char myBuffer[] = {0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x31,0x32,0x33,0x34,0x35};

            size_t sizeBuffer = sizeof(myBuffer);

            McMsisdn  myMcMsisdn(myBuffer,sizeBuffer);

 

When I compile it produces an error:

 

/tmp/ccxwGq5g.o(.gnu.linkonce.t._ZN5SNACC8McMsisdnD1Ev+0xb): In function `SNACC::McMsisdn::~McMsisdn()':

: undefined reference to `vtable for SNACC::McMsisdn'

/tmp/ccxwGq5g.o(.gnu.linkonce.t._ZN5SNACC8McMsisdnC1EPKcj+0x1f): In function `SNACC::McMsisdn::McMsisdn(char const*, unsigned int)':

: undefined reference to `vtable for SNACC::McMsisdn'

collect2: ld returned 1 exit status

 

I read a lot and tried to find the solution myself but in the gcc documentation explain about virtual functions, etc. etc. I think that is not the problem, I am not sure.

 

The declaration of my class generated by esnacc is the following

 

/* OCTET STRING SIZE 3..20 */

class  McMsisdn: public AsnOcts  {

                            public:

                                    McMsisdn ():AsnOcts() { }

                        McMsisdn (const char *str):AsnOcts(str) { }

                        McMsisdn (const char *str, const size_t len):AsnOcts(str, len) { }

                        McMsisdn (const McMsisdn &o):AsnOcts(o){ }

                                    const SizeConstraint* SizeConstraints(int &sizeList)const;

 

                                    McMsisdn                &operator = (const AsnOcts &o)

                            { SetEqual(o);  return *this;}

                                    McMsisdn                &operator = (const char *str)

                                { SetEqual(str); return *this; }

  };

 

When I comment the function  “const SizeConstraint* SizeConstraints(int &sizeList)const;” my application compile fine, but I think that It is necessary to handle the maximum an minimum size of the types.

 

I don’t understand why this error. I need your help, please.

 

 

Andrés Fuentes