Skip to content

common/gattlib_common_adapter.c:15:17: error: implicit declaration of function 'tolower' #293

@brettski74

Description

@brettski74

Trying to build gattlib-0.7.2 using the tarball downloaded from https://github.com/labapart/gattlib/archive/refs/tags/0.7.2.tar.gz. Got the following output and failure during compilation:

==> Making package: gattlib 0.7.2-1 (Wed 02 Jul 2025 05:27:51 PM)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> Retrieving sources...
-> Found gattlib-0.7.2.tar.gz
==> Validating source files with sha256sums...
gattlib-0.7.2.tar.gz ... Passed
==> Extracting sources...
-> Extracting gattlib-0.7.2.tar.gz with bsdtar
==> Removing existing $pkgdir/ directory...
==> Starting build()...
-- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE)
Build DBus gattlib for Bluez v5.83
Package Gattlib for development version
-- Configuring done (0.1s)
-- Generating done (0.0s)
-- Build files have been written to: /home/blg/pkgbuilds/gattlib/src/gattlib-0.7.2/build
[ 2%] Building C object dbus/CMakeFiles/gattlib.dir//common/gattlib_common_adapter.c.o
/home/blg/pkgbuilds/gattlib/src/gattlib-0.7.2/common/gattlib_common_adapter.c: In function ‘stricmp’:
/home/blg/pkgbuilds/gattlib/src/gattlib-0.7.2/common/gattlib_common_adapter.c:15:17: error: implicit declaration of function ‘tolower’ [-Wimplicit-function-declaration]
15 | int d = tolower((unsigned char)*a) - tolower((unsigned char)*b);
| ^~~~~~~
/home/blg/pkgbuilds/gattlib/src/gattlib-0.7.2/common/gattlib_common_adapter.c:8:1: note: include ‘<ctype.h>’ or provide a declaration of ‘tolower’
7 | #include "gattlib_internal.h"
+++ |+#include <ctype.h>
8 |
make[2]: *** [dbus/CMakeFiles/gattlib.dir/build.make:215: dbus/CMakeFiles/gattlib.dir/
/common/gattlib_common_adapter.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:267: dbus/CMakeFiles/gattlib.dir/all] Error 2
make: *** [Makefile:156: all] Error 2
==> ERROR: A failure occurred in build().
Aborting...

The build was being run from within makepkg on a recently updated Arch Linux using a PKGBUILD file with the following build commands:

build() {
cd "$srcdir/$pkgname-$pkgver"
mkdir -p build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=/usr
make
}

Adding the ctype.h include as suggested in the note resolved the error and the build completed successfully. I've generated the following patch for the change:

--- gattlib-0.7.2/common/gattlib_common_adapter.c 2024-04-24 08:37:28.000000000 -0400
+++ ../src/gattlib-0.7.2/common/gattlib_common_adapter.c 2025-07-02 17:31:16.000000000 -0400
@@ -4,6 +4,7 @@

+#include <ctype.h>
#include "gattlib_internal.h"

// Keep track of the allocated adapters to avoid an adapter to be freed twice.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions