jtortoise / linuxc_makefile_template Goto Github PK
View Code? Open in Web Editor NEWLinux环境C语言编程项目多级Makefile管理模板
Linux环境C语言编程项目多级Makefile管理模板
交叉编译的工作一般都是在主机进行的,在生成可执行程序的时候指定的动态库运行路径Wl,-rpth=xx/xx/xx/
的时候,当把可执行程序放到目标平台,也需要建立一个同主机一样的路径来保证动态库的查找是正确的,这样子在做不同平台程序测试的时候相当麻烦。
在多级Makefile模板里面,是通过将src目录下每个模块编译成一个动态库,再将其放到顶层目录下的lib目录,方便主函数调用相应模块的库函数(这样子可以避免主函数依赖大量的*.o文件),这样子在运行生成的可执行程序的时候,就涉及到了可执行程序在运行的时候动态库路径查找的问题。
在这里提出部分解决方案,打勾代表该问题的最佳解决方案。
Wl,-rpath
是目标平台上的某个已经定好的路径。这样就不会出现依赖找不到的问题,但是也需要更新相应模块的动态库,才能保证程序执行正确。这样子在做不同平台测试的时候,不仅需要传输你得可执行程序,也需要传输你的动态库,麻烦。。src
目录的每个模块不做成动态库,全部改成静态库,这样子在编译生成的可执行程序中,就不会依赖到自己模块的动态库,在目标平台做测试的时候,也只需要传输一个可执行程序就搞定了!但也会带来一些问题,就是在编译主模块的时候比较复杂些。在一个Makefile中指定要生成的对象是一个TARGET,就意味这个Makefile生成的是一个可执行文件。但在该模块下,还需要生成一堆*.o
的可重定位的目标文件,这些文件的生成也依赖着gcc的CFLAGS参数。对于gcc生成TARGET的CFLAGS的作用是不一样的,因此两者存在冲突。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.