DIGImend / hidrd

HID report descriptor I/O library and conversion tool
GNU General Public License v2.0
171 stars 29 forks source link

How to build? #29

Open kevinlieb opened 3 years ago

kevinlieb commented 3 years ago

Can someone include a "how to build" section for NOOBS in the makefile?

I tried: autoreconf and it doesn't work. I get errors like: configure.ac:47: error: required file 'auxdir/ar-lib' not found

T-vK commented 3 years ago

If you use the latest release (v0.2.0), you first need to fix it. Open lib/fmt/xml/snk/element.c, search for this line:

                (void)va_arg(*pap, const char *);

and add the following line directly below that:

                /* FALLTHROUGH */

The you can build and install it like this:

./configure && make 
make install

I got some permission errors when running make install. In that case doing sudo make install appeared to do the trick. But be warned, I have no idea if there are any side effects.

You should find the compiled binary in src/hidrd-convert.

kirvedx commented 1 year ago

For me, I was able to almost build it with:

  1. Clone the repository and switch to it
  2. You'll find that ./configure doesn't work, let's fix that: A. Run autoconf, but this will likely fail B. Run automake, but this will likely fail too C. Run automake --add-missing, but this again, will likely fail D. Run autoreconf --force --install, this should succeed
  3. Run ./configure
  4. Run make, you'll likely get an error that warnings are treated as errors, let's fix the underlying issue: A. Open ./lib/fmt/xml/snk/element.c and traverse to line 231. B. Change the code from:

    
              case XML_SNK_ELEMENT_NT_ATTR:
                  /* Retrieve name */
                  (void)va_arg(*pap, const char *);
              case XML_SNK_ELEMENT_NT_COMMENT:

    to

    
              case XML_SNK_ELEMENT_NT_ATTR:
                  /* Retrieve name */
                  (void)va_arg(*pap, const char *);
                  [[fallthrough]];
              case XML_SNK_ELEMENT_NT_COMMENT:
  5. Run make, however, multiple definition errors now appear - so the program doesn't get through the linker.
    libhidrd_fmt.so.0 -o .libs/libhidrd_fmt.so.0.0.0
    /usr/bin/ld: .libs/libhidrd_fmt_la-natv.o:(.rodata+0x0): multiple definition of `hidrd_natv_snk'; .libs/libhidrd_fmt_la-list.o:(.rodata+0xc0): first defined here
    /usr/bin/ld: .libs/libhidrd_fmt_la-spec.o:(.rodata+0x0): multiple definition of `hidrd_spec_snk'; .libs/libhidrd_fmt_la-list.o:(.rodata+0x60): first defined here
    /usr/bin/ld: .libs/libhidrd_fmt_la-code.o:(.rodata+0x0): multiple definition of `hidrd_code_snk'; .libs/libhidrd_fmt_la-list.o:(.rodata+0x0): first defined here
    /usr/bin/ld: .libs/libhidrd_fmt_la-code.o:(.rodata+0x60): multiple definition of `hidrd_spec_snk'; .libs/libhidrd_fmt_la-list.o:(.rodata+0x60): first defined here
    /usr/bin/ld: natv/.libs/libhidrd_natv.a(snk.o):(.data.rel.ro.local+0x0): multiple definition of `hidrd_natv_snk'; .libs/libhidrd_fmt_la-list.o:(.rodata+0xc0): first defined here
    /usr/bin/ld: spec/.libs/libhidrd_spec.a(snk.o):(.data.rel.ro+0x0): multiple definition of `hidrd_spec_snk'; .libs/libhidrd_fmt_la-list.o:(.rodata+0x60): first defined here
    /usr/bin/ld: spec/.libs/libhidrd_spec.a(item.o):(.rodata+0x60): multiple definition of `hidrd_spec_snk'; .libs/libhidrd_fmt_la-list.o:(.rodata+0x60): first defined here
    /usr/bin/ld: spec/.libs/libhidrd_spec.a(item_ent.o):(.rodata+0x0): multiple definition of `hidrd_spec_snk'; .libs/libhidrd_fmt_la-list.o:(.rodata+0x60): first defined here
    /usr/bin/ld: code/.libs/libhidrd_code.a(snk.o):(.data.rel.ro+0x0): multiple definition of `hidrd_code_snk'; .libs/libhidrd_fmt_la-list.o:(.rodata+0x0): first defined here
    /usr/bin/ld: code/.libs/libhidrd_code.a(snk.o):(.rodata+0x0): multiple definition of `hidrd_spec_snk'; .libs/libhidrd_fmt_la-list.o:(.rodata+0x60): first defined here
    collect2: error: ld returned 1 exit status
    make[4]: *** [Makefile:827: libhidrd_fmt.la] Error 1
    make[4]: Leaving directory '/home/rik/Downloads/hidrd-0.2.0/lib/fmt'
    make[3]: *** [Makefile:1021: all-recursive] Error 1
    make[3]: Leaving directory '/home/rik/Downloads/hidrd-0.2.0/lib/fmt'
    make[2]: *** [Makefile:377: all-recursive] Error 1
    make[2]: Leaving directory '/home/rik/Downloads/hidrd-0.2.0/lib'
    make[1]: *** [Makefile:428: all-recursive] Error 1
    make[1]: Leaving directory '/home/rik/Downloads/hidrd-0.2.0'
    make: *** [Makefile:360: all] Error 2

I've given up and chosen instead to use this online tool for converting hid descriptors to human readable format. Debian removed it altogether from all sources - nothing else really works in its place. hid-tools instructions violate Debian's 'externally manage' environment, and isn't available as python3-hidtools nor as any variation, seems it's just not a popular enough sort of tool at all. At that link I posted they're using the "official " spec for implementing a tool to work with device descriptors - so if you're trying to provide information for supporting devices to something on linux -- they should be able to work with that.

tmk commented 1 year ago

With this change the command can be compiled on Ubuntu 22.04.3 LTS.

$ autoreconf --force --install
$ ./configure
$ make
$ ls src/hidrd-convert
diff --git a/configure.ac b/configure.ac
index 962d4af..8df68ba 100644
--- a/configure.ac
+++ b/configure.ac
@@ -19,11 +19,12 @@
 #
 # Process this file with autoconf to produce a configure script.

-AC_PREREQ(2.61)
+AC_PREREQ([2.69])
 AC_INIT([hidrd], [0.2])
 AC_CONFIG_AUX_DIR([auxdir])
 AM_INIT_AUTOMAKE([1.9 -Wall foreign])
-AC_CONFIG_HEADER([config.h])
+AC_CONFIG_SRCDIR([config.h.in])
+AC_CONFIG_HEADERS([config.h])
 AC_CONFIG_MACRO_DIR([m4/autoconf])

 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
@@ -42,8 +43,14 @@ fi
 #
 # Checks for programs.
 #
+AC_PROG_CXX
+AC_PROG_AWK
 AC_PROG_CC
+AC_PROG_CPP
 AC_PROG_INSTALL
+AC_PROG_LN_S
+AC_PROG_MAKE_SET
+AC_PROG_RANLIB
 m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
 LT_INIT

@@ -227,10 +234,22 @@ fi
 #
 # Checks for header files.
 #
+AC_CHECK_HEADERS([fcntl.h limits.h stddef.h stdint.h stdlib.h string.h strings.h unistd.h])

 #
 # Checks for typedefs, structures, and compiler characteristics.
 #
+AC_CHECK_HEADER_STDBOOL
+AC_C_INLINE
+AC_TYPE_INT16_T
+AC_TYPE_INT32_T
+AC_TYPE_INT8_T
+AC_FUNC_OBSTACK
+AC_TYPE_SIZE_T
+AC_TYPE_SSIZE_T
+AC_TYPE_UINT16_T
+AC_TYPE_UINT32_T
+AC_TYPE_UINT8_T

 #
 # Checks for declarations
@@ -247,6 +266,10 @@ fi
 #
 # Checks for library functions.
 #
+AC_FUNC_ERROR_AT_LINE
+AC_FUNC_MALLOC
+AC_FUNC_REALLOC
+AC_CHECK_FUNCS([memset strcasecmp strdup strerror strncasecmp strtol strtoul])

 #
 # Output