Is it possible to compile the compiler-generated control table or code file as a DLL?

Yes, you can do it. After you have created the DLL, you can pass it to ossWinit() which will load it and make it available to the runtime.

Here is what you need to do: If you wish to compile a code file (when -codeFile is specified on the ASN.1 compiler command line) or a control table as a DLL, you should follow the example provided in the dll.mak makefile in the samples directory of your installation.

To run the makefiles, you should invoke the nmake (or make) program with the DLL=1 command-line option specified. For example:

nmake -f asn1cpl.mak DLL=1
nmake -f dll.mak DLL=1

Below you can find instructions for how to compile your control table as a DLL using the MS Visual C++ compiler.

Using the MS Visual C++ compiler, you should follow the same steps that you usually follow to compile a DLL. However, you should use a definition file like ctltbl.def:

oss_test @1
ossGetHeader @2

You may use this file to compile OSS control tables and code files of your own as DLLs. However if you don't use the -wTest ASN.1 compiler option, then you should delete the EXPORTS statement oss_test @1. Otherwise, you'll get an unresolved symbol error.

When C-compiling the ASN.1 compiler output .c file, you must #define the macro _OSSGETHEADER. If this macro is #defined, ossWinit() can get the control table (or code file) address by a call to the internal OSS function ossGetHeader().

Practically speaking, the steps that you should follow when using MS Visual C++ are (assuming that bcas.c and bcas.h are the ASN.1 compiler output files):

(a) C-compile the ASN.1 compiler output files bcas.c and bcas.h and the source file dllmain.c provided:

cl -c -MD -D_WIN32 -D_OSSGETHEADER -I\ossasn1\win32\5.3.0\include bcas.c
cl -c -MD -D_WIN32 -I\ossasn1\win32\5.3.0\include dllmain.c

(b) Create bcas.def by copying:

copy ctltbl.def bcas.def

(c) Create an export file bcas.exp first, using the object files bcas.obj, dllmain.obj, and bcas.def:

lib -machine:i386 -out:bcas.lib -def:bcas.def dllmain.obj bcas.obj

(d) Link-edit the object files bcas.obj and dllmain.obj with the import library ossapi.lib:

link -nodefaultlib DLL -entry:DllMain -out:bcas.dll bcas.exp bcas.obj ossapi.lib msvcrt.lib kernel32.lib gdi32.lib user32.lib comdlg32.lib oldnames.lib

After your control table or code file is compiled as a DLL, you can pass its
name to ossWinit() (See the OSS ASN.1/C API Runtime Reference Manual, section 4.2.5 of the April 2011 edition) for loading and using it by the runtime.

The samples included with some of the Knowledge Center answers are meant for your general understanding of the OSS products. Different versions of the products might produce slightly different outputs. Consult the products documentation and samples for the most up-to-date products information and code examples.

Contact Support
contact Our office hours
24 hours/day, 7 days/week

  • Phone: 1-888-OSS-2761 (USA and Canada)
  • Phone: 1-732-302-9669 (International)
  • Fax: 1-732-302-0023
  • Email:
Free Trial

Test drive the OSS Nokalva ASN.1, LTE, and XML Tools now! Your trial includes complete software, documentation, sample programs, free 24x7 technical support and more.

Learn ASN.1
Learn ASN.1

Our expert personnel can help you learn ASN.1!

We offer 4-day ASN.1 courses at our headquarters or your premises.