C,headers

The concept of headers in C was necessary at its time,but these days it just makes compilation of complex program in complex environment several times more complex. Whenever you have several package-roots (I have /usr,/usr/local,/sw,/opt/local,/opt/some_pkg1,/opt/some_pkg2 at the same time),which have different versions of the same libraries,you need to separately check resolution order of libraries and header-files.

Sometimes it feels completely counter-intuitive and you just end up manually hiding some files.

Common end-user solution is just sticking to the package-root provided by distribution (usually “/usr”),but that is not an option for developer,who needs to test different combinations of bleeding-edge apps.

How do you manage this stuff?

Example. I need to build php6 (installation prefix /opt/php6) with:

  • iconv from /sw (whle there is other iconv in /usr)
  • libxml from /usr (while there is other libxml in /sw)
  • icu from /sw/local (while there are pieces of other icu’s in /sw and /usr)

In reality,there are more libs involved,and complexity arises,when these different libs are needed by the same components of php. I start thinking,that I should create some special package-root and just symlink every needed library in it. And just give it as the only package-root to php. Seems like a complex task,while considering all dependencies.

In my ideal world,there would be no name-resolution at all,compiler would just require exact position of library (which would be represented by the single file)

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • DZone
  • FriendFeed
  • Reddit
  • Tumblr
  • Twitter
Liked this post? Follow me on twitter:@jimi_dini.

  • Adriano

    Good post,man. Only one thing:you write “complexity arouses”. ‘arouses’doesn’t mean what you think. It especially doesn’t mean “arises”.

  • http://indeyets.pp.ru/ indeyets

    thanks,Adriano. fixed

  • http://karwin.blogspot.com Bill Karwin

    You should check out the Filesystem Hierarchy Standard (http://proton.pathname.com/fhs/pub/fhs-2.3.html). It might help you manage the software more easily if you follow the guidelines in that standard.

  • http://indeyets.pp.ru/ indeyets

    Bill:it doesn’t really help,if you need to manage independent package-roots.

    FHS is good for end-users and for developers of single-packages.

    Anyway,FHS doesn’t help in resolution of conflicting C-libraries

  • http://jpipes.com Jay Pipes

    “Anyway,FHS doesn’t help in resolution of conflicting C-libraries”

    True,but what about using autotools? Surely the AC_ macros can work some wonders here? Not the easiest or most intuitive to learn,but I bet they’d be able to solve much of these problems…

    Cheers!

    -jay

  • http://indeyets.pp.ru/ indeyets

    autotools work on other level. They help to locate headers and libraries,but in the end,I still will be left with:

    “gcc -I/sw/include -I/usr/include …”

    and if for compilation of this exact file I need 1 file from /usr,other from /sw,but similiar (but other versions) files exist in both package-roots I will end with both files from /sw used,and autotools won’t be able to help me

  • http://blog.stuartherbert.com/php/ Stuart Herbert

    Hi Alexey,

    You’re trying to fight decades of UNIX tradition here :( Two options that are useful:

    1) Run separate chroot environments for each of your different build combinations. Takes time to setup,and eats disk space,but once setup,they are less frustrating than trying to mix and match the way you are.
    2) Run separate Xen based virtual machines for each of your different build combinations :)

    Hope that helps,
    Stu

A sample text widget

Etiam pulvinar consectetur dolor sed malesuada. Ut convallis euismod dolor nec pretium. Nunc ut tristique massa.

Nam sodales mi vitae dolor ullamcorper et vulputate enim accumsan. Morbi orci magna,tincidunt vitae molestie nec,molestie at mi. Nulla nulla lorem,suscipit in posuere in,interdum non magna.