Menu

#58 Compilation fails on NetBSD due to <sys/sysctl.h>

open
Peter C
5
2014-08-22
2006-12-15
No

Sysctl(2) isn't very portable, it should be checked thoroughly in configure. Unmodified, compilation fails like this:

if g++ -DHAVE_CONFIG_H -I. -I. -I. -Wall -g -O2 -MT par2creator.o -MD -MP -MF ".deps/par2creator.Tpo" -c -o par2creator.o par2creator.cpp; \
then mv -f ".deps/par2creator.Tpo" ".deps/par2creator.Po"; else rm -f ".deps/par2creator.Tpo"; exit 1; fi
In file included from /usr/include/sys/sysctl.h:44,
from par2creator.cpp:22:
/usr/include/sys/ucred.h:49: error: `NGROUPS' was not declared in this scope
/usr/include/sys/ucred.h:59: error: `NGROUPS' was not declared in this scope
In file included from /usr/include/sys/sysctl.h:46,
from par2creator.cpp:22:
/usr/include/sys/proc.h:66: error: `MAXLOGNAME' was not declared in this scope
/usr/include/sys/proc.h:243: error: `MAXCOMLEN' was not declared in this scope
In file included from par2creator.cpp:22:
/usr/include/sys/sysctl.h:402: error: `MAXLOGNAME' was not declared in this
scope
gmake[1]: *** [par2creator.o] Error 1
gmake[1]: Leaving directory `/vol1/rhialto/cvs/other/parchive/par2-cmdline'
gmake: *** [all] Error 2

sysctl(3) says

SYNOPSIS
#include <sys/param.h>
#include <sys/sysctl.h>

Even after adding #include <sys/param.h> it still fails. However, a small test program succeeds compiling:

#include <sys/param.h>
#include <sys/sysctl.h>

int main(){}

so there must be something in the parchive source code that prevents this from working.

Discussion

  • Olaf Seibert

    Olaf Seibert - 2006-12-15

    Logged In: YES
    user_id=177931
    Originator: YES

    Ah, I looked wrong, the error was now in a different file, and adding #include <sys/param.h> there too helped.
    Now I get link errors (about pthread_join).

     
  • Olaf Seibert

    Olaf Seibert - 2006-12-15

    Logged In: YES
    user_id=177931
    Originator: YES

    So, linking needs the addition of "-pthread" and then it works. I don't know how to put a check for that in configure, though.
    But I do attach a patch for the 2 extra #include statements.
    File Added: diffs

     
  • Olaf Seibert

    Olaf Seibert - 2006-12-15

    Patch for the #includes

     

Log in to post a comment.