# MyFirstGnProject **Repository Path**: havealex/my-first-gn-project ## Basic Information - **Project Name**: MyFirstGnProject - **Description**: 使用gn + ninja构建的一个简单的C++程序 - **Primary Language**: C++ - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-07-30 - **Last Updated**: 2025-07-30 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Ubuntu22.04中搭建GN编译环境 参考[Ubuntu22.04中搭建GN编译环境](https://ccf19881030.blog.csdn.net/article/details/149787321) # 使用GN+Ninja编译构建本项目 ## 1. 构建项目 ```shell # 创建输出目录 mkdir -p out/Default # 生成Ninja构建文件 gn gen out/Default # 执行构建 ninja -C out/Default ``` ## 2. 运行生成的可执行程序: ```shell # 设置动态库路径 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(pwd)/out/Default/libB # 运行程序 ./out/Default/my_app ``` 运行成功后,您应该看到以下输出: ```shell Starting main function... This is functionA from static library A This is functionB from dynamic library B Ending main function. ```