源码编译antlr4-cpp-runtime

源码编译antlr4-cpp-runtime

环境:

antlr4: 4.9.3
编译器: msvc 2019/gcc 9.4.0

1. windows编译antlr4-cpp-runtime源码

1.1 编译utfcpp(有互联网的情况下,该步骤可省略)

$ wget https://github.com/nemtrif/utfcpp/archive/refs/tags/v3.1.1.tar.gz
$ tar zxvf v3.1.1.tar.gz
$ cd utfcpp-3.1.1
$ cmake -B bin -DUTF8_TESTS=OFF
$ cmake --build bin --config Debug
$ cmake --install bin --config Debug

1.2 编译antlr4-cpp-runtime

$ wget https://www.antlr.org/download/antlr4-cpp-runtime-4.9.3-source.zip
$ unzip antlr4-cpp-runtime-4.9.3-source.zip
$ cmake -B bin -DCMAKE_INSTALL_PREFIX=install
$ cmake --build bin --config Debug
$ cmake --install bin --config Debug

注意:
如果引用antlr4-cpp-runtime.dll的功能运行库使用的是多线程调试DLL(/MDd),那么antlr4-cpp-runtime的编译也不必须保持一致,否则会出现崩溃。
【C/C++】-【代码生成】-【运行库】-【多线程调试DLL(/MDd)】

安装后的目录结构

$ tree
.
+--- include
|   +--- antlr4-runtime
+--- lib
|   +--- antlr4-runtime-static.lib
|   +--- antlr4-runtime.dll
|   +--- antlr4-runtime.lib
+--- share
|   +--- doc
|   |   +--- libantlr4
|   |   |   +--- LICENSE.txt
|   |   |   +--- README.md
|   |   |   +--- VERSION

2. Linux编译antlr4-cpp-runtime源码

Ubuntu 20.04系统

2.1 编译libuuid

$ wget http://nchc.dl.sourceforge.net/project/libuuid/libuuid-1.0.3.tar.gz
$ tar zxvf libuuid-1.0.3.tar.gz

$ cd libuuid-1.0.3
$ ./configure
$ make
$ sudo make install

2.2 编译utfcpp(有互联网的情况下,该步骤可省略)

$ wget https://github.com/nemtrif/utfcpp/archive/refs/tags/v3.1.1.tar.gz
$ tar zxvf v3.1.1.tar.gz
$ cd utfcpp-3.1.1
$ cmake -B bin -DUTF8_TESTS=OFF
$ cmake --build bin --config Debug
$ cmake --install bin --config Debug

2.3 编译antlr4-cpp-runtime

$ wget https://www.antlr.org/download/antlr4-cpp-runtime-4.9.3-source.zip
$ unzip antlr4-cpp-runtime-4.9.3-source.zip
$ cmake -B bin -DCMAKE_INSTALL_PREFIX=install
$ cmake --build bin --config Debug
$ cmake --install bin --config Debug

安装后的目录结构

$ tree
.
├── include
│   └── antlr4-runtime
├── lib
│   ├── libantlr4-runtime.a
│   ├── libantlr4-runtime.so -> libantlr4-runtime.so.4.9.3
│   └── libantlr4-runtime.so.4.9.3
└── share
    └── doc
        └── libantlr4
            ├── LICENSE.txt
            ├── README.md
            └── VERSION

猜你喜欢

转载自blog.csdn.net/itas109/article/details/131360565
今日推荐