Skip to contentSkip to conversation

Allow building static binaries

PATCH In review Sakari Ailus 3 participants 4 messages Dec 8, 2015 – Dec 21, 2015 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Allow building static binaries

	$ LDFLAGS="--static -static" ./configure --enable-static
	$ LDFLAGS=-static make

can be used to create static binaries. The issue was that shared libraries were attempted to link statically which naturally failed.

---
 lib/libv4l1/Makefile.am | 3 +--
 lib/libv4l2/Makefile.am | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)
lib/libv4l1/Makefile.am +1 -2
index 005ae10..c325390 100644
@@ -23,7 +23,6 @@ libv4l1_la_LIBADD = ../libv4l2/libv4l2.la
 v4l1compat_la_SOURCES = v4l1compat.c
 
 v4l1compat_la_LIBADD = libv4l1.la
-v4l1compat_la_LDFLAGS = -avoid-version -module -shared -export-dynamic
-v4l1compat_la_LIBTOOLFLAGS = --tag=disable-static
+v4l1compat_la_LDFLAGS = -avoid-version -module -export-dynamic
 
 EXTRA_DIST = libv4l1-kernelcode-license.txt
lib/libv4l2/Makefile.am +1 -2
index b6f4d3b..878ccd9 100644
@@ -22,7 +22,6 @@ libv4l2_la_LIBADD = ../libv4lconvert/libv4lconvert.la
 
 v4l2convert_la_SOURCES = v4l2convert.c
 v4l2convert_la_LIBADD = libv4l2.la
-v4l2convert_la_LDFLAGS = -avoid-version -module -shared -export-dynamic
-v4l2convert_la_LIBTOOLFLAGS = --tag=disable-static
+v4l2convert_la_LDFLAGS = -avoid-version -module -export-dynamic
 
 EXTRA_DIST = Android.mk v4l2-plugin-android.c
Signature · 1 line
2.1.0.231.g7484e3b
#1 lore raw

Hi Gregor,

I discussed with Hans and he thought you'd be the best person to take a look at this.

The case is that I'd like to build static binaries and that doesn't seem to work with what's in Makefile.am for libv4l1 and libv4l2 at the moment.

Thanks.

Quoted 45 lines · Sakari Ailus
	$ LDFLAGS="--static -static" ./configure --enable-static
	$ LDFLAGS=-static make

can be used to create static binaries. The issue was that shared libraries were attempted to link statically which naturally failed.

---
 lib/libv4l1/Makefile.am | 3 +--
 lib/libv4l2/Makefile.am | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)
lib/libv4l1/Makefile.am +1 -2
index 005ae10..c325390 100644
@@ -23,7 +23,6 @@ libv4l1_la_LIBADD = ../libv4l2/libv4l2.la
 v4l1compat_la_SOURCES = v4l1compat.c
 
 v4l1compat_la_LIBADD = libv4l1.la
-v4l1compat_la_LDFLAGS = -avoid-version -module -shared -export-dynamic
-v4l1compat_la_LIBTOOLFLAGS = --tag=disable-static
+v4l1compat_la_LDFLAGS = -avoid-version -module -export-dynamic
 
 EXTRA_DIST = libv4l1-kernelcode-license.txt
lib/libv4l2/Makefile.am +1 -2
index b6f4d3b..878ccd9 100644
@@ -22,7 +22,6 @@ libv4l2_la_LIBADD = ../libv4lconvert/libv4lconvert.la
 
 v4l2convert_la_SOURCES = v4l2convert.c
 v4l2convert_la_LIBADD = libv4l2.la
-v4l2convert_la_LDFLAGS = -avoid-version -module -shared -export-dynamic
-v4l2convert_la_LIBTOOLFLAGS = --tag=disable-static
+v4l2convert_la_LDFLAGS = -avoid-version -module -export-dynamic
 
 EXTRA_DIST = Android.mk v4l2-plugin-android.c
Signature · 6 lines
2.1.0.231.g7484e3b

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Signature · 4 lines
Kind regards,

Sakari Ailus
e-mail: [email protected]	XMPP: [email protected]
#2 lore raw

Hello,

Quoted 5 lines · Sakari Ailus

I discussed with Hans and he thought you'd be the best person to take a look at this.

The case is that I'd like to build static binaries and that doesn't seem to work with what's in Makefile.am for libv4l1 and libv4l2 at the moment.

Sorry for the late reply. Didi not notice this email earlier. Your patch does not do what you'd like to achieve. Both v4l1compat and v4l2convert are libraries which only purpose is to get preloaded by the loader. So build them statically does not make sense. Instead they should not be built at all. To achieve this the WITH_V4L_WRAPPERS variable should evaluate to false. This is triggered by

AM_CONDITIONAL([WITH_V4L_WRAPPERS], [test x$enable_libv4l != xno -a x$enable_shared != xno])

So changing

LDFLAGS="--static -static" ./configure --enable-static

to

LDFLAGS="--static -static" ./configure --enable-static --disabled-shared

should do the trick. Does this help?

Thanks,
Gregor

#3 lore raw

Hi Gregor,

Quoted 21 lines · Gregor Jasny

Hello,

Quoted 5 lines · Sakari Ailus

I discussed with Hans and he thought you'd be the best person to take a look at this.

The case is that I'd like to build static binaries and that doesn't seem to work with what's in Makefile.am for libv4l1 and libv4l2 at the moment.

Sorry for the late reply. Didi not notice this email earlier. Your patch does not do what you'd like to achieve. Both v4l1compat and v4l2convert are libraries which only purpose is to get preloaded by the loader. So build them statically does not make sense. Instead they should not be built at all. To achieve this the WITH_V4L_WRAPPERS variable should evaluate to false. This is triggered by

AM_CONDITIONAL([WITH_V4L_WRAPPERS], [test x$enable_libv4l != xno -a x$enable_shared != xno])

So changing

Quoted 7 lines

LDFLAGS="--static -static" ./configure --enable-static

to

LDFLAGS="--static -static" ./configure --enable-static --disabled-shared

should do the trick. Does this help?

It does. I get statically linked binaries now without changes. Thank you, Gregor!

Hans, Mauro, please ignore the patch.

Signature · 4 lines
Kind regards,

Sakari Ailus
e-mail: [email protected]	XMPP: [email protected]