mouse07410 / asn1c

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

Cannot compile S1AP ASN.1 Files into libasncodec.a or converter-example #83

Closed btsimon97 closed 3 years ago

btsimon97 commented 3 years ago

When attempting to use asn1c to compile the ASN.1 files for S1AP, the files will compile, but the resulting output cannot be used to produce the libasncodec.a file and/or converter example.

Attempting to run make to produce these files returns a bunch of compiler errors with the ProtocolIE-Field.c file, most of them redefinition errors. The compilation process then terminates after dumping the compiler errors to the terminal and fails to produce the libasncodec.a file.

mouse07410 commented 3 years ago

It probably has to do with the order of the includes/header files. Protocols like S1AP tend to contort ASN.1 to the point that a "simple" tool like asn1c cannot handle adequately.

It is fairly likely that you can figure out (probably, by trial and error) the order of including header files, such that the resulting C sources compile and link correctly. But it's a pain, and time-consuming. Another possibility would be "massaging" the ASN.1 definitions by hand, simplifying them and making asn1c's life "easier".

I'm sorry, but I don't think I can help you here - not enough time and expertise.

btsimon97 commented 3 years ago

Hi for some reason asn1c produced exact duplicates of the function definitions within the same file, which was why the compiler was complaining, as every function in the file was being defined twice in the same file. Not sure if its related to the issues with S1AP being difficult for asn1c to parse, or something else that triggered. I can provide the file in question along with the ASN1 files causing the issue if it would help in troubleshooting.

mouse07410 commented 3 years ago

I'm pretty sure it's S1AP being too difficult fur asn1c to parse.

As I said, I don't even know whether this can be fixed without significantly increasing the complexity of the compiler even more (you can see for yourself that is darn complicated already) - and I've neither time nor expertise for that.

brchiu commented 3 years ago

@btsimon97 use -findirect-choice command line option to generate code for S1AP.

mouse07410 commented 3 years ago

@btsimon97 any feedback? Did @brchiu 's suggestion fix your problem?

I will close this issue, assuming your problem was fixed. If not - please feel free to re-open with additional info.