g++ problem

Harti Brandt brandt at fokus.fraunhofer.de
Thu Nov 6 09:10:44 PST 2003

On Thu, 6 Nov 2003, Marius Strobl wrote:

MS>On Thu, Nov 06, 2003 at 11:28:28AM -0500, Alexander Kabaev wrote:
MS>> On Thu, 6 Nov 2003 16:55:00 +0100 (CET)
MS>> "C. Kukulies" <kuku at www.kukulies.org> wrote:
MS>> > I tried to compile a virus-scanner for Linux that allows for scanning
MS>> > Windoze PCs in a network for all sorts of recent viruses (RPC/DCOM and
MS>> > such).
MS>> >
MS>> > http://www.enyo.de/fw/software/doscan
MS>> >
MS>> > Compilation fails with the following:
MS>> >
MS>> > kukuboo2k# gmake
MS>> > g++ -g -O2 -Wall -I/usr/local/include -I. -I. -I./lib \
MS>> >         -MMD -MF src/doscan.d \
MS>> >         -c -o src/doscan.o src/doscan.cc
MS>> > In file included from src/doscan.cc:28:
MS>> > /usr/local/include/getopt.h:115: error: declaration of C function `int
MS>> > getopt()
MS>> >    ' conflicts with
MS>> > /usr/include/unistd.h:377: error: previous declaration `int
MS>> > getopt(int, char*
MS>> >    const*, const char*)' here
MS>> > gmake: *** [src/doscan.o] Error 1
MS>> >
MS>> > I wonder where /usr/local/include comes from. If I remove that it
MS>> > compiles smoothly.
MS>> Uhm, from you command line? What _this_ has to do with a compiler?
MS>This happens with g++ 3.x when the devel/libgnugetopt port is installed
MS>and both its getopt.h and the base unistd.h are included. There are
MS>several ports that have workarounds for this issue.
MS>I have a patch for devel/libgnugetopt at
MS>that should fix this issue by updating to the latest sources.
MS>In my opinion the right thing to do is however to also include
MS>getopt_long_only() in libc and not only getopt_long() so one can get
MS>rid of the devel/libgnugetopt port. I have a patch for this at
MS>When I have time I'll continue testing of both and eventually submit

getopt.h is broken. It should not define a Posix reserved name or the
application should not use any of the interfaces in unistd.h. You cannot
have both.

harti brandt,
brandt at fokus.fraunhofer.de, harti at freebsd.org

More information about the freebsd-current mailing list