GithubHelp home page GithubHelp logo

linuxc_makefile_template's People

Contributors

jtortoise avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

linuxc_makefile_template's Issues

交叉编译的可执行程序动态库依赖问题

交叉编译生成的可执行程序动态库依赖问题

交叉编译的工作一般都是在主机进行的,在生成可执行程序的时候指定的动态库运行路径Wl,-rpth=xx/xx/xx/的时候,当把可执行程序放到目标平台,也需要建立一个同主机一样的路径来保证动态库的查找是正确的,这样子在做不同平台程序测试的时候相当麻烦。

问题产生的缘由

在多级Makefile模板里面,是通过将src目录下每个模块编译成一个动态库,再将其放到顶层目录下的lib目录,方便主函数调用相应模块的库函数(这样子可以避免主函数依赖大量的*.o文件),这样子在运行生成的可执行程序的时候,就涉及到了可执行程序在运行的时候动态库路径查找的问题。

解决方案

在这里提出部分解决方案,打勾代表该问题的最佳解决方案。

  • 在生成可执行程序的时候指定编译Wl,-rpath是目标平台上的某个已经定好的路径。这样就不会出现依赖找不到的问题,但是也需要更新相应模块的动态库,才能保证程序执行正确。这样子在做不同平台测试的时候,不仅需要传输你得可执行程序,也需要传输你的动态库,麻烦。。
  • src目录的每个模块不做成动态库,全部改成静态库,这样子在编译生成的可执行程序中,就不会依赖到自己模块的动态库,在目标平台做测试的时候,也只需要传输一个可执行程序就搞定了!但也会带来一些问题,就是在编译主模块的时候比较复杂些。
  • ...

主模块下TARGET的CFLAGS参数与模块下.o文件的CFLAGS参数冲突

主模块下TARGET的CFLAGS参数与模块下.o文件的CFLAGS参数冲突

在一个Makefile中指定要生成的对象是一个TARGET,就意味这个Makefile生成的是一个可执行文件。但在该模块下,还需要生成一堆*.o的可重定位的目标文件,这些文件的生成也依赖着gcc的CFLAGS参数。对于gcc生成TARGET的CFLAGS的作用是不一样的,因此两者存在冲突。

解决方案

  • 为TARGET专门指定一个属于它自己的gcc编译参数变量,比如TARGET_CFLAGS。
  • ...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.