pcloudcom / console-client

440 stars 131 forks source link

FreeBSD compilation #155

Open ToppDev opened 2 years ago

ToppDev commented 2 years ago

Issue description

Does not compile under FreeBSD.

Errors

  1. gcc -Wall -Wpointer-arith -O2 -g -fno-stack-protector -fomit-frame-pointer -mtune=core2 -I../sqlite -DP_ELECTRON -fPIC -DP_SSL_MBEDTLS -I../mbedtls/include   -c -o pcompat.o pcompat.c
    pcompat.c: In function 'connect_socket_direct':
    pcompat.c:1405:22: error: 'IPPROTO_TCP' undeclared (first use in this function)
     1405 |     setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (char  *)&sock_opt, sizeof(sock_opt));
          |                      ^~~~~~~~~~~
  2. pcompat.c:1406:35: error: 'TCP_KEEPALIVE' undeclared (first use in this function); did you mean 'SO_KEEPALIVE'?
     1406 |     setsockopt(sock, IPPROTO_TCP, TCP_KEEPALIVE, (char*)&sock_opt, sizeof(sock_opt));
          |                                   ^~~~~~~~~~~~~
          |                                   SO_KEEPALIVE

    After applying the fixes from Possible solutions section below, I get

  3. In file included from psynclib.c:32:
    pcallbacks.h:36:33: error: expected ')' before '*' token
       36 | typedef void(/*_cdecl*/__stdcall *data_event_callback)(int eventId, char* str1, char* str2, uint64_t uint1, uint64_t uint2);
          |                                 ^~
          |                                 )
  4. psynclib.c:2689:33: error: 'DELIM_DIR' undeclared (first use in this function)
     2689 |   parse_os_path(path, &folders, DELIM_DIR, 1);
          |                                 ^~~~~~~~~

Steps to reproduce the issue

$ pkg install git cmake gmake gcc lzlib boost-libs libpthread-stubs
$ git clone https://github.com/pcloudcom/console-client.git ./console-client/
$ cd ./console-client/pCloudCC/
$ cd lib/pclsync/
$ gmake clean
$ gmake fs

Possible solutions

  1. I read somewhere that

    IPPROTO_TCP is defined in netinet/in.h by the POSIX standard.

    So adding the following include to the pcompat.c file solved the problem with the undefined IPPROTO_TCP

    #include <netinet/in.h>
  2. The undefined TCP_KEEPALIVE I am not sure about, but I also read somewhere that maybe it should be TCP_KEEPIDLE on FreeBSD

For the errors 3. and 4. I did not come up with a solution yet. So hopefully someone can help.

Environment