fuzziqersoftware / phosg

C++ helpers for some common tasks
18 stars 17 forks source link

build error on Alpine:latest #34

Closed PalasX closed 2 months ago

PalasX commented 2 months ago

This is happening in the build process for a docker image, even though it compiles fine on the hose Ubuntu 22.03LTS system.

20.99 Cloning into 'phosg'...
21.63 -- The C compiler identification is GNU 13.2.1
21.70 -- The CXX compiler identification is GNU 13.2.1
21.72 -- Detecting C compiler ABI info
21.80 -- Detecting C compiler ABI info - done
21.83 -- Check for working C compiler: /usr/bin/cc - skipped
21.83 -- Detecting C compile features
21.84 -- Detecting C compile features - done
21.84 -- Detecting CXX compiler ABI info
21.93 -- Detecting CXX compiler ABI info - done
21.97 -- Check for working CXX compiler: /usr/bin/c++ - skipped
21.97 -- Detecting CXX compile features
21.97 -- Detecting CXX compile features - done
21.97 -- Target architecture is x86_64
21.97 -- Configuring done (0.4s)
22.01 -- Generating done (0.0s)
22.02 -- Build files have been written to: /src/phosg
22.07 [  2%] Building CXX object CMakeFiles/phosg.dir/src/Arguments.cc.o
23.78 [  4%] Building CXX object CMakeFiles/phosg.dir/src/Encoding.cc.o
24.41 [  6%] Building CXX object CMakeFiles/phosg.dir/src/Filesystem.cc.o
27.01 [  8%] Building CXX object CMakeFiles/phosg.dir/src/Hash.cc.o
28.25 [ 10%] Building CXX object CMakeFiles/phosg.dir/src/Image.cc.o
30.50 [ 12%] Building CXX object CMakeFiles/phosg.dir/src/JSON.cc.o
33.96 [ 14%] Building CXX object CMakeFiles/phosg.dir/src/Network.cc.o
35.69 [ 16%] Building CXX object CMakeFiles/phosg.dir/src/Process.cc.o
38.28 [ 18%] Building CXX object CMakeFiles/phosg.dir/src/Random.cc.o
39.45 [ 20%] Building CXX object CMakeFiles/phosg.dir/src/Strings.cc.o
41.93 [ 22%] Building CXX object CMakeFiles/phosg.dir/src/Time.cc.o
42.94 /src/phosg/src/Time.cc: In function 'uint64_t phosg::now()':
42.94 /src/phosg/src/Time.cc:16:11: error: aggregate 'phosg::timeval t' has incomplete type and cannot be defined
42.94    16 |   timeval t;
42.94       |           ^
42.95 /src/phosg/src/Time.cc: In function 'std::string phosg::format_time(timeval*)':
42.95 /src/phosg/src/Time.cc:37:18: error: aggregate 'phosg::timeval local_tv' has incomplete type and cannot be defined
42.95    37 |   struct timeval local_tv;
42.95       |                  ^~~~~~~~
42.95 /src/phosg/src/Time.cc:40:18: error: cannot convert 'phosg::timeval*' to 'timeval*'
42.95    40 |     gettimeofday(tv, nullptr);
42.95       |                  ^~
42.95       |                  |
42.95       |                  phosg::timeval*
42.95 In file included from /src/phosg/src/Time.cc:3:
42.95 /usr/include/sys/time.h:11:19: note:   initializing argument 1 of 'int gettimeofday(timeval*, void*)'
42.95    11 | int gettimeofday (struct timeval *__restrict, void *__restrict);
42.95       |                   ^~~~~~~~~~~~~~~~~~~~~~~~~~
42.95 In file included from /src/phosg/src/Time.cc:1:
42.95 /src/phosg/src/Time.hh:12:32: note: class type 'phosg::timeval' is incomplete
42.95    12 | std::string format_time(struct timeval* tv = nullptr);
42.95       |                                ^~~~~~~
42.95 /src/phosg/src/Time.cc:43:18: error: invalid use of incomplete type 'struct phosg::timeval'
42.95    43 |   time_t sec = tv->tv_sec;
42.95       |                  ^~
42.95 /src/phosg/src/Time.hh:12:32: note: forward declaration of 'struct phosg::timeval'
42.95    12 | std::string format_time(struct timeval* tv = nullptr);
42.95       |                                ^~~~~~~
42.95 /src/phosg/src/Time.cc:54:31: error: invalid use of incomplete type 'struct phosg::timeval'
42.95    54 |       static_cast<uint16_t>(tv->tv_usec / 1000));
42.95       |                               ^~
42.95 /src/phosg/src/Time.hh:12:32: note: forward declaration of 'struct phosg::timeval'
42.95    12 | std::string format_time(struct timeval* tv = nullptr);
42.95       |                                ^~~~~~~
42.95 /src/phosg/src/Time.cc: At global scope:
42.95 /src/phosg/src/Time.cc:113:47: error: return type 'struct phosg::timeval' is incomplete
42.95   113 | struct timeval usecs_to_timeval(uint64_t usecs) {
42.95       |                                               ^
42.95 /src/phosg/src/Time.cc:113:16: error: ambiguating new declaration of 'void phosg::usecs_to_timeval(uint64_t)'
42.95   113 | struct timeval usecs_to_timeval(uint64_t usecs) {
42.95       |                ^~~~~~~~~~~~~~~~
42.95 /src/phosg/src/Time.hh:15:16: note: old declaration 'phosg::timeval phosg::usecs_to_timeval(uint64_t)'
42.95    15 | struct timeval usecs_to_timeval(uint64_t usecs);
42.95       |                ^~~~~~~~~~~~~~~~
42.95 /src/phosg/src/Time.cc: In function 'void phosg::usecs_to_timeval(uint64_t)':
42.95 /src/phosg/src/Time.cc:114:18: error: aggregate 'phosg::timeval tv' has incomplete type and cannot be defined
42.95   114 |   struct timeval tv;
42.95       |                  ^~
42.95 /src/phosg/src/Time.cc: In function 'uint64_t phosg::timeval_to_usecs(timeval&)':
42.95 /src/phosg/src/Time.cc:121:11: error: invalid use of incomplete type 'struct phosg::timeval'
42.95   121 |   return (tv.tv_sec * 1000000) + tv.tv_usec;
42.95       |           ^~
42.95 /src/phosg/src/Time.hh:12:32: note: forward declaration of 'struct phosg::timeval'
42.95    12 | std::string format_time(struct timeval* tv = nullptr);
42.95       |                                ^~~~~~~
42.95 /src/phosg/src/Time.cc:121:34: error: invalid use of incomplete type 'struct phosg::timeval'
42.95   121 |   return (tv.tv_sec * 1000000) + tv.tv_usec;
42.95       |                                  ^~
42.95 /src/phosg/src/Time.hh:12:32: note: forward declaration of 'struct phosg::timeval'
42.95    12 | std::string format_time(struct timeval* tv = nullptr);
42.95       |                                ^~~~~~~
43.05 make[2]: *** [CMakeFiles/phosg.dir/build.make:216: CMakeFiles/phosg.dir/src/Time.cc.o] Error 1
43.05 make[1]: *** [CMakeFiles/Makefile2:119: CMakeFiles/phosg.dir/all] Error 2
43.05 make: *** [Makefile:146: all] Error 2

the relevant portion of the dockerfile ::

RUN apk add procps build-base git libevent-dev cmake zlib-dev  && \
    git clone https://github.com/fuzziqersoftware/phosg.git && \
    cd /src/phosg && cmake . && make && make test && make install && cd .. && \
    rm -R /src/phosg && \
fuzziqersoftware commented 2 months ago

This should be fixed by edffb782, but I don't have the same build environment set up. Please try it again and let me know if it works now.

PalasX commented 2 months ago

Adding the include for sys/time.h solved the issue. Builds fine on Alpine now.

Weird, i thought that included got added like WAY back already? i was so sure i didnt even check. Sorry.

Thanks again for the AWESOME effort you've put into this project. its by far the easiest and most complete way to setup a local BB server for friends and family. You're a champion!