build(3)
π NAME π
okay so this is build(3) from the ANTLR3C manual, bestie, and it's literally the whole "how do I even build this thing" saga. buckle up π
build β Building From Source
so the C runtime? it's shipped as source code only. no cap. there are just wayyyyy too many binary versions out there to sensibly maintain binaries on www.antlr.org. like, keeping up with that many builds? not the vibe. π
what you do get: the runtime code comes with .sln and .vcproj files for Visual Studio 2005 and 2008, plus configure files for building and installing on UNIX or any other system that supports this tool. and if your system is neither Windows nor configure-compatible? honestly you should find it reasonable to build the code manually β go peek at the section "Building Manually". π«Ά
πΈ Source Code Organization πΈ
when the source code expands out of that tar/zip file, this is the little family of directories it gives you:
./β the location of theconfigurescript and theantlr3config.hfile generated by the running theconfigurescript. This directory also contains the solution and project files for visual studio 2005 and 2008../srcβ the location of all the C files in the project. π./includeβ the location of all the header files for the project β¨./doxygenβ the location of documentation files such as the one that generates this page π- Other ancillary directories used by the build or documentation process.
π¦ Building for Windows π¦
if you're building for Cygwin, or a similar UNIX on Windows System, follow the "Building With Configure" instructions down below instead, mwah. π
β οΈ note that the runtime is no longer compatible with the VC6 Microsoft compiler. if you absolutely need to build with this compiler, you can probably hack the source code to deall with the pieces that VC6 cannot handle such as the ULL suffix for constants. (yes, "deall". the manpage said it, I'm not fixing it, that's the original energy π« )
β¨ Building with the Visual Studio IDE β¨
if you wish to build the binaries for Windows using Visual Studio 2005, or 2008 you may build using the IDE:
- Open the
C.slnfile - Select batch Build from the Build menu
- Select all configurations and press the build button.
π» Building from the command line π»
if you wish or need to build the libraries from the command line, then you must use a Windows command shell configured for access to VS2005/VS2008 compilers, such as the one that is started from:
Start->Microsoft Visual Studio 2005->Visual Studio Tools->Visual Studio 2005 Command Prompt
there appears to be no way to build all targets at once in a batch mode from the command line, so you may build one or all of the following:
C:\antlrsrc\code\antlr\main\runtime\C> DEVENV C.sln /Build ReleaseDLL
C:\antlrsrc\code\antlr\main\runtime\C> DEVENV C.sln /Build Release
C:\antlrsrc\code\antlr\main\runtime\C> DEVENV C.sln /Build DebugDLL
C:\antlrsrc\code\antlr\main\runtime\C> DEVENV C.sln /Build Debug
after the build is complete you will find the .\cDLL and .\cLIB files under the directory containing C.sln, in a subdirectory named after the /Build target. π₯ In the Release and Debug targets, you will find that there is only a .\cLIB archive file, which you can link directly into your own projects if you wish to avoid the DLL. In ReleaseDLL and DebugDLL you will find both a .LIB file which you should link your projects with and a DLL. The library and names on Windows are as follows:
- ReleaseDLL : ANTLR3C.DLL and ANTLR3C_DLL.LIB
- DebugDLL : ANTLR3CD.DLL and ANTLR3CD_DLL.LIB
- Release : ANTLR3C.LIB
- Debug : ANTLR3CD.LIB
there currently no .msi modules or other installs built for Windows, so you must place the DLLs in a directory referenced by the PATH environment variable and make the include directory available to your project configurations. that's just how it is, bestie π
π Building with configure π
before starting, make sure that you are using a source code distribution and not the source code directly from the Perforce repository. π¨ If you use the source from the perforce tree directly, you will find that there is no configure script as this is generated as part of the distribution build by the maintainers. If you feel the need to build from the distribution tree then you must have all the autobuild packages available on your system and can generate the configure script using autoreconf. If you are not familiar with these tools, then please use the tgz files in the dist subdirectory (or downloaded from the ANTLR web site). π
π¦ Unpacking π¦
the source code file should be expanded in a directory of your choice (probably your working directory) using the command:
gzip -dc antlrtgzname.tar.gz | tar xvf -
where: antlrtgzname.tar.gz is of course the name of the tar when you downloaded it. You should find a configure script in the sub directory thus created. β¨
π Configuring π
the configure script accepts the usual options, such as --prefix= but the default is to build in the source directory and to place libraries in /usr/local/lib and include files (for building your recognizers) in /usr/local/include. There are also a number of antlr specific options, which you may wish to utilize. The command:
./configure --help
will document the latest incarnations of these options in case this documentation is ever out of date. At this time the options are:
--enable-debuginfoβ Compiles debug info into the library (default no)--enable-64bitβ Turns on flags that produce 64 bit object code if any are required (default no)
unless you need 64 bit builds, or a change in library types, you will generally use the configure command without options:
π«Ά A sample configure output π«Ά
here's the whole thing, verbatim, because watching it run is honestly iconic:
[jimi@localhost dist]$ tar zvxf libantlr3c-3.0.0-rc8.tar.gz
libantlr3c-3.0.0-rc8/
libantlr3c-3.0.0-rc8/antlr3config.h
libantlr3c-3.0.0-rc8/src/
libantlr3c-3.0.0-rc8/src/antlr3stringstream.c
...
libantlr3c-3.0.0-rc8/antlr3config.h.in
[jimi@localhost dist]$ cd libantlr3c-3.0.0-rc
[jimi@localhost libantlr3c-3.0.0-rc8]$ ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for xlc... no
checking for aCC... no
checking for gcc... gcc
...
checking for strdup... yes
configure: creating ./config.status
config.status: creating Makefile
config.status: creating antlr3config.h
config.status: antlr3config.h is unchanged
config.status: executing depfiles commands
having configured the library successfully, you need only make it, and install it:
[jimi@localhost libantlr3c-3.0.0-rc8]$ make
make all-am
make[1]: Entering directory `/home/jimi/antlrsrc/code/antlr/main/runtime/C/dist/libantlr3c-3.0.0-rc8'
/bin/sh ./libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -Iinclude -Iinclude -O2 -MT antlr3baserecognizer.lo -MD -MP -MF .deps/antlr3baserecognizer.Tpo -c -o antlr3baserecognizer.lo `test -f 'src/antlr3baserecognizer.c' || echo './'`src/antlr3baserecognizer.c
...
gcc -shared .libs/antlr3baserecognizer.o .libs/antlr3basetree.o .libs/antlr3basetreeadaptor.o .libs/antlr3bitset.o .libs/antlr3collections.o .libs/antlr3commontoken.o .libs/antlr3commontree.o .libs/antlr3commontreeadaptor.o .libs/antlr3commontreenodestream.o .libs/antlr3cyclicdfa.o .libs/antlr3encodings.o .libs/antlr3exception.o .libs/antlr3filestream.o .libs/antlr3inputstream.o .libs/antlr3intstream.o .libs/antlr3lexer.o .libs/antlr3parser.o .libs/antlr3string.o .libs/antlr3stringstream.o .libs/antlr3tokenstream.o .libs/antlr3treeparser.o .libs/antlr3rewritestreams.o .libs/antlr3ucs2inputstream.o -Wl,-soname -Wl,libantlr3c.so -o .libs/libantlr3c.so
ar cru .libs/libantlr3c.a antlr3baserecognizer.o antlr3basetree.o antlr3basetreeadaptor.o antlr3bitset.o antlr3collections.o antlr3commontoken.o antlr3commontree.o antlr3commontreeadaptor.o antlr3commontreenodestream.o antlr3cyclicdfa.o antlr3encodings.o antlr3exception.o antlr3filestream.o antlr3inputstream.o antlr3intstream.o antlr3lexer.o antlr3parser.o antlr3string.o antlr3stringstream.o antlr3tokenstream.o antlr3treeparser.o antlr3rewritestreams.o antlr3ucs2inputstream.o
ranlib .libs/libantlr3c.a
creating libantlr3c.la
(cd .libs && rm -f libantlr3c.la && ln -s ../libantlr3c.la libantlr3c.la)
make[1]: Leaving directory `/home/jimi/antlrsrc/code/antlr/main/runtime/C/dist/libantlr3c-3.0.0-rc8'
[jimi@localhost libantlr3c-3.0.0-rc8]$ sudo make install
make[1]: Entering directory `/home/jimi/antlrsrc/code/antlr/main/runtime/C/dist/libantlr3c-3.0.0-rc8'
test -z "/usr/local/lib" || /bin/mkdir -p "/usr/local/lib"
/bin/sh ./libtool --mode=install /usr/bin/install -c 'libantlr3c.la' '/usr/local/lib/libantlr3c.la'
/usr/bin/install -c .libs/libantlr3c.so /usr/local/lib/libantlr3c.so
/usr/bin/install -c .libs/libantlr3c.lai /usr/local/lib/libantlr3c.la
/usr/bin/install -c .libs/libantlr3c.a /usr/local/lib/libantlr3c.a
...
/usr/bin/install -c -m 644 'include/antlr3stringstream.h' '/usr/local/include/antlr3stringstream.h'
...
/usr/bin/install -c -m 644 'antlr3config.h' '/usr/local/include/antlr3config.h'
make[1]: Leaving directory `/home/jimi/antlrsrc/code/antlr/main/runtime/C/dist/libantlr3c-3.0.0-rc8'
[jimi@localhost libantlr3c-3.0.0-rc8]$
and that's it β you are now ready to generate C recognizers and compile and link them with the ANTLR 3 C Runtime. slay. πβ¨
π§ Building Manually π§
the only step that configure performs that cannot be done manually (without effort) is to produce the header file antlr3config.h, which contains typedefs of the fundamental types that your local C compiler supports. The easiest way to produce this file for your system, if you cannot port automake and configure to the system is:
- Run
configureon a system that does supportconfigure - Copy the generated
antlr3config.hfile to the target system - Edit the file locally and change any types that differ on this system to the target systems. There are only a few types and you should find this relatively easy.
having produced a compatible antlr3config.h file, then you should be able to compile the source files in the ./src subdirectory, providing an include path to the location of antlr3config.h and the ./include subdirectory. Something akin to:
~/C/src: cc -c -O -I.. -I../include *.c
having produced the .o (or equivalent) files for the local system you can then build an archive or shared library for the C runtime. π
when you wish to build and link with the C runtime, specify the path to the supplied header files, and the path to the library that you built. and you're done, bestie, go forth and recognize some C π
and that's the whole page, babes β this was Version 3.3.1, dated Tue Jul 29 2025 00:00:00, and it's the build(3) page from the ANTLR3C manual. bye pookie, happy building π
β¨π¦
π¦ where this page comes from
- fedora 43: antlr3-C-devel 1:3.4-3.5.3.14.fc43 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms