Skip to contentSkip to conversation

fix static linking

PATCH New Riku Voipio 2 participants 2 messages Dec 8, 2015 – Dec 11, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix static linking

Static linking fails currently, as -lm and -lpthread are missing:

gcc -O2 -fPIC -O2 -L../libdm -L../lib -L../libdaemon/client -static -L../libdm/ioctl \
-o dmsetup.static dmsetup.o -ldevmapper -lrt
../libdm/ioctl/libdevmapper.a(libdm-stats.o): In function `dm_stats_create_region':
libdm-stats.c:(.text+0x2d69): undefined reference to log10' libdm-stats.c:(.text+0x2d6e): undefined reference to lround' ../libdm/ioctl/libdevmapper.a(pool.o): In function `dm_pool_create':
pool.c:(.text+0x134): undefined reference to pthread_mutex_lock' pool.c:(.text+0x14f): undefined reference to pthread_mutex_unlock'

---
 tools/Makefile.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/Makefile.in +1 -1
index d6e54f0..518a21a 100644
@@ -130,7 +130,7 @@ dmsetup: dmsetup.o $(top_builddir)/libdm/libdevmapper.$(LIB_SUFFIX)
 
 dmsetup.static: dmsetup.o $(interfacebuilddir)/libdevmapper.a
 	$(CC) $(CFLAGS) $(LDFLAGS) -static -L$(interfacebuilddir) \
-	      -o $@ dmsetup.o -ldevmapper $(STATIC_LIBS) $(LIBS)
+	      -o $@ dmsetup.o -ldevmapper $(M_LIBS) $(PTHREAD_LIBS) $(STATIC_LIBS) $(LIBS)
 
 all: device-mapper
 
Signature · 1 line
2.6.2
#1 lore raw

PATCH 1/1 fix static linking

Dne 8.12.2015 v 15:40 Riku Voipio napsal(a):

Quoted 23 lines

Static linking fails currently, as -lm and -lpthread are missing:

gcc -O2 -fPIC -O2 -L../libdm -L../lib -L../libdaemon/client -static -L../libdm/ioctl \
-o dmsetup.static dmsetup.o -ldevmapper -lrt
../libdm/ioctl/libdevmapper.a(libdm-stats.o): In function `dm_stats_create_region':
libdm-stats.c:(.text+0x2d69): undefined reference to log10' libdm-stats.c:(.text+0x2d6e): undefined reference to lround' ../libdm/ioctl/libdevmapper.a(pool.o): In function `dm_pool_create':
pool.c:(.text+0x134): undefined reference to pthread_mutex_lock' pool.c:(.text+0x14f): undefined reference to pthread_mutex_unlock'

---
  tools/Makefile.in | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
tools/Makefile.in +0 -0
index d6e54f0..518a21a 100644

tools/Makefile.in dmsetup: dmsetup.o $(top_builddir)/libdm/libdevmapper.$(LIB_SUFFIX) · line 135

Quoted 7 lines
tools/Makefile.in +1 -1
@@ -130,7 +130,7 @@ dmsetup: dmsetup.o $(top_builddir)/libdm/libdevmapper.$(LIB_SUFFIX)
 
  dmsetup.static: dmsetup.o $(interfacebuilddir)/libdevmapper.a
  	$(CC) $(CFLAGS) $(LDFLAGS) -static -L$(interfacebuilddir) \
-	      -o $@ dmsetup.o -ldevmapper $(STATIC_LIBS) $(LIBS)
+	      -o $@ dmsetup.o -ldevmapper $(M_LIBS) $(PTHREAD_LIBS) $(STATIC_LIBS) $(LIBS)
 
  all: device-mapper

Hi

Thanks for the patch.

I've pushed to upstream, but it's worth to note - static linking is currently not really supported - for many packages it's getting a bit complex to do linking right.

So for a very limited 'subset' of linked libs this may work, but ATM we cannot really provide static linking for all combination of options.

I assume however you just need 'static' dmsetup right ?

Regards

Zdenek