no warning if included header and library dont match

Asked by J-B Vosteen on 2012-01-09

If i include the "doublefann.h" header and then compile it with
    gcc myfile.c -lfann
i dont get any warning.
This Problem cost me two precious days of my life. So it may worth considering to issue some sort of warning or error.

Question information

English Edit question
Ubuntu libfann Edit question
No assignee Edit question
Last query:
Last reply:
mycae (mycae) said : #1

Can you explain your scenario in a little more detail? In C, there is no need for the header and library names to match. The header provide a compiler with interface information regarding the .so file. What warning would you expect a compiler to generically provide, and how?

Matching ABI to header data is exceedingly tricky, to say the least.

J-B Vosteen (bart-jan-bart) said : #2

I tried to create a little program with libfann. At compilation time there were no errors, but at runtime it continuously segfaulted. So i created a testcase.
The code of the testcase included "doublefann.h". I tried to compile this testcase with "-lfann", because at that point i was totally unaware of the fact that i had to supply "-ldoublefann". As one could have expected it did not work. "double" is just bigger as float.
As already said i spent two days searching for the answer, until somone pointed it out to me (

All this took place on the same machine, so no differing lib versions:
    Linux hsw-vosteen 2.6.38-13-generic #53-Ubuntu SMP Mon Nov 28 19:33:45 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux

Maybe i am just not skilled enough, but libfann was the obvious choice to link to. But as i was not right, the lib should point it out to me. Somewhere.

If it is not technically possible to inform the user about it at compile/link time, it should be put BOLD into the documentation.

mycae (mycae) said : #3

Yes, it is a tricky problem - Personally I would have set it up so that there would be TWO libflann s, which conflict with each other and cannot be installed simultaneously.

However, I would recommend posting a bug, and requesting that a runtime check be made available. It should be possible to create a function that has a signature such as

int getFannPrecision();

which returns "4" and "8", and can be used as a check

if(sizeof(fann_type) != getFannSize)
printf("well that isn't right, library and compiled fann size do not agree!")
return someErrorCode;

As you have set this as a support request, I would recommend filing a bug with the upstream version of Fann itself, requesting something like the above change, or a more prominent mention in their webpage's documentation.

Can you help with this problem?

Provide an answer of your own, or ask J-B Vosteen for more information if necessary.

To post a message you must log in.