Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i2c 4.0 breaks current assumptions in configure #2646

Closed
cpaelzer opened this issue Jan 11, 2018 · 2 comments
Closed

i2c 4.0 breaks current assumptions in configure #2646

cpaelzer opened this issue Jan 11, 2018 · 2 comments

Comments

@cpaelzer
Copy link
Contributor

  • Version of collectd: 5.7.2
  • Operating system / distribution: Ubuntu

Expected behavior

Configure works

Actual behavior

Configure fails to detect i2c:

configure:43292: x86_64-linux-gnu-gcc -c -g -O2 -fdebug-prefix-map=/<<PKGBUILDDIR>>=. -fstack-protector-strong -Wformat -Werror=format-security -Wall -Wno-error=deprecated-declarations -Wdate-time -D_FORTIFY_SOURCE=2 -I/<<PKGBUILDDIR>>/debian/include -UCONFIGFILE -DCONFIGFILE='"/etc/collectd/collectd.conf"' conftest.c >&5
conftest.c: In function 'main':
conftest.c:284:10: error: 'i2c_smbus_read_i2c_block_data' undeclared (first use in this function); did you mean 'i2c_smbus_ioctl_data'?
   (void) i2c_smbus_read_i2c_block_data;
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          i2c_smbus_ioctl_data

Steps to reproduce

  • build collectd against libi2c-dev 4.0-2 or later

The actual i2c detection doesn't break it which might make this less detected at first.
But if you have e.g. barometer enabled it fill fail via dependency error which makes it fatal.

Reason this happens

in i2c these methods were moved to a proper library

commit 251d594fd0d338c7b85707a2e72153a404a25b10
Author: Jean Delvare jdelvare@suse.de
Date: Mon May 21 16:52:48 2012 +0000

New library for I2C device access under Linux. As a first step, the
library will host the i2c_smbus_*() inline functions which were
previously in the user-space flavor of <linux/i2c-dev.h>.

So there now is a proper -li2c to be used to be able to get to those symbols.
I'm not a configure magician enough to get that fixed fast, but at least wanted to report so you can take a look.

@cpaelzer
Copy link
Contributor Author

Not fully matching current master, so no PR, but seems to work on test packaging builds, so FYI:

Description: configure: barometer: fix i2c lib usage for 4.0

The newer libi2c separated some symbols.
Thanks ahasenack for the patch.

Forwarded: yes (ML entry)/no(reason) if created new, otherwise line not needed
Author: Andreas Hasenack <andreas.hasenack@canonical.com>
Bug-Ubuntu: https://bugs.launchpad.net/bugs/1742691
Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=886920
Last-Update: 2018-01-14

--- a/configure.ac
+++ b/configure.ac
@@ -6216,7 +6216,7 @@ AC_CHECK_DECL(i2c_smbus_read_i2c_block_d
        [with_libi2c="yes"],
        [with_libi2c="no (symbol i2c_smbus_read_i2c_block_data not found - have you installed libi2c-dev ?)"],
        [[#include <stdlib.h>
-       #include <linux/i2c-dev.h>]])
+       #include <i2c/smbus.h>]])
 else
        with_libi2c="no (Linux only)"
 fi
--- a/src/barometer.c
+++ b/src/barometer.c
@@ -27,6 +27,7 @@
 
 #include <fcntl.h>
 #include <linux/i2c-dev.h>
+#include <i2c/smbus.h>
 #include <math.h>
 #include <stdint.h>
 #include <sys/ioctl.h>
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -232,7 +232,7 @@ if BUILD_PLUGIN_BAROMETER
 pkglib_LTLIBRARIES += barometer.la
 barometer_la_SOURCES = barometer.c
 barometer_la_LDFLAGS = $(PLUGIN_LDFLAGS)
-barometer_la_LIBADD = -lm
+barometer_la_LIBADD = -lm -li2c
 endif
 
 if BUILD_PLUGIN_BATTERY

rpv-tomsk added a commit to rpv-tomsk/collectd that referenced this issue May 19, 2018
rpv-tomsk added a commit to rpv-tomsk/collectd that referenced this issue May 19, 2018
@rpv-tomsk
Copy link
Contributor

Many thanks, Christian!
I made a PR based mainly on provided patch, and this issue is almost solved.

codesmith14 pushed a commit to signalfx/collectd that referenced this issue Jun 15, 2018
nmdayton pushed a commit to Stackdriver/collectd that referenced this issue Jan 17, 2019
nmdayton pushed a commit to Stackdriver/collectd that referenced this issue Jan 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants