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

Build fails on FreeBSD: error: use of undeclared identifier 'PF_INET' #548

Closed
VVD opened this issue Jan 18, 2023 · 3 comments
Closed

Build fails on FreeBSD: error: use of undeclared identifier 'PF_INET' #548

VVD opened this issue Jan 18, 2023 · 3 comments
Assignees

Comments

@VVD
Copy link

VVD commented Jan 18, 2023

Describe the bug
Compile of 0.9.14 fails on FreeBSD, but 0.9.13 build without errors.

To Reproduce
Compile 0.9.14.

Expected Behavior
Compile without errors.

Logs/Backtraces

/tmp/work/usr/ports/net/libvncserver/work/libvncserver-LibVNCServer-0.9.14/client_examples/sshtunnel.c:56:18: warning: implicit declaration of function 'accept' is invalid in C99 [-Wimplicit-function-declaration]
    proxy_sock = accept(data->local_listensock, (struct sockaddr *)&sin, &sinlen);
                 ^
/tmp/work/usr/ports/net/libvncserver/work/libvncserver-LibVNCServer-0.9.14/client_examples/sshtunnel.c:63:5: warning: implicit declaration of function 'close' is invalid in C99 [-Wimplicit-function-declaration]
    rfbCloseSocket(data->local_listensock);
    ^
/tmp/work/usr/ports/net/libvncserver/work/libvncserver-LibVNCServer-0.9.14/rfb/rfbproto.h:117:6: note: expanded from macro 'rfbCloseSocket'
            _rfbCloseSocket(s);         \
            ^
/tmp/work/usr/ports/net/libvncserver/work/libvncserver-LibVNCServer-0.9.14/rfb/rfbproto.h:107:25: note: expanded from macro '_rfbCloseSocket'
#define _rfbCloseSocket close
                        ^
/tmp/work/usr/ports/net/libvncserver/work/libvncserver-LibVNCServer-0.9.14/client_examples/sshtunnel.c:94:19: warning: implicit declaration of function 'recv' is invalid in C99 [-Wimplicit-function-declaration]
            len = recv(proxy_sock, buf, sizeof(buf), 0);
                  ^
/tmp/work/usr/ports/net/libvncserver/work/libvncserver-LibVNCServer-0.9.14/client_examples/sshtunnel.c:127:21: warning: implicit declaration of function 'send' is invalid in C99 [-Wimplicit-function-declaration]
                i = send(proxy_sock, buf + wr, len - wr, 0);
                    ^
/tmp/work/usr/ports/net/libvncserver/work/libvncserver-LibVNCServer-0.9.14/client_examples/sshtunnel.c:146:5: warning: implicit declaration of function 'close' is invalid in C99 [-Wimplicit-function-declaration]
    rfbCloseSocket(proxy_sock);
    ^
/tmp/work/usr/ports/net/libvncserver/work/libvncserver-LibVNCServer-0.9.14/rfb/rfbproto.h:117:6: note: expanded from macro 'rfbCloseSocket'
            _rfbCloseSocket(s);         \
            ^
/tmp/work/usr/ports/net/libvncserver/work/libvncserver-LibVNCServer-0.9.14/rfb/rfbproto.h:107:25: note: expanded from macro '_rfbCloseSocket'
#define _rfbCloseSocket close
                        ^
/tmp/work/usr/ports/net/libvncserver/work/libvncserver-LibVNCServer-0.9.14/client_examples/sshtunnel.c:154:5: warning: implicit declaration of function 'close' is invalid in C99 [-Wimplicit-function-declaration]
    rfbCloseSocket(data->ssh_sock);
    ^
/tmp/work/usr/ports/net/libvncserver/work/libvncserver-LibVNCServer-0.9.14/rfb/rfbproto.h:117:6: note: expanded from macro 'rfbCloseSocket'
            _rfbCloseSocket(s);         \
            ^
/tmp/work/usr/ports/net/libvncserver/work/libvncserver-LibVNCServer-0.9.14/rfb/rfbproto.h:107:25: note: expanded from macro '_rfbCloseSocket'
#define _rfbCloseSocket close
                        ^
/tmp/work/usr/ports/net/libvncserver/work/libvncserver-LibVNCServer-0.9.14/client_examples/sshtunnel.c:213:22: warning: implicit declaration of function 'socket' is invalid in C99 [-Wimplicit-function-declaration]
    data->ssh_sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
                     ^
/tmp/work/usr/ports/net/libvncserver/work/libvncserver-LibVNCServer-0.9.14/client_examples/sshtunnel.c:213:29: error: use of undeclared identifier 'PF_INET'
    data->ssh_sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
                            ^
/tmp/work/usr/ports/net/libvncserver/work/libvncserver-LibVNCServer-0.9.14/client_examples/sshtunnel.c:213:38: error: use of undeclared identifier 'SOCK_STREAM'
    data->ssh_sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
                                     ^
/tmp/work/usr/ports/net/libvncserver/work/libvncserver-LibVNCServer-0.9.14/client_examples/sshtunnel.c:220:25: error: use of undeclared identifier 'AF_INET'
    hints.ai_family   = AF_INET;
                        ^
/tmp/work/usr/ports/net/libvncserver/work/libvncserver-LibVNCServer-0.9.14/client_examples/sshtunnel.c:221:25: error: use of undeclared identifier 'SOCK_STREAM'
    hints.ai_socktype = SOCK_STREAM;
                        ^
/tmp/work/usr/ports/net/libvncserver/work/libvncserver-LibVNCServer-0.9.14/client_examples/sshtunnel.c:224:19: error: use of undeclared identifier 'AF_INET'
        sin.sin_family = AF_INET;
                         ^
/tmp/work/usr/ports/net/libvncserver/work/libvncserver-LibVNCServer-0.9.14/client_examples/sshtunnel.c:233:8: warning: implicit declaration of function 'connect' is invalid in C99 [-Wimplicit-function-declaration]
    if(connect(data->ssh_sock, (struct sockaddr*)(&sin), sizeof(struct sockaddr_in)) != 0) {
       ^
/tmp/work/usr/ports/net/libvncserver/work/libvncserver-LibVNCServer-0.9.14/client_examples/sshtunnel.c:288:37: error: use of undeclared identifier 'PF_INET'
    data->local_listensock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
                                    ^
/tmp/work/usr/ports/net/libvncserver/work/libvncserver-LibVNCServer-0.9.14/client_examples/sshtunnel.c:288:46: error: use of undeclared identifier 'SOCK_STREAM'
    data->local_listensock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
                                             ^
/tmp/work/usr/ports/net/libvncserver/work/libvncserver-LibVNCServer-0.9.14/client_examples/sshtunnel.c:293:22: error: use of undeclared identifier 'AF_INET'
    sin.sin_family = AF_INET;
                     ^
/tmp/work/usr/ports/net/libvncserver/work/libvncserver-LibVNCServer-0.9.14/client_examples/sshtunnel.c:301:14: warning: implicit declaration of function 'bind' is invalid in C99 [-Wimplicit-function-declaration]
    if(-1 == bind(data->local_listensock, (struct sockaddr *)&sin, sinlen)) {
             ^
/tmp/work/usr/ports/net/libvncserver/work/libvncserver-LibVNCServer-0.9.14/client_examples/sshtunnel.c:305:14: warning: implicit declaration of function 'listen' is invalid in C99 [-Wimplicit-function-declaration]
    if(-1 == listen(data->local_listensock, 1)) {
             ^
/tmp/work/usr/ports/net/libvncserver/work/libvncserver-LibVNCServer-0.9.14/client_examples/sshtunnel.c:311:9: warning: implicit declaration of function 'getsockname' is invalid in C99 [-Wimplicit-function-declaration]
    if (getsockname(data->local_listensock, (struct sockaddr *)&sin, &sinlen ) == -1){
        ^
/tmp/work/usr/ports/net/libvncserver/work/libvncserver-LibVNCServer-0.9.14/client_examples/sshtunnel.c:340:5: warning: implicit declaration of function 'close' is invalid in C99 [-Wimplicit-function-declaration]
    rfbCloseSocket(data->local_listensock);
    ^
/tmp/work/usr/ports/net/libvncserver/work/libvncserver-LibVNCServer-0.9.14/rfb/rfbproto.h:117:6: note: expanded from macro 'rfbCloseSocket'
            _rfbCloseSocket(s);         \
            ^
/tmp/work/usr/ports/net/libvncserver/work/libvncserver-LibVNCServer-0.9.14/rfb/rfbproto.h:107:25: note: expanded from macro '_rfbCloseSocket'
#define _rfbCloseSocket close
                        ^
/tmp/work/usr/ports/net/libvncserver/work/libvncserver-LibVNCServer-0.9.14/client_examples/sshtunnel.c:341:5: warning: implicit declaration of function 'close' is invalid in C99 [-Wimplicit-function-declaration]
    rfbCloseSocket(data->ssh_sock);
    ^
/tmp/work/usr/ports/net/libvncserver/work/libvncserver-LibVNCServer-0.9.14/rfb/rfbproto.h:117:6: note: expanded from macro 'rfbCloseSocket'
            _rfbCloseSocket(s);         \
            ^
/tmp/work/usr/ports/net/libvncserver/work/libvncserver-LibVNCServer-0.9.14/rfb/rfbproto.h:107:25: note: expanded from macro '_rfbCloseSocket'
#define _rfbCloseSocket close
                        ^
/tmp/work/usr/ports/net/libvncserver/work/libvncserver-LibVNCServer-0.9.14/client_examples/sshtunnel.c:423:6: warning: implicit declaration of function 'close' is invalid in C99 [-Wimplicit-function-declaration]
            rfbCloseSocket(client->sock);
            ^
/tmp/work/usr/ports/net/libvncserver/work/libvncserver-LibVNCServer-0.9.14/rfb/rfbproto.h:117:6: note: expanded from macro 'rfbCloseSocket'
            _rfbCloseSocket(s);         \
            ^
/tmp/work/usr/ports/net/libvncserver/work/libvncserver-LibVNCServer-0.9.14/rfb/rfbproto.h:107:25: note: expanded from macro '_rfbCloseSocket'
#define _rfbCloseSocket close
                        ^
14 warnings and 8 errors generated.

Your environment (please complete the following information):

  • OS and version: FreeBSD 13.1-p5 amd64
  • Compiler and version: clang 13

Additional context
Issue on FreeBSD's bugtracker: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=269039
accept require #include <sys/types.h> and #include <sys/socket.h>: https://www.freebsd.org/cgi/man.cgi?query=accept&sektion=2
close require #include <unistd.h>: https://www.freebsd.org/cgi/man.cgi?query=close&sektion=2

Patch:

--- client_examples/sshtunnel.c.orig
+++ client_examples/sshtunnel.c
@@ -10,6 +10,11 @@
  *  - added name resolution for the ssh host
  */

+#ifdef __FreeBSD__
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <unistd.h>
+#endif
 #include <rfb/rfbclient.h>
 #include <libssh2.h>
 #include <arpa/inet.h>
@VVD VVD added the bug label Jan 18, 2023
@bk138 bk138 self-assigned this Jan 19, 2023
@bk138 bk138 added this to the Release 0.9.15 milestone Jan 19, 2023
@bk138 bk138 added the building label Jan 19, 2023
@VVD
Copy link
Author

VVD commented Jan 19, 2023

Configure stage silent "grab" libssh2 if it installed:

If libssh2 not installed:
Could NOT find LibSSH2 (missing: LIBSSH2_LIBRARY LIBSSH2_INCLUDE_DIR)

If libssh2 installed:
-- Found LibSSH2: /usr/local/lib/libssh2.so (found version "1.10.0")

What purpose of the file client_examples/sshtunnel.c for build libvncserver?
If it's just example, maybe remove it from default build and other examples too?

@bk138
Copy link
Member

bk138 commented Jan 19, 2023

What purpose of the file client_examples/sshtunnel.c for build libvncserver? If it's just example, maybe remove it from default build and other examples too?

As the dir implies, it's an example. You can build without examples if wanted.

@bk138 bk138 closed this as completed in 6408d56 Jan 22, 2023
@bk138
Copy link
Member

bk138 commented Jan 22, 2023

@VVD I now fixed it by checking header availability #ifdefs, not OS-specific ones. Should work for you as well me thinks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants