vlm / asn1c

The ASN.1 Compiler
http://lionet.info/asn1c/
BSD 2-Clause "Simplified" License
1.04k stars 557 forks source link

Compiling 3GPP NGAP: get only one .h file and locate local headers <asn-application.h> #432

Open raoufkh opened 3 years ago

raoufkh commented 3 years ago

Hello,

I've been able to compile the ASN file from 3GPP TS 38.413 (NGAP) v16.5.0 using asn1c from the vlm_master branch of this fork https://github.com/mouse07410/asn1c by running the following command:

asn1c -fcompound-names -gen-APER ngap-v16.5.0.asn

The result is:

Q1: My first question is: is it possible to get only one .h file for that protocol (NGAP)? I want then to use that library for parsing NGAP messages in C language.

Then when I try to compile the example using cc or make I have the following errors:

cc -DPDU=NGAP-PDU -o NgapDecoder.o *.c
compilation terminated.
uper_encoder.c:1:10: fatal error: asn_application.h: No such file or directory
 #include <asn_application.h>
          ^~~~~~~~~~~~~~~~~~~
compilation terminated.
uper_opentype.c:5:10: fatal error: asn_internal.h: No such file or directory
 #include <asn_internal.h>
          ^~~~~~~~~~~~~~~~
compilation terminated.
uper_support.c:5:10: fatal error: asn_system.h: No such file or directory
 #include <asn_system.h>
          ^~~~~~~~~~~~~~
compilation terminated.
xer_decoder.c:5:10: fatal error: asn_application.h: No such file or directory
 #include <asn_application.h>
          ^~~~~~~~~~~~~~~~~~~
compilation terminated.
xer_encoder.c:5:10: fatal error: asn_internal.h: No such file or directory
 #include <asn_internal.h>
          ^~~~~~~~~~~~~~~~
compilation terminated.
xer_support.c:7:10: fatal error: asn_system.h: No such file or directory
 #include <asn_system.h>
          ^~~~~~~~~~~~~~

while I can see that these headers are available in the current directory. Q2: So how to make the compiler aware of the location of these local headers?

Can anyone help please?

raoufkh commented 3 years ago

Update: The issue of not finding skeleton headers has been solved by specifying the path where to search for headers using -I parameter:

cc -DPDU=NGAP-PDU -I. -o NgapDecoder.o *.c 

Now, I've another issue, the cc compiler tell me that several types are not defined. I will take an example of the ProtocolIE_SingleContainer_128P31_t type.

When I search for the definition of the ProtocolIE_SingleContainer_128P31_t I find this:

./ProtocolIE-SingleContainer.h:typedef NPN_Support_ExtIEs_t  ProtocolIE_SingleContainer_128P31_t;

in ./ProtocolIE-Field.h I expect that the type NPN_Support_ExtIEs_t is defined:

typedef struct NPN_Support_ExtIEs {
    ProtocolIE_ID_t  id;
    Criticality_t    criticality;
    struct NPN_Support_ExtIEs__value {
        NPN_Support_ExtIEs__value_PR present;
        union NPN_Support_ExtIEs__value_u {
        } choice;

        /* Context for parsing across buffer boundaries */
        asn_struct_ctx_t _asn_ctx;
    } value;

    /* Context for parsing across buffer boundaries */
    asn_struct_ctx_t _asn_ctx;
} NPN_Support_ExtIEs_t;

The header ProtocolIE-Field.h is included in the file ./ProtocolIE-SingleContainer.h like this:

include "ProtocolIE-Field.h"

Do I have to specify the order to the compiler?

plutec commented 2 years ago

Hi, I'm having exactly the same issue than you. Did you solve it?

Thanks.