libcheck / check

A unit testing framework for C
GNU Lesser General Public License v2.1
1.07k stars 210 forks source link

arm-linux: undefined reference to `WIFSIGNALED' #144

Open Miaou opened 6 years ago

Miaou commented 6 years ago

In a cross compilation environment targeting arm-linux, linking libbcheck 0.11.0 fails after cmake .. && cmake --build . --target install:

Linking C executable check_check
../src/libcheck.a(check_run.c.o): In function `set_fork_info':
/tmp/check-0.11.0/src/check_run.c:569: undefined reference to `WIFSIGNALED'
/tmp/check-0.11.0/src/check_run.c:570: undefined reference to `WIFEXITED'
/tmp/check-0.11.0/src/check_run.c:571: undefined reference to `WEXITSTATUS'
/tmp/check-0.11.0/src/check_run.c:572: undefined reference to `WTERMSIG'
../src/libcheck.a(check_run.c.o): In function `waserror':
/tmp/check-0.11.0/src/check_run.c:714: undefined reference to `WIFSIGNALED'
/tmp/check-0.11.0/src/check_run.c:715: undefined reference to `WIFEXITED'
/tmp/check-0.11.0/src/check_run.c:716: undefined reference to `WEXITSTATUS'
/tmp/check-0.11.0/src/check_run.c:717: undefined reference to `WTERMSIG'

Adding #include <sys/wait.h> to src/check_run.c fixes the problem.

brarcher commented 6 years ago

Do you know if cross compiling with the configure script is successful? The CMake support was initially added to support non-Unix platforms (e.g. Windows), and is not as mature for *unix or cross compiling.

I see that there is a check in configure.ac for the sys/wait.h header, which then controls an optional include in libcompat.h that is included in check_run.c. There is no such check in the CMake scripts, which was likely overlooked as Windows does not support fork() so that code is never compiled.

If using the configure script is sufficient, then perhaps go with that. If not, and you are up for adding the necessary support to the CMake scripts, I'll gladly accept your fixes. (: