diff --git a/moberg_device.c b/moberg_device.c
index 850d76ea15092050e5a34069330553aeb09363b0..038974b237a964ae56425353383ac7c82b5ab9ad 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 346e57658e1ce12e114a43c655630b64729ff87d..66f7670e930c341af04ab2ab8cb96a0d710cd81d 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/%)