gphoto / libgphoto2

The libgphoto2 camera access and control library.
GNU Lesser General Public License v2.1
991 stars 317 forks source link

libgphoto2 2.5.30 fails to build with llvm-mingw on Windows (missing unistd.h include) #890

Closed trilader closed 1 year ago

trilader commented 1 year ago

While trying to build libgphoto2 2.5.30 using llvm-mingw inside an MSYS2 shell the build failed with an error: error: call to undeclared function 'ftruncate'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] in gphoto-file.c and also the same error in other places but with usleep instead of ftruncate.

Adding #include <unistd.h> in gphoto-file.c and also greping the source for usleep usage and adding the include to the files makes the build not fail. I've attached libgphoto2-add-unistd.patch for the relevant changes.

I've noticed that at least gphoto2-port-portability.h includes unistd.h but not on Windows. I'm not sure who usually provides usleep there.

I'm not sure if this is a libgphoto2 issue or if llvm-mingw is to blame here as it might behave differently from other MinGW based compilers (I've used gcc in the past).

msmeissn commented 1 year ago

thanks, i applied your patch.

hard to say whatt the cause was