Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build on FreeBSD #19

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Fix build on FreeBSD #19

wants to merge 1 commit into from

Conversation

yzgyyang
Copy link

The include directive of netinet/in.h must be before resolv.h on FreeBSD, otherwise, the following errors will occur:

In file included from dns.c:265:
/usr/include/resolv.h:159:14: error: array has incomplete element type 'struct sockaddr_in'
                nsaddr_list[MAXNS];     /*%< address of name server */
                           ^
/usr/include/resolv.h:158:9: note: forward declaration of 'struct sockaddr_in'
        struct sockaddr_in
               ^
/usr/include/resolv.h:173:18: error: field has incomplete type 'struct in_addr'
                struct in_addr  addr;
                                ^
/usr/include/resolv.h:173:10: note: forward declaration of 'struct in_addr'
                struct in_addr  addr;
                       ^
/usr/include/resolv.h:198:21: error: field has incomplete type 'struct sockaddr_in'
        struct sockaddr_in      sin;
                                ^
/usr/include/resolv.h:158:9: note: forward declaration of 'struct sockaddr_in'
        struct sockaddr_in
               ^
3 errors generated.

The reason is that the resolv.h on FreeBSD is not yet self-contained, see this bug report: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=182466

This fix was committed with the FreeBSD port net/R-cran-pingr in https://cgit.freebsd.org/ports/commit/?id=fce80f530301d0079d84bc4b818ba957ad29617b.

src/dns.c Outdated Show resolved Hide resolved
@yzgyyang yzgyyang changed the title Fix dns.c on FreeBSD Fix build on FreeBSD Jan 14, 2022
@yzgyyang
Copy link
Author

@gaborcsardi There is actually one last thing to fix for FreeBSD build - -lresolv is not needed for FreeBSD since it is in libc. So,

PKG_LIBS = -lresolv
will raise an error during build. To fix it, just an empty PKG_LIBS would work, but I do not know Makevars enough to have a platform-specific fix there. What do you think?

@gaborcsardi
Copy link
Member

Re -lresolv I am afraid that means that we need a configure file, not autoconf, just a simple shell script, that creates Makevars.

The include directive of `netinet/in.h` must be before `resolv.h` on FreeBSD, otherwise, the following errors will occur:

```
In file included from dns.c:265:
/usr/include/resolv.h:159:14: error: array has incomplete element type 'struct sockaddr_in'
                nsaddr_list[MAXNS];     /*%< address of name server */
                           ^
/usr/include/resolv.h:158:9: note: forward declaration of 'struct sockaddr_in'
        struct sockaddr_in
               ^
/usr/include/resolv.h:173:18: error: field has incomplete type 'struct in_addr'
                struct in_addr  addr;
                                ^
/usr/include/resolv.h:173:10: note: forward declaration of 'struct in_addr'
                struct in_addr  addr;
                       ^
/usr/include/resolv.h:198:21: error: field has incomplete type 'struct sockaddr_in'
        struct sockaddr_in      sin;
                                ^
/usr/include/resolv.h:158:9: note: forward declaration of 'struct sockaddr_in'
        struct sockaddr_in
               ^
3 errors generated.
```

The reason is that the `resolv.h` on FreeBSD is not yet self-contained, see this bug report: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=182466

This fix was committed with the FreeBSD port `net/R-cran-pingr` in https://cgit.freebsd.org/ports/commit/?id=fce80f530301d0079d84bc4b818ba957ad29617b.
@yzgyyang
Copy link
Author

Re -lresolv I am afraid that means that we need a configure file, not autoconf, just a simple shell script, that creates Makevars.

Sounds good - I opened #21 for this and will work on it later, and am fine with leaving it out of this PR for now.

@gaborcsardi
Copy link
Member

gaborcsardi commented Jan 14, 2022

Sounds good. I think we can add it to this PR, so that this PR fixed the compilation on FreeBSD. I might add it, it is fairly quick. (Well, I hope...)

@yzgyyang
Copy link
Author

Sounds good. I think we can add it to this PR, so that this PR fixed the compilation on FreeBSD. I might add it, it is fairly quick. (Well, I hope...)

Sounds good, please feel free to do that! I need to get some sleep now... zzzZ

@gaborcsardi gaborcsardi added the bug an unexpected problem or unintended behavior label Oct 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants