hi guys,
First of all: my english is poor, but I hope you understand me.
I downloaded asn1c-0.9.27.tar.gz (https://lionet.info/asn1c/download.html) few days ago. I don’t have implemented a program with ASN.1 before, so I’m an absolute amateur. I develop under Linux (Debian) with Eclipse CDT (C++).
I did the following:
I extracted and installed asn1c with follows commands in the terminal (as root):
tar xfz asn1c-0.9.27.tar.gz cd asn1c-0.9.27 ./configure --prefix=/usr make make install
After this, I could use asn1c in the terminal. Now I tried the example in the documentation (asn1c-usage.pdf). I created a file named rectangle.asn1 with the following contents:
RectangleModule1 DEFINITIONS ::= BEGIN Rectangle ::= SEQUENCE { height INTEGER, width INTEGER } END
After this, I compiled it in the terminal with follow command:
asn1c rectangle.asn1
terminal output:
WARNING: Cannot find standard modules in /usr/local/share/asn1c/standard-modules Compiled Rectangle.c Compiled Rectangle.h Copied /usr/local/share/asn1c/INTEGER.h -> INTEGER.h Copied /usr/local/share/asn1c/NativeEnumerated.h -> NativeEnumerated.h Copied /usr/local/share/asn1c/INTEGER.c -> INTEGER.c Copied /usr/local/share/asn1c/NativeEnumerated.c -> NativeEnumerated.c Copied /usr/local/share/asn1c/NativeInteger.h -> NativeInteger.h Copied /usr/local/share/asn1c/NativeInteger.c -> NativeInteger.c Copied /usr/local/share/asn1c/constr_SEQUENCE.h -> constr_SEQUENCE.h Copied /usr/local/share/asn1c/constr_SEQUENCE.c -> constr_SEQUENCE.c Copied /usr/local/share/asn1c/asn_application.h -> asn_application.h Copied /usr/local/share/asn1c/asn_system.h -> asn_system.h Copied /usr/local/share/asn1c/asn_codecs.h -> asn_codecs.h Copied /usr/local/share/asn1c/asn_internal.h -> asn_internal.h Copied /usr/local/share/asn1c/OCTET_STRING.h -> OCTET_STRING.h Copied /usr/local/share/asn1c/OCTET_STRING.c -> OCTET_STRING.c Copied /usr/local/share/asn1c/BIT_STRING.h -> BIT_STRING.h Copied /usr/local/share/asn1c/BIT_STRING.c -> BIT_STRING.c Copied /usr/local/share/asn1c/asn_codecs_prim.c -> asn_codecs_prim.c Copied /usr/local/share/asn1c/asn_codecs_prim.h -> asn_codecs_prim.h Copied /usr/local/share/asn1c/ber_tlv_length.h -> ber_tlv_length.h Copied /usr/local/share/asn1c/ber_tlv_length.c -> ber_tlv_length.c Copied /usr/local/share/asn1c/ber_tlv_tag.h -> ber_tlv_tag.h Copied /usr/local/share/asn1c/ber_tlv_tag.c -> ber_tlv_tag.c Copied /usr/local/share/asn1c/ber_decoder.h -> ber_decoder.h Copied /usr/local/share/asn1c/ber_decoder.c -> ber_decoder.c Copied /usr/local/share/asn1c/der_encoder.h -> der_encoder.h Copied /usr/local/share/asn1c/der_encoder.c -> der_encoder.c Copied /usr/local/share/asn1c/constr_TYPE.h -> constr_TYPE.h Copied /usr/local/share/asn1c/constr_TYPE.c -> constr_TYPE.c Copied /usr/local/share/asn1c/constraints.h -> constraints.h Copied /usr/local/share/asn1c/constraints.c -> constraints.c Copied /usr/local/share/asn1c/xer_support.h -> xer_support.h Copied /usr/local/share/asn1c/xer_support.c -> xer_support.c Copied /usr/local/share/asn1c/xer_decoder.h -> xer_decoder.h Copied /usr/local/share/asn1c/xer_decoder.c -> xer_decoder.c Copied /usr/local/share/asn1c/xer_encoder.h -> xer_encoder.h Copied /usr/local/share/asn1c/xer_encoder.c -> xer_encoder.c Copied /usr/local/share/asn1c/per_support.h -> per_support.h Copied /usr/local/share/asn1c/per_support.c -> per_support.c Copied /usr/local/share/asn1c/per_decoder.h -> per_decoder.h Copied /usr/local/share/asn1c/per_decoder.c -> per_decoder.c Copied /usr/local/share/asn1c/per_encoder.h -> per_encoder.h Copied /usr/local/share/asn1c/per_encoder.c -> per_encoder.c Copied /usr/local/share/asn1c/per_opentype.h -> per_opentype.h Copied /usr/local/share/asn1c/per_opentype.c -> per_opentype.c Copied /usr/local/share/asn1c/converter-sample.c -> converter-sample.c Generated Makefile.am.sample root@debian:~/Dokumente#
I got a warning, so I think I made something wrong during the installation. I copied the folder “standard-modules” from asn1c-0.9.27.tar.gz (/skeletons) to /usr/local/share/asn1c and tried again. Ok, now it works without a warning. Now I created a new c++ project in eclipse and add the path to the compiled asn1 files. Then I wrote the main.cpp file with the following code:
#include <Rectangle.h> int main() { Rectangle_t *rect = NULL; asn_DEF_Rectangle.free_struct(&asn_DEF_Rectangle, rect, 0); /* more code …sometime */ return 0; }
However, I can’t compile this code. I always get an error like this: undefined reference to 'asn_DEF_Rectangle'
Eclipse output:
make all Building file: ../src/ASN1.cpp Invoking: GCC C++ Compiler g++ -I/root/Dokumente -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/ASN1.d" -MT"src/ASN1.d" -o "src/ASN1.o" "../src/ASN1.cpp" Finished building: ../src/ASN1.cpp Building target: ASN1 Invoking: GCC C++ Linker g++ -o "ASN1" ./src/ASN1.o makefile:45: recipe for target 'ASN1' failed ./src/ASN1.o: In function `main': /media/sf_NTS_Daten/Workspace/ASN1/Debug/../src/ASN1.cpp:6: undefined reference to `asn_DEF_Rectangle' /media/sf_NTS_Daten/Workspace/ASN1/Debug/../src/ASN1.cpp:6: undefined reference to `asn_DEF_Rectangle' collect2: error: ld returned 1 exit status make: *** [ASN1] Error 1
All examples I found (documentation and lionet.info) ends with an error (undefined reference to 'asn_DEF_xxxxxxxxxxxxxx'). I don’t know the reason. The structures are working and I can fill it with values, but asn_DEF_Rectangle (in this case) generate an error. I have no idea what I can do. Did I need a library? Or may fail the installation of asn1c?
Have someone tips or ideas? please...
I do not know how to continue…. :(
regards,
SBond