C/C++ source code generated by the compiler can be compiled using any ANSI standard C or C++ compiler. The only additional option that must be set is the inclusion of the ASN.1 C/C++ header file include directory with the –I option.
When linking a program with compiler-generated code, it is necessary to include the ASN.1 run-time libraries. It is necessary to include at least one of the encoding rules libraries (asn1ber, asn1per, etc.) as well as the common run-time functions library (asn1rt). See the ASN1C C/C++ Run-time Reference Manual for further details on these libraries.
For static linking on Windows systems, the name of the library files are asn1ber_a.lib, asn1per_a.lib, or asn1xer_a.lib for BER/DER/CER, PER, XER, or XML respectively, and asn1rt_a.lib for the common run-time components. On UNIX/Linux, the library names are libasn1ber.a, libasn1per.a, libasn1xer.a, libasn1xml.a and libasn1rt.a. The library files are located in the lib subdirectory. For UNIX, the –L switch should be used to point to the subdirectory path and - lasn1ber, -lasn1per, -lasn1xer, -lasn1xml and/or -lasn1rt used to link with the libraries. For Windows, the -LIBPATH switch should be used to specify the library path.
There are several other variations of the C/C++ run-time library files for Windows. The following table summarizes what options were used to build each of these variations:
Library Files | Description |
---|---|
asn1ber_a.lib asn1json_a.lib asn1mder_a.lib asn1oer_a.lib asn1per_a.lib asn1rt_a.lib asn1rt3gpp_a.lib asn1xer_a.lib asn1xml_a.lib |
Static libraries. These are built without the -MD (dynamic link libraries) option. They may be used to produce statically linked application programs. |
asn1ber.lib asn1json.lib asn1mder.lib asn1oer.lib asn1per.lib asn1rt.lib asn1rt3gpp.lib asn1xer.lib asn1xml.lib |
DLL libraries. These are used to link against the DLL versions of the run-time libraries (for example, asn1rt.dll, etc.). Note that the version of these libraries in the SDK package have a 'd' suffix after the library name to denote that these are the debug version of the libraries. The deployment release packages contain libraries without the 'd' suffix (i.e. non-debug libraries). |
asn1bermd_a.lib asn1jsonmd_a.lib asn1mdermd_a.lib asn1oermd_a.lib asn1permd_a.lib asn1rtmd_a.lib asn1rt3gppmd_a.lib asn1xermd_a.lib asn1xmlmd_a.lib |
DLL-ready multi-threaded libraries. These libraries were built with the –MD option. They allow linking additional object modules in with the ASN1C run-time modules to produce larger DLLs. |
For dynamic linking on UNIX/Linux, a shared object version of each run-time library is included in the lib subdirectory. This file typically has the extension .so (for shared object) or .sl (for shared library). See the documentation for your UNIX compiler to determine how to link using these files.
See the makefile in any of the sample subdirectories of the distribution for an example of what must be included to build a program using generated source code.