Re: Compilation error with net-snmp header files

This is a discussion on Re: Compilation error with net-snmp header files within the SNMP Users forums, part of the Networking and Network Related category; > OS: FreeBSD-4.10-RELEASE > (with /usr/local/include/getopt.h header file added by some packages) > ...


Go Back   Usenet Forums > Networking and Network Related > SNMP Users

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 08-19-2005
Pavlin Radoslavov
 
Posts: n/a
Default Re: Compilation error with net-snmp header files

> OS: FreeBSD-4.10-RELEASE
> (with /usr/local/include/getopt.h header file added by some packages)
> Net-SNMP: 5.2.1.2
> Compiler: gcc-3.4.2
>
> If I try to compile the following sample program:
>
> #include <net-snmp/net-snmp-config.h>
> #include <net-snmp/net-snmp-includes.h>
> #include <net-snmp/agent/net-snmp-agent-includes.h>
>
> #include <unistd.h>
>
> int
> main()
> {
> exit(0);
> }
>
> with the following arguments:
> g++34 `~/net-snmp/bin/net-snmp-config --cflags` bar.cc
>
> it fails with the following errors:
>
> pavlin@possum[483] g++34 `~/net-snmp/bin/net-snmp-config --cflags` bar.cc
> In file included from bar.cc:5:
> /usr/include/unistd.h:112: error: declaration of C function `int
> getopt(int, char* const*, const char*)' conflicts with
> /usr/local/include/getopt.h:115: error: previous declaration `int
> getopt()' here
> /home/possum/u0/pavlin/net-snmp/include/net-snmp/agent/agent_handler.h:238:
> warning: inline function `void*
> netsnmp_request_get_list_data(netsnmp_request_info *, const char*)'
> used but never defined
> Exit 1
>
> The problem is that on FreeBSD getopt() may be declared in both
> <unistd.h> and /usr/local/include/getopt.h, and we shouldn't include
> both files. The latter is included by <net-snmp/utilities.h> if
> HAVE_GETOPT_H is defined.
>
> Also note the second (probably independent) error about
> netsnmp_request_get_list_data() being used but never defined.
>
> Both errors are with gcc-3.4 (and probably the gcc-4.x branch), but
> are not with the gcc-2.95.4 compiler.


After some investigation I found that the second error can be
eliminated if the inlined functions are disabled by adding
-DNETSNMP_NO_INLINE to the compiler's flags.

Any suggestions how to fix the first error?
The ugly hack I use for testing purpose is to add
"#undef HAVE_GETOPT_H" after "#include <net-snmp/net-snmp-config.h>"
but this is not an acceptable solution.

Pavlin


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Net-snmp-users mailing list
Net-snmp-users@lists.sourceforge.net
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/...net-snmp-users
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 04:24 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0