From 57104e5d75419444285a16be29c9c07f981a2b6b Mon Sep 17 00:00:00 2001
From: Anders Blomdell <anders.blomdell@gmail.com>
Date: Thu, 14 Mar 2019 23:21:44 +0100
Subject: [PATCH] Fix dlopen problems with old comedilib

---
 moberg_device.c         | 4 ++--
 plugins/comedi/Makefile | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/moberg_device.c b/moberg_device.c
index 850d76e..038974b 100644
--- a/moberg_device.c
+++ b/moberg_device.c
@@ -61,9 +61,9 @@ struct moberg_device *moberg_device_new(struct moberg *moberg,
   char *name = malloc(strlen("libmoberg_.so") + strlen(driver) + 1);
   if (!name) { goto out; }
   sprintf(name, "libmoberg_%s.so", driver);
-  void *handle = dlopen(name, RTLD_LAZY || RTLD_DEEPBIND);
+  void *handle = dlopen(name, RTLD_LAZY | RTLD_DEEPBIND);
   if (! handle) {
-    fprintf(stderr, "Could not find driver %s\n", name);
+    fprintf(stderr, "Could not find driver %s %s\n", name, dlerror());
     goto free_name;
   }
   struct moberg_device_driver *device_driver =
diff --git a/plugins/comedi/Makefile b/plugins/comedi/Makefile
index 346e576..66f7670 100644
--- a/plugins/comedi/Makefile
+++ b/plugins/comedi/Makefile
@@ -1,7 +1,7 @@
 LIBRARIES=libmoberg_comedi.so
 CCFLAGS+=-Wall -Werror -I../.. -I. -O3 -g -fPIC
 LDFLAGS+=-Lbuild/ -lmoberg
-LDFLAGS_comedi=-shared -fPIC -L../../build -lmoberg  
+LDFLAGS_comedi=-shared -fPIC -L../../build -lmoberg -lcomedi -lm  
 
 all:	$(LIBRARIES:%=build/%)
 
-- 
GitLab