Search code examples
cmakefilecompiler-errors

C Library Compile Error


I'm trying to compile the sorting library from http://www.yendor.com/programming/sort/

Direct Link to library: http://www.yendor.com/programming/sort/sort-all.tgz

When I run make the compiler says:

gcc -g -O -DCUTOFF=15 -c sorttest.c
In file included from sorttest.c:15:
sort.h:66: error: conflicting types for ‘heapsort’
/usr/include/stdlib.h:301: error: previous declaration of ‘heapsort’ was here
make: *** [sorttest.o] Error 1

Can someone help with this issue?


Solution

  • Frosty,

    Well, the compiler is complaining that the type heapsort is already defined at line 301 in /usr/include/stdlib.h ... the traditional methods for dealing with these issues are :

    • Use another name for the offending article in your code. One supposes that myheapsort should do nicely. (and yes you can modify sort-all.tgz, coz it's published under GNU GPL)
    • supress stdlib's definition of heapsort using #def #ifndef (if you can't change your code).
    • Scream, cry, curse, and wish that all stdlibs (at least) where created equal. Sigh.

    Hope that helps.