# basics **Repository Path**: Cooper0/basics ## Basic Information - **Project Name**: basics - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2022-02-11 - **Last Updated**: 2022-05-17 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## 模板工程 本工程是一个工程模板,使用Makefile进行编译管理 ### Makefile结构及拓展说明 本工程中共使用了5种类型的Makefile 1、主目录下的Makefile,主要作用是自动查找下一级子目录中的Makefile并且运行 2、thirdPartyLibrary下的Makefile查找运行子目录下的Makefile 3、thirdPartyLibrary子目录下的Makefile就是每个第三方库的实际编译控制 4、libtest的Makefile,用来生成用户的静态库 5、main的Makefile,用来生成最终的可执行文件 ### 添加用户模块 拷贝libtest文件夹为新的文件夹,修改Makefile中的TARGET,编写源文件 ### 添加第三方库 以添加opensll为例 ```shell #创建子模块路径 mkdir -p thirdPartyLibrary/opensll/ #添加opensll为工程子模块 git submodule add https://gitee.com/zhanyejun/openssl.git thirdPartyLibrary/opensll/openssl #拷贝模板Makefile cp thirdPartyLibrary/cJSON/Makefile thirdPartyLibrary/opensll/ #进入到opensll源码 cd thirdPartyLibrary/opensll/openssl #配置opensll在本机的编译环境,交叉编译需要用--cross-compile-prefix指定编译器,32位需要删除Makefile中的m64 ./config no-asm --prefix=/home/user/test/build/x86_64 -fPIC #将配置生成的Makefile拷贝到上级目录 cp Makefile ../Makefile.x86_64 ``` 修改thirdPartyLibrary/opensll/Makefile中的CONFIG为../Makefile.x86_64,-C后面的目录修改为openssl。在修改CONFIG时可以通过HOST判定不同平台,在多平台编译时可分别编译