Fix static linking of v4l2-compliance and v4l2-ctl
PATCH 1/1 Fix static linking of v4l2-compliance and v4l2-ctl
v4l2-compliance and v4l2-ctl depend on librt and libpthread. The symbols are found by the linker only if these libraries are specified after the objects that depend on them.
As LDFLAGS variable end up expanded on libtool command line before LDADD, move the libraries to LDADD after local objects. -lpthread is added as on some systems librt depends on libpthread. This is the case on Ubuntu 16.04 for instance.
After this patch, creating a static build using the command
LDFLAGS="--static -static" ./configure --disable-shared --enable-static
works again.
---
Hi,
This patch fixes the static build; the error is:
CXXLD v4l2-compliance
../../lib/libv4l2/.libs/libv4l2.a(libv4l2_la-v4l2-plugin.o): In function `v4l2_plugin_init':/home/sailus/a/v4l-utils/lib/libv4l2/v4l2-plugin.c:75: warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /home/sailus/a/v4l-utils/lib/libv4lconvert/.libs/libv4lconvert.a(libv4lconvert_la-libv4lcontrol.o): In function `v4lcontrol_create':/home/sailus/a/v4l-utils/lib/libv4lconvert/control/libv4lcontrol.c:693: warning: Using 'getpwuid_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/librt.a(shm_open.o): In function `shm_open':
(.text+0x1f): undefined reference to `__shm_directory'
collect2: error: ld returned 1 exit status
distcc[21660] ERROR: compile (null) on localhost failed
Makefile:559: recipe for target 'v4l2-compliance' failed
Kind regards,
Sakari
utils/v4l2-compliance/Makefile.am | 4 ++-- utils/v4l2-ctl/Makefile.am | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-)
utils/v4l2-compliance/Makefile.am +2 -2
@@ -5,12 +5,12 @@ DEFS := v4l2_compliance_SOURCES = v4l2-compliance.cpp v4l2-test-debug.cpp v4l2-test-input-output.cpp \ v4l2-test-controls.cpp v4l2-test-io-config.cpp v4l2-test-formats.cpp v4l2-test-buffers.cpp \ v4l2-test-codecs.cpp v4l2-test-colors.cpp v4l2-compliance.h -v4l2_compliance_LDFLAGS = -lrt v4l2_compliance_CPPFLAGS = -I../common if WITH_V4L2_COMPLIANCE_LIBV4L -v4l2_compliance_LDADD = ../../lib/libv4l2/libv4l2.la ../../lib/libv4lconvert/libv4lconvert.la +v4l2_compliance_LDADD = ../../lib/libv4l2/libv4l2.la ../../lib/libv4lconvert/libv4lconvert.la -lrt -lpthread else +v4l2_compliance_LDADD = -lrt -lpthread DEFS += -DNO_LIBV4L2 endif
utils/v4l2-ctl/Makefile.am +1 -2
@@ -7,11 +7,10 @@ v4l2_ctl_SOURCES = v4l2-ctl.cpp v4l2-ctl.h v4l2-ctl-common.cpp v4l2-ctl-tuner.cp v4l2-ctl-overlay.cpp v4l2-ctl-vbi.cpp v4l2-ctl-selection.cpp v4l2-ctl-misc.cpp \ v4l2-ctl-streaming.cpp v4l2-ctl-sdr.cpp v4l2-ctl-edid.cpp v4l2-ctl-modes.cpp \ v4l2-tpg-colors.c v4l2-tpg-core.c v4l-stream.c -v4l2_ctl_LDFLAGS = -lrt v4l2_ctl_CPPFLAGS = -I../common if WITH_V4L2_CTL_LIBV4L -v4l2_ctl_LDADD = ../../lib/libv4l2/libv4l2.la ../../lib/libv4lconvert/libv4lconvert.la +v4l2_ctl_LDADD = ../../lib/libv4l2/libv4l2.la ../../lib/libv4lconvert/libv4lconvert.la -lrt -lpthread else DEFS += -DNO_LIBV4L2 endif
Signature · 1 line
2.7.4
Em Mon, 19 Sep 2016 13:50:25 +0300
Sakari Ailus <[email protected]> escreveu:
Quoted 4 lines
v4l2-compliance and v4l2-ctl depend on librt and libpthread. The symbols are found by the linker only if these libraries are specified after the objects that depend on them.
Quoted 8 lines
As LDFLAGS variable end up expanded on libtool command line before LDADD, move the libraries to LDADD after local objects. -lpthread is added as on some systems librt depends on libpthread. This is the case on Ubuntu 16.04 for instance.
After this patch, creating a static build using the command
LDFLAGS="--static -static" ./configure --disable-shared --enable-static
It sounds weird to use LDFLAGS="--static -static" here, as the configure options are already asking for static.
IMHO, the right way would be to change configure.ac to add those LDFLAGS when --disable-shared is used.
Regards,
Mauro
Quoted 53 lines
works again.
Signed-off-by Sakari Ailus <[email protected]>---
Hi,This patch fixes the static build; the error is:
CXXLD v4l2-compliance
../../lib/libv4l2/.libs/libv4l2.a(libv4l2_la-v4l2-plugin.o): In function `v4l2_plugin_init':/home/sailus/a/v4l-utils/lib/libv4l2/v4l2-plugin.c:75: warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /home/sailus/a/v4l-utils/lib/libv4lconvert/.libs/libv4lconvert.a(libv4lconvert_la-libv4lcontrol.o): In function `v4lcontrol_create':/home/sailus/a/v4l-utils/lib/libv4lconvert/control/libv4lcontrol.c:693: warning: Using 'getpwuid_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/librt.a(shm_open.o): In function `shm_open':
(.text+0x1f): undefined reference to `__shm_directory'
collect2: error: ld returned 1 exit status
distcc[21660] ERROR: compile (null) on localhost failed
Makefile:559: recipe for target 'v4l2-compliance' failedKind regards,
Sakariutils/v4l2-compliance/Makefile.am | 4 ++-- utils/v4l2-ctl/Makefile.am | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-)utils/v4l2-compliance/Makefile.am +2
-2@@ -5,12 +5,12 @@ DEFS := v4l2_compliance_SOURCES = v4l2-compliance.cpp v4l2-test-debug.cpp v4l2-test-input-output.cpp \ v4l2-test-controls.cpp v4l2-test-io-config.cpp v4l2-test-formats.cpp v4l2-test-buffers.cpp \ v4l2-test-codecs.cpp v4l2-test-colors.cpp v4l2-compliance.h -v4l2_compliance_LDFLAGS = -lrt v4l2_compliance_CPPFLAGS = -I../common if WITH_V4L2_COMPLIANCE_LIBV4L -v4l2_compliance_LDADD = ../../lib/libv4l2/libv4l2.la ../../lib/libv4lconvert/libv4lconvert.la +v4l2_compliance_LDADD = ../../lib/libv4l2/libv4l2.la ../../lib/libv4lconvert/libv4lconvert.la -lrt -lpthread else +v4l2_compliance_LDADD = -lrt -lpthread DEFS += -DNO_LIBV4L2 endifutils/v4l2-ctl/Makefile.am +0
-0@@ -7,11 +7,10 @@ v4l2_ctl_SOURCES = v4l2-ctl.cpp v4l2-ctl.h v4l2-ctl-common.cpp v4l2-ctl-tuner.cp v4l2-ctl-overlay.cpp v4l2-ctl-vbi.cpp v4l2-ctl-selection.cpp v4l2-ctl-misc.cpp \ v4l2-ctl-streaming.cpp v4l2-ctl-sdr.cpp v4l2-ctl-edid.cpp v4l2-ctl-modes.cpp \
utils/v4l2-ctl/Makefile.am v4l2_ctl_SOURCES = v4l2-ctl.cpp v4l2-ctl.h v4l2-ctl-common.cpp v4l2-ctl-tuner.cp · line 16
Quoted 10 lines
utils/v4l2-ctl/Makefile.am +1
-2v4l2-tpg-colors.c v4l2-tpg-core.c v4l-stream.c -v4l2_ctl_LDFLAGS = -lrt v4l2_ctl_CPPFLAGS = -I../common if WITH_V4L2_CTL_LIBV4L -v4l2_ctl_LDADD = ../../lib/libv4l2/libv4l2.la ../../lib/libv4lconvert/libv4lconvert.la +v4l2_ctl_LDADD = ../../lib/libv4l2/libv4l2.la ../../lib/libv4lconvert/libv4lconvert.la -lrt -lpthread else DEFS += -DNO_LIBV4L2 endif
Thanks,
Mauro
Hi Mauro,
Quoted 14 lines · Mauro Carvalho Chehab
Em Mon, 19 Sep 2016 13:50:25 +0300
Sakari Ailus <[email protected]> escreveu:Quoted 11 lines
v4l2-compliance and v4l2-ctl depend on librt and libpthread. The symbols are found by the linker only if these libraries are specified after the objects that depend on them.
As LDFLAGS variable end up expanded on libtool command line before LDADD, move the libraries to LDADD after local objects. -lpthread is added as on some systems librt depends on libpthread. This is the case on Ubuntu 16.04 for instance.
After this patch, creating a static build using the command
Quoted 7 lines
Quoted 1 line
LDFLAGS="--static -static" ./configure --disable-shared --enable-static
It sounds weird to use LDFLAGS="--static -static" here, as the configure options are already asking for static.
IMHO, the right way would be to change configure.ac to add those LDFLAGS when --disable-shared is used.
That's one option, but then shared libraries won't be built at all. I'm not sure what would be the use cases for that, though: static linking isn't very commonly needed except when you need to run the binaries elsewhere (for whatever reason) where you don't have the libraries you linked against available.
That's still a separate issue from what this patch fixes.
Ideally it should be possible to link the binaries statically while still building shared libraries: both are built by default right now, yet shared libraries are always used for linking unless you disable shared libraries. Most of the time this makes sense but not always.
I'm sending a separate patch to fix that by adding --with-static-binaries option.
Signature · 2 lines
Sakari Ailus [email protected]
Em Mon, 19 Sep 2016 16:21:30 +0300
Sakari Ailus <[email protected]> escreveu:
Quoted 19 lines
Hi Mauro,
Quoted 16 lines · Mauro Carvalho Chehab
Em Mon, 19 Sep 2016 13:50:25 +0300
Sakari Ailus <[email protected]> escreveu:Quoted 12 lines
v4l2-compliance and v4l2-ctl depend on librt and libpthread. The symbols are found by the linker only if these libraries are specified after the objects that depend on them.
As LDFLAGS variable end up expanded on libtool command line before LDADD, move the libraries to LDADD after local objects. -lpthread is added as on some systems librt depends on libpthread. This is the case on Ubuntu 16.04 for instance.
After this patch, creating a static build using the command
LDFLAGS="--static -static" ./configure --disable-shared --enable-static
Quoted 7 lines
Quoted 5 lines
It sounds weird to use LDFLAGS="--static -static" here, as the configure options are already asking for static.
IMHO, the right way would be to change configure.ac to add those LDFLAGS when --disable-shared is used.
That's one option, but then shared libraries won't be built at all.
Well, my understanding is that --disable-shared is meant to disable building the shared library build :)
Quoted 5 lines
I'm
not sure what would be the use cases for that, though: static linking isn't very commonly needed except when you need to run the binaries elsewhere (for whatever reason) where you don't have the libraries you linked against available.
Yeah, that's the common usage. It is also interesting if someone wants to build 2 versions of the same utility, each using a different library, for testing purposes.
The usecase I can't see is to use --disable-shared but keeping using the dynamic library for the exec files.
Quoted 6 lines
That's still a separate issue from what this patch fixes.
Ideally it should be possible to link the binaries statically while still building shared libraries: both are built by default right now, yet shared libraries are always used for linking unless you disable shared libraries.
Well, the point is: if dynamic library build is disabled, it should be doing static links that are produced by the build, instead of using an already existing set of dynamic libraries present on the system (that may not contain the symbols needed by the tool, or miss some patches that were on -git).
Quoted 5 lines
Most of the time this makes sense but not always.
I'm sending a separate patch to fix that by adding --with-static-binaries option.
Thanks,
Mauro
Hi Mauro,
Quoted 39 lines · Mauro Carvalho Chehab
Em Mon, 19 Sep 2016 16:21:30 +0300
Sakari Ailus <[email protected]> escreveu:Quoted 19 lines
Hi Mauro,
Quoted 16 lines · Mauro Carvalho Chehab
Em Mon, 19 Sep 2016 13:50:25 +0300
Sakari Ailus <[email protected]> escreveu:Quoted 12 lines
v4l2-compliance and v4l2-ctl depend on librt and libpthread. The symbols are found by the linker only if these libraries are specified after the objects that depend on them.
As LDFLAGS variable end up expanded on libtool command line before LDADD, move the libraries to LDADD after local objects. -lpthread is added as on some systems librt depends on libpthread. This is the case on Ubuntu 16.04 for instance.
After this patch, creating a static build using the command
LDFLAGS="--static -static" ./configure --disable-shared --enable-static
Quoted 7 lines
Quoted 5 lines
It sounds weird to use LDFLAGS="--static -static" here, as the configure options are already asking for static.
IMHO, the right way would be to change configure.ac to add those LDFLAGS when --disable-shared is used.
That's one option, but then shared libraries won't be built at all.
Well, my understanding is that --disable-shared is meant to disable building the shared library build :)
Quoted 5 lines
I'm
not sure what would be the use cases for that, though: static linking isn't very commonly needed except when you need to run the binaries elsewhere (for whatever reason) where you don't have the libraries you linked against available.
Quoted 6 lines
Yeah, that's the common usage. It is also interesting if someone wants to build 2 versions of the same utility, each using a different library, for testing purposes.
The usecase I can't see is to use --disable-shared but keeping using the dynamic library for the exec files.
There are three primary options here,
1. build an entirely static binary,
2. build a binary that relies on dynamic libraries as well and
3. build a binary that relies on dynamic libraries outside v4l-utils package but that links v4l-utils originating libraries statically.
If you say 3. is not needed then we could just use --disable-shared also to tell that static binaries are to be built.
3. is always used for libv4l2subdev and libmediactl as the libraries do not have stable APIs.
Quoted 8 lines
Quoted 7 lines
That's still a separate issue from what this patch fixes.
Ideally it should be possible to link the binaries statically while still building shared libraries: both are built by default right now, yet shared libraries are always used for linking unless you disable shared libraries.
Quoted 5 lines
Well, the point is: if dynamic library build is disabled, it should be doing static links that are produced by the build, instead of using an already existing set of dynamic libraries present on the system (that may not contain the symbols needed by the tool, or miss some patches that were on -git).
No, it uses the static libraries that are built at the same time.
Signature · 4 lines
Kind regards, Sakari Ailus e-mail: [email protected] XMPP: [email protected]
Em Mon, 26 Sep 2016 18:46:40 +0300
Sakari Ailus <[email protected]> escreveu:
Quoted 56 lines
Hi Mauro,
Quoted 39 lines · Mauro Carvalho Chehab
Em Mon, 19 Sep 2016 16:21:30 +0300
Sakari Ailus <[email protected]> escreveu:Quoted 19 lines
Hi Mauro,
Quoted 16 lines · Mauro Carvalho Chehab
Em Mon, 19 Sep 2016 13:50:25 +0300
Sakari Ailus <[email protected]> escreveu:Quoted 12 lines
v4l2-compliance and v4l2-ctl depend on librt and libpthread. The symbols are found by the linker only if these libraries are specified after the objects that depend on them.
As LDFLAGS variable end up expanded on libtool command line before LDADD, move the libraries to LDADD after local objects. -lpthread is added as on some systems librt depends on libpthread. This is the case on Ubuntu 16.04 for instance.
After this patch, creating a static build using the command
LDFLAGS="--static -static" ./configure --disable-shared --enable-static
Quoted 7 lines
Quoted 5 lines
It sounds weird to use LDFLAGS="--static -static" here, as the configure options are already asking for static.
IMHO, the right way would be to change configure.ac to add those LDFLAGS when --disable-shared is used.
That's one option, but then shared libraries won't be built at all.
Well, my understanding is that --disable-shared is meant to disable building the shared library build :)
Quoted 5 lines
I'm
not sure what would be the use cases for that, though: static linking isn't very commonly needed except when you need to run the binaries elsewhere (for whatever reason) where you don't have the libraries you linked against available.Quoted 6 lines
Yeah, that's the common usage. It is also interesting if someone wants to build 2 versions of the same utility, each using a different library, for testing purposes.
The usecase I can't see is to use --disable-shared but keeping using the dynamic library for the exec files.
There are three primary options here,
1. build an entirely static binary,
2. build a binary that relies on dynamic libraries as well and
3. build a binary that relies on dynamic libraries outside v4l-utils package but that links v4l-utils originating libraries statically.
Quoted 5 lines
If you say 3. is not needed then we could just use --disable-shared also to tell that static binaries are to be built.
3. is always used for libv4l2subdev and libmediactl as the libraries do not have stable APIs.
Sakari,
I can't see what you mean by scenario (2). I mean, if --disable-shared is called, it *should not* use dynamic libraries for any library provided by v4l-utils, as the generated binaries will either:
a) don't work, because those libraries weren't built;
b) will do the wrong thing, as they'll be dynamically linked to an older version of the library.
So, there are only 3 possible scenarios, IMHO:
1) dynamic libraries, dynamic execs
2) static v4l-utils libraries, static execs
3) static v4l-utils libraries, static links for v4l-utils libs, dyn for the rest.
In practice, I don't see any reason for keeping support for both (2) and (3), as all usecases for (3) can be covered by a fully static exec. It is also very confusing for one to understand that. For example, right now, we have those static/shared options:
--enable-static[=PKGS] build static libraries [default=yes] --enable-shared[=PKGS] build shared libraries [default=yes]
with, IMHO, sounds confusing, as those options don't seem to be orthogonal. I mean, what happens someone calls ./configure with:
./configure --disable-static --disable-shared
Thanks,
Mauro
Hi Mauro,
Quoted 87 lines · Mauro Carvalho Chehab
Em Mon, 26 Sep 2016 18:46:40 +0300
Sakari Ailus <[email protected]> escreveu:Quoted 56 lines
Hi Mauro,
Quoted 39 lines · Mauro Carvalho Chehab
Em Mon, 19 Sep 2016 16:21:30 +0300
Sakari Ailus <[email protected]> escreveu:Quoted 19 lines
Hi Mauro,
Quoted 16 lines · Mauro Carvalho Chehab
Em Mon, 19 Sep 2016 13:50:25 +0300
Sakari Ailus <[email protected]> escreveu:Quoted 12 lines
v4l2-compliance and v4l2-ctl depend on librt and libpthread. The symbols are found by the linker only if these libraries are specified after the objects that depend on them.
As LDFLAGS variable end up expanded on libtool command line before LDADD, move the libraries to LDADD after local objects. -lpthread is added as on some systems librt depends on libpthread. This is the case on Ubuntu 16.04 for instance.
After this patch, creating a static build using the command
LDFLAGS="--static -static" ./configure --disable-shared --enable-static
Quoted 7 lines
Quoted 5 lines
It sounds weird to use LDFLAGS="--static -static" here, as the configure options are already asking for static.
IMHO, the right way would be to change configure.ac to add those LDFLAGS when --disable-shared is used.
That's one option, but then shared libraries won't be built at all.
Well, my understanding is that --disable-shared is meant to disable building the shared library build :)
Quoted 5 lines
I'm
not sure what would be the use cases for that, though: static linking isn't very commonly needed except when you need to run the binaries elsewhere (for whatever reason) where you don't have the libraries you linked against available.Quoted 6 lines
Yeah, that's the common usage. It is also interesting if someone wants to build 2 versions of the same utility, each using a different library, for testing purposes.
The usecase I can't see is to use --disable-shared but keeping using the dynamic library for the exec files.
There are three primary options here,
1. build an entirely static binary,
2. build a binary that relies on dynamic libraries as well and
3. build a binary that relies on dynamic libraries outside v4l-utils package but that links v4l-utils originating libraries statically.Quoted 5 lines
If you say 3. is not needed then we could just use --disable-shared also to tell that static binaries are to be built.
3. is always used for libv4l2subdev and libmediactl as the libraries do not have stable APIs.
Sakari,
I can't see what you mean by scenario (2). I mean, if --disable-shared is called, it *should not* use dynamic libraries for any library provided by v4l-utils, as the generated binaries will either:
a) don't work, because those libraries weren't built;
b) will do the wrong thing, as they'll be dynamically linked to an older version of the library.So, there are only 3 possible scenarios, IMHO:
1) dynamic libraries, dynamic execs
2) static v4l-utils libraries, static execs
3) static v4l-utils libraries, static links for v4l-utils libs, dyn for the rest.In practice, I don't see any reason for keeping support for both (2) and (3), as all usecases for (3) can be covered by a fully static exec. It is also very confusing for one to understand that. For example, right now, we have those static/shared options:
Quoted 7 lines
--enable-static[=PKGS] build static libraries [default=yes] --enable-shared[=PKGS] build shared libraries [default=yes]
with, IMHO, sounds confusing, as those options don't seem to be orthogonal. I mean, what happens someone calls ./configure with:
./configure --disable-static --disable-shared
That doesn't make much sense --- to disable the build for both static and dynamic libraries.
What would you prefer? Link binaries statically iff shared libraries are not built? I'd just like to get this fixed. Currently building static binaries is simply broken.
Signature · 4 lines
Regards, Sakari Ailus e-mail: [email protected] XMPP: [email protected]
Em Tue, 27 Sep 2016 00:40:51 +0300
Sakari Ailus <[email protected]> escreveu:
Quoted 93 lines
Hi Mauro,
Quoted 90 lines · Mauro Carvalho Chehab
Em Mon, 26 Sep 2016 18:46:40 +0300
Sakari Ailus <[email protected]> escreveu:Quoted 56 lines
Hi Mauro,
Quoted 39 lines · Mauro Carvalho Chehab
Em Mon, 19 Sep 2016 16:21:30 +0300
Sakari Ailus <[email protected]> escreveu:Quoted 19 lines
Hi Mauro,
Quoted 16 lines · Mauro Carvalho Chehab
Em Mon, 19 Sep 2016 13:50:25 +0300
Sakari Ailus <[email protected]> escreveu:Quoted 12 lines
v4l2-compliance and v4l2-ctl depend on librt and libpthread. The symbols are found by the linker only if these libraries are specified after the objects that depend on them.
As LDFLAGS variable end up expanded on libtool command line before LDADD, move the libraries to LDADD after local objects. -lpthread is added as on some systems librt depends on libpthread. This is the case on Ubuntu 16.04 for instance.
After this patch, creating a static build using the command
LDFLAGS="--static -static" ./configure --disable-shared --enable-static
Quoted 7 lines
Quoted 5 lines
It sounds weird to use LDFLAGS="--static -static" here, as the configure options are already asking for static.
IMHO, the right way would be to change configure.ac to add those LDFLAGS when --disable-shared is used.
That's one option, but then shared libraries won't be built at all.
Well, my understanding is that --disable-shared is meant to disable building the shared library build :)
Quoted 5 lines
I'm
not sure what would be the use cases for that, though: static linking isn't very commonly needed except when you need to run the binaries elsewhere (for whatever reason) where you don't have the libraries you linked against available.Quoted 6 lines
Yeah, that's the common usage. It is also interesting if someone wants to build 2 versions of the same utility, each using a different library, for testing purposes.
The usecase I can't see is to use --disable-shared but keeping using the dynamic library for the exec files.
There are three primary options here,
1. build an entirely static binary,
2. build a binary that relies on dynamic libraries as well and
3. build a binary that relies on dynamic libraries outside v4l-utils package but that links v4l-utils originating libraries statically.Quoted 5 lines
If you say 3. is not needed then we could just use --disable-shared also to tell that static binaries are to be built.
3. is always used for libv4l2subdev and libmediactl as the libraries do not have stable APIs.
Sakari,
I can't see what you mean by scenario (2). I mean, if --disable-shared is called, it *should not* use dynamic libraries for any library provided by v4l-utils, as the generated binaries will either:
a) don't work, because those libraries weren't built;
b) will do the wrong thing, as they'll be dynamically linked to an older version of the library.So, there are only 3 possible scenarios, IMHO:
1) dynamic libraries, dynamic execs
2) static v4l-utils libraries, static execs
3) static v4l-utils libraries, static links for v4l-utils libs, dyn for the rest.In practice, I don't see any reason for keeping support for both (2) and (3), as all usecases for (3) can be covered by a fully static exec. It is also very confusing for one to understand that. For example, right now, we have those static/shared options:
--enable-static[=PKGS] build static libraries [default=yes] --enable-shared[=PKGS] build shared libraries [default=yes]
Quoted 7 lines
Quoted 4 lines
with, IMHO, sounds confusing, as those options don't seem to be orthogonal. I mean, what happens someone calls ./configure with:
./configure --disable-static --disable-sharedThat doesn't make much sense --- to disable the build for both static and dynamic libraries.
Yes, but it is still a "valid" set of options, as configure won't complain. Yet, this will cause build errors:
/usr/bin/ld: ../../lib/libdvbv5/.libs/libdvbv5.a(libdvbv5_la-dvb-dev-local.o): undefined reference to symbol 'pthread_cancel@@GLIBC_2.2.5' /usr/lib64/libpthread.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
Quoted 3 lines
What would you prefer? Link binaries statically iff shared libraries are not built? I'd just like to get this fixed. Currently building static binaries is simply broken.
IMHO, if --disable-shared is issued, it should do static linking for all libraries.
Gregor may have a different opinion, as I think he knows a lot more about how distros usually expect those options to be handled.
Thanks,
Mauro
Em Tue, 27 Sep 2016 13:04:07 -0300
Mauro Carvalho Chehab <[email protected]> escreveu:
Quoted 104 lines
Em Tue, 27 Sep 2016 00:40:51 +0300
Sakari Ailus <[email protected]> escreveu:Quoted 93 lines
Hi Mauro,
Quoted 90 lines · Mauro Carvalho Chehab
Em Mon, 26 Sep 2016 18:46:40 +0300
Sakari Ailus <[email protected]> escreveu:Quoted 56 lines
Hi Mauro,
Quoted 39 lines · Mauro Carvalho Chehab
Em Mon, 19 Sep 2016 16:21:30 +0300
Sakari Ailus <[email protected]> escreveu:Quoted 19 lines
Hi Mauro,
Quoted 16 lines · Mauro Carvalho Chehab
Em Mon, 19 Sep 2016 13:50:25 +0300
Sakari Ailus <[email protected]> escreveu:Quoted 12 lines
v4l2-compliance and v4l2-ctl depend on librt and libpthread. The symbols are found by the linker only if these libraries are specified after the objects that depend on them.
As LDFLAGS variable end up expanded on libtool command line before LDADD, move the libraries to LDADD after local objects. -lpthread is added as on some systems librt depends on libpthread. This is the case on Ubuntu 16.04 for instance.
After this patch, creating a static build using the command
LDFLAGS="--static -static" ./configure --disable-shared --enable-static
Quoted 7 lines
Quoted 5 lines
It sounds weird to use LDFLAGS="--static -static" here, as the configure options are already asking for static.
IMHO, the right way would be to change configure.ac to add those LDFLAGS when --disable-shared is used.
That's one option, but then shared libraries won't be built at all.
Well, my understanding is that --disable-shared is meant to disable building the shared library build :)
Quoted 5 lines
I'm
not sure what would be the use cases for that, though: static linking isn't very commonly needed except when you need to run the binaries elsewhere (for whatever reason) where you don't have the libraries you linked against available.Quoted 6 lines
Yeah, that's the common usage. It is also interesting if someone wants to build 2 versions of the same utility, each using a different library, for testing purposes.
The usecase I can't see is to use --disable-shared but keeping using the dynamic library for the exec files.
There are three primary options here,
1. build an entirely static binary,
2. build a binary that relies on dynamic libraries as well and
3. build a binary that relies on dynamic libraries outside v4l-utils package but that links v4l-utils originating libraries statically.Quoted 5 lines
If you say 3. is not needed then we could just use --disable-shared also to tell that static binaries are to be built.
3. is always used for libv4l2subdev and libmediactl as the libraries do not have stable APIs.
Sakari,
I can't see what you mean by scenario (2). I mean, if --disable-shared is called, it *should not* use dynamic libraries for any library provided by v4l-utils, as the generated binaries will either:
a) don't work, because those libraries weren't built;
b) will do the wrong thing, as they'll be dynamically linked to an older version of the library.So, there are only 3 possible scenarios, IMHO:
1) dynamic libraries, dynamic execs
2) static v4l-utils libraries, static execs
3) static v4l-utils libraries, static links for v4l-utils libs, dyn for the rest.In practice, I don't see any reason for keeping support for both (2) and (3), as all usecases for (3) can be covered by a fully static exec. It is also very confusing for one to understand that. For example, right now, we have those static/shared options:
--enable-static[=PKGS] build static libraries [default=yes] --enable-shared[=PKGS] build shared libraries [default=yes]
Quoted 7 lines
Quoted 4 lines
with, IMHO, sounds confusing, as those options don't seem to be orthogonal. I mean, what happens someone calls ./configure with:
./configure --disable-static --disable-sharedThat doesn't make much sense --- to disable the build for both static and dynamic libraries.
Quoted 6 lines
Yes, but it is still a "valid" set of options, as configure won't complain. Yet, this will cause build errors:
/usr/bin/ld: ../../lib/libdvbv5/.libs/libdvbv5.a(libdvbv5_la-dvb-dev-local.o): undefined reference to symbol 'pthread_cancel@@GLIBC_2.2.5'/usr/lib64/libpthread.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
Double-checked: configure will ignore --disable-static if --disable-shared is used. The above is actually a problem with libdvbv5 and pthread. I pushed a patch fixing it (and another one to display the options.
Quoted 9 lines
Quoted 3 lines
What would you prefer? Link binaries statically iff shared libraries are not built? I'd just like to get this fixed. Currently building static binaries is simply broken.
IMHO, if --disable-shared is issued, it should do static linking for all libraries.
Gregor may have a different opinion, as I think he knows a lot more about how distros usually expect those options to be handled.
After doing some tests and re-checking the patches you're proposing, patch 1 actually seems OK to me. I'm applying it.
Yet, I guess we have another issues here:
1) libv4l1 and qv4l2 just assumes that pthread is available, instead of relying on the autoconf check.
2) static builds don't work here (Fedora 24, x86-64).
I tried to do a build with:
LDFLAGS="--static -static" ./configure --disable-shared --enable-static
after applying your patch. It didn't work:
/devel-/devv4l/-v4l-utils/liblocal.o): In/libdvbv5 function/dvb- `handle_device_changedev-local.c:305':
/devel/: undefined reference v4lto/ `udev_enumerate_get_list_entry'
/v4ldevel-/v4lutils//libv4l/-libdvbv5/dvb-devutils/lib/libdvbv5-local.c:/187: undefineddvb -reference devto-local.c:310 : undefinedudev_device_get_sysattr_value 'reference to udev_list_entry_get_name/'devel/v4l/v4l
/devel/v4l-utils/lib//libdvbv5v4l/-utils/lib/dvblibdvbv5-/dvb-devdev--local.c:312:local.c :undefined188: undefined referencereference to to udev_device_new_from_syspath' ../udev_device_get_sysattr_value'
/devel././lib/v4llibdvbv5//.libs/v4llibdvbv5.a-(libdvbv5_lautils-dvb-dev-/local.olib):/ libdvbv5/Indvb-dev-local.c:116: undefined reference to udev_device_get_devnode' ../../lib/libdvbv5/.libs/libdvbv5.a(libdvbv5_la-dvb-dev-local.o): In function dvb_local_find':
/devel/v4l/v4l-utils/lib/libdvbv5/dvb-dev-local.c:332: undefined reference to `udev_unref'
collect2: error: ld returned 1 exit status
function `handle_device_change':
/devel/v4l/v4l-utils/lib/libdvbv5/dvb-dev-local.c:124: undefined reference to udev_device_get_devnode' /devel/v4l/v4l-utils/lib/libdvbv5/dvb-dev-local.c:131: undefined reference to udev_device_get_property_value'
...
Basically, at least on my system, libsystemd doesn't come with a static libudev.
In thesis, this should actually be the syntax for static builds, in order to let pkg-config to know that it will be doing a static build:
PKG_CONFIG="pkg-config --static" LDFLAGS="--static -static" ./configure --disable-shared --enable-static
But it still fails to link.
So, I guess that, if you want to fix for static build, you'll need to add some additional checks at the configure.ac for it to verify if the information returned by pkg-config really works for static build, disabling the packages if not.
Regards,
Mauro
PATCH 2/2 Add --with-static-binaries option to link binaries statically
In reply to Sakari AilusAdd a new variable STATIC_LDFLAGS to add the linker flags required for static linking for each binary built.
Static and dynamic libraries are built by default but the binaries are otherwise linked dynamically. --with-static-binaries requires that static libraries are built.
--- configure.ac | 5 +++++ contrib/gconv/Makefile.am | 4 ++-- contrib/test/Makefile.am | 8 ++++---- lib/libv4l1/Makefile.am | 2 +- lib/libv4l2/Makefile.am | 2 +- utils/cec-compliance/Makefile.am | 2 +- utils/cec-ctl/Makefile.am | 1 + utils/cec-follower/Makefile.am | 2 +- utils/cx18-ctl/Makefile.am | 1 + utils/decode_tm6000/Makefile.am | 2 +- utils/dvb/Makefile.am | 10 +++++----- utils/ir-ctl/Makefile.am | 2 +- utils/ivtv-ctl/Makefile.am | 2 +- utils/keytable/Makefile.am | 2 +- utils/media-ctl/Makefile.am | 1 + utils/qv4l2/Makefile.am | 6 +++--- utils/rds-ctl/Makefile.am | 2 +- utils/v4l2-compliance/Makefile.am | 1 + utils/v4l2-ctl/Makefile.am | 1 + utils/v4l2-sysfs-path/Makefile.am | 2 +- 20 files changed, 34 insertions(+), 24 deletions(-)
configure.ac +5 -0
@@ -427,6 +427,11 @@ AM_CONDITIONAL([WITH_V4L2_COMPLIANCE_LIBV4L], [test x${enable_v4l2_compliance_li # append -static to libtool compile and link command to enforce static libs AS_IF([test x$enable_libdvbv5 = xno], [AC_SUBST([ENFORCE_LIBDVBV5_STATIC], ["-static"])]) AS_IF([test x$enable_libv4l = xno], [AC_SUBST([ENFORCE_LIBV4L_STATIC], ["-static"])]) +AC_ARG_WITH([static-binaries], AS_HELP_STRING([--with-static-binaries], [link binaries statically, requires static libraries to be built])) +AS_IF([test x$with_static_binaries = xyes], + [AS_IF([test x$enable_static = xno], + [AC_MSG_ERROR([--with-static-binaries requires --enable-static])])] + [AC_SUBST([STATIC_LDFLAGS], ["--static -static"])]) # misc
contrib/gconv/Makefile.am +2 -2
@@ -9,9 +9,9 @@ gconv_base_sources = iconv/skeleton.c iconv/loop.c arib-std-b24.c, en300-468-tab00.c: $(gconv_base_sources) ARIB_STD_B24_la_SOURCES = arib-std-b24.c jis0201.h jis0208.h jisx0213.h -ARIB_STD_B24_la_LDFLAGS = $(gconv_ldflags) -L@gconvsysdir@ -R @gconvsysdir@ -lJIS -lJISX0213 +ARIB_STD_B24_la_LDFLAGS = $(gconv_ldflags) -L@gconvsysdir@ -R @gconvsysdir@ -lJIS -lJISX0213 $(STATIC_LDFLAGS) EN300_468_TAB00_la_SOURCES = en300-468-tab00.c -EN300_468_TAB00_la_LDFLAGS = $(gconv_ldflags) +EN300_468_TAB00_la_LDFLAGS = $(gconv_ldflags) $(STATIC_LDFLAGS) EXTRA_DIST = $(gconv_base_sources) $(gconv_DATA) gconv.map
contrib/test/Makefile.am +4 -4
@@ -21,18 +21,18 @@ driver_test_LDADD = ../../utils/libv4l2util/libv4l2util.la pixfmt_test_SOURCES = pixfmt-test.c pixfmt_test_CFLAGS = $(X11_CFLAGS) -pixfmt_test_LDFLAGS = $(X11_LIBS) +pixfmt_test_LDFLAGS = $(X11_LIBS) $(STATIC_LDFLAGS) v4l2grab_SOURCES = v4l2grab.c -v4l2grab_LDFLAGS = $(ARGP_LIBS) +v4l2grab_LDFLAGS = $(ARGP_LIBS) $(STATIC_LDFLAGS) v4l2grab_LDADD = ../../lib/libv4l2/libv4l2.la ../../lib/libv4lconvert/libv4lconvert.la -lpthread v4l2gl_SOURCES = v4l2gl.c -v4l2gl_LDFLAGS = $(X11_LIBS) $(GL_LIBS) $(GLU_LIBS) $(ARGP_LIBS) +v4l2gl_LDFLAGS = $(X11_LIBS) $(GL_LIBS) $(GLU_LIBS) $(ARGP_LIBS) $(STATIC_LDFLAGS) v4l2gl_LDADD = ../../lib/libv4l2/libv4l2.la ../../lib/libv4lconvert/libv4lconvert.la mc_nextgen_test_CFLAGS = $(LIBUDEV_CFLAGS) -mc_nextgen_test_LDFLAGS = $(LIBUDEV_LIBS) +mc_nextgen_test_LDFLAGS = $(LIBUDEV_LIBS) $(STATIC_LDFLAGS) ioctl_test_SOURCES = ioctl-test.c ioctl-test.h ioctl_32.h ioctl_64.h
lib/libv4l1/Makefile.am +1 -1
@@ -23,7 +23,7 @@ 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_LDFLAGS = -avoid-version -module -shared -export-dynamic $(STATIC_LDFLAGS) v4l1compat_la_LIBTOOLFLAGS = --tag=disable-static EXTRA_DIST = libv4l1-kernelcode-license.txt
lib/libv4l2/Makefile.am +1 -1
@@ -22,7 +22,7 @@ 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_LDFLAGS = -avoid-version -module -shared -export-dynamic $(STATIC_LDFLAGS) v4l2convert_la_LIBTOOLFLAGS = --tag=disable-static EXTRA_DIST = Android.mk v4l2-plugin-android.c
utils/cec-compliance/Makefile.am +1 -1
@@ -2,7 +2,7 @@ bin_PROGRAMS = cec-compliance man_MANS = cec-compliance.1 cec_compliance_SOURCES = cec-compliance.cpp cec-test.cpp cec-test-adapter.cpp cec-test-audio.cpp cec-test-power.cpp -cec_compliance_LDFLAGS = -lrt +cec_compliance_LDFLAGS = -lrt $(STATIC_LDFLAGS) cec-compliance.cpp: cec-table.h
utils/cec-ctl/Makefile.am +1 -0
@@ -2,6 +2,7 @@ bin_PROGRAMS = cec-ctl man_MANS = cec-ctl.1 cec_ctl_SOURCES = cec-ctl.cpp +cec_ctl_LDFLAGS = $(STATIC_LDFLAGS) cec-ctl.cpp: cec-ctl-gen.h
utils/cec-follower/Makefile.am +1 -1
@@ -2,7 +2,7 @@ bin_PROGRAMS = cec-follower man_MANS = cec-follower.1 cec_follower_SOURCES = cec-follower.cpp cec-processing.cpp cec-log.cpp -cec_follower_LDFLAGS = -lrt +cec_follower_LDFLAGS = -lrt $(STATIC_LDFLAGS) cec-log.cpp: cec-log.h
utils/cx18-ctl/Makefile.am +1 -0
@@ -1,3 +1,4 @@ bin_PROGRAMS = cx18-ctl cx18_ctl_SOURCES = cx18-ctl.c +cx18_ctl_LDFLAGS = $(STATIC_LDFLAGS)
utils/decode_tm6000/Makefile.am +1 -1
@@ -1,4 +1,4 @@ bin_PROGRAMS = decode_tm6000 decode_tm6000_SOURCES = decode_tm6000.c decode_tm6000_LDADD = ../libv4l2util/libv4l2util.la -decode_tm6000_LDFLAGS = $(ARGP_LIBS) +decode_tm6000_LDFLAGS = $(ARGP_LIBS) $(STATIC_LDFLAGS)
utils/dvb/Makefile.am +5 -5
@@ -9,23 +9,23 @@ man_MANS = dvb-fe-tool.1 dvbv5-zap.1 dvbv5-scan.1 dvb-format-convert.1 dvb_fe_tool_SOURCES = dvb-fe-tool.c dvb_fe_tool_LDADD = ../../lib/libdvbv5/libdvbv5.la @LIBINTL@ $(LIBUDEV_LIBS) $(XMLRPC_LDADD) -dvb_fe_tool_LDFLAGS = $(ARGP_LIBS) -lm $(LIBUDEV_CFLAGS) $(XMLRPC_LDFLAGS) +dvb_fe_tool_LDFLAGS = $(ARGP_LIBS) -lm $(LIBUDEV_CFLAGS) $(XMLRPC_LDFLAGS) $(STATIC_LDFLAGS) dvbv5_zap_SOURCES = dvbv5-zap.c dvbv5_zap_LDADD = ../../lib/libdvbv5/libdvbv5.la @LIBINTL@ $(LIBUDEV_LIBS) $(XMLRPC_LDADD) -dvbv5_zap_LDFLAGS = $(ARGP_LIBS) -lm $(LIBUDEV_CFLAGS) $(XMLRPC_LDFLAGS) +dvbv5_zap_LDFLAGS = $(ARGP_LIBS) -lm $(LIBUDEV_CFLAGS) $(XMLRPC_LDFLAGS) $(STATIC_LDFLAGS) dvbv5_scan_SOURCES = dvbv5-scan.c dvbv5_scan_LDADD = ../../lib/libdvbv5/libdvbv5.la @LIBINTL@ $(LIBUDEV_LIBS) $(XMLRPC_LDADD) -dvbv5_scan_LDFLAGS = $(ARGP_LIBS) -lm $(LIBUDEV_CFLAGS) $(XMLRPC_LDFLAGS) +dvbv5_scan_LDFLAGS = $(ARGP_LIBS) -lm $(LIBUDEV_CFLAGS) $(XMLRPC_LDFLAGS) $(STATIC_LDFLAGS) dvb_format_convert_SOURCES = dvb-format-convert.c dvb_format_convert_LDADD = ../../lib/libdvbv5/libdvbv5.la @LIBINTL@ $(LIBUDEV_LIBS) $(XMLRPC_LDADD) -dvb_format_convert_LDFLAGS = $(ARGP_LIBS) -lm $(LIBUDEV_CFLAGS) $(XMLRPC_LDFLAGS) +dvb_format_convert_LDFLAGS = $(ARGP_LIBS) -lm $(LIBUDEV_CFLAGS) $(XMLRPC_LDFLAGS) $(STATIC_LDFLAGS) dvbv5_daemon_SOURCES = dvbv5-daemon.c dvbv5_daemon_LDADD = ../../lib/libdvbv5/libdvbv5.la @LIBINTL@ $(LIBUDEV_LIBS) $(XMLRPC_LDADD) $(PTHREAD_LDADD) -dvbv5_daemon_LDFLAGS = $(ARGP_LIBS) -lm $(XMLRPC_LDFLAGS) $(PTHREAD_LDFLAGS) +dvbv5_daemon_LDFLAGS = $(ARGP_LIBS) -lm $(XMLRPC_LDFLAGS) $(PTHREAD_LDFLAGS) $(STATIC_LDFLAGS) dvbv5_daemon_CFLAGS = $(XMLRPC_CFLAGS) $(LIBUDEV_CFLAGS) $(PTHREAD_CFLAGS) EXTRA_DIST = README
utils/ir-ctl/Makefile.am +1 -1
@@ -3,4 +3,4 @@ man_MANS = ir-ctl.1 ir_ctl_SOURCES = ir-ctl.c ir_ctl_LDADD = @LIBINTL@ -ir_ctl_LDFLAGS = $(ARGP_LIBS) +ir_ctl_LDFLAGS = $(ARGP_LIBS) $(STATIC_LDFLAGS)
utils/ivtv-ctl/Makefile.am +1 -1
@@ -1,4 +1,4 @@ bin_PROGRAMS = ivtv-ctl ivtv_ctl_SOURCES = ivtv-ctl.c -ivtv_ctl_LDFLAGS = -lm +ivtv_ctl_LDFLAGS = -lm $(STATIC_LDFLAGS)
utils/keytable/Makefile.am +1 -1
@@ -6,7 +6,7 @@ udevrules_DATA = 70-infrared.rules ir_keytable_SOURCES = keytable.c parse.h ir_keytable_LDADD = @LIBINTL@ -ir_keytable_LDFLAGS = $(ARGP_LIBS) +ir_keytable_LDFLAGS = $(ARGP_LIBS) $(STATIC_LDFLAGS) EXTRA_DIST = 70-infrared.rules rc_keymaps rc_keymaps_userspace gen_keytables.pl ir-keytable.1 rc_maps.cfg
utils/media-ctl/Makefile.am +1 -0
@@ -26,4 +26,5 @@ noinst_HEADERS = mediactl.h v4l2subdev.h bin_PROGRAMS = media-ctl media_ctl_SOURCES = media-ctl.c options.c options.h tools.h +media_ctl_LDFLAGS = $(STATIC_LDFLAGS) media_ctl_LDADD = libmediactl.la libv4l2subdev.la
utils/qv4l2/Makefile.am +3 -3
@@ -12,14 +12,14 @@ qv4l2_CPPFLAGS = -I../common if WITH_QTGL qv4l2_CPPFLAGS += $(QTGL_CFLAGS) -qv4l2_LDFLAGS = $(QTGL_LIBS) +qv4l2_LDFLAGS = $(QTGL_LIBS) $(STATIC_LDFLAGS) else qv4l2_CPPFLAGS += $(QT_CFLAGS) -qv4l2_LDFLAGS = $(QT_LIBS) +qv4l2_LDFLAGS = $(QT_LIBS) $(STATIC_LDFLAGS) endif qv4l2_CPPFLAGS += $(ALSA_CFLAGS) -qv4l2_LDFLAGS += $(ALSA_LIBS) -pthread +qv4l2_LDFLAGS += $(ALSA_LIBS) -pthread $(STATIC_LDFLAGS) EXTRA_DIST = enterbutt.png exit.png fileopen.png qv4l2_24x24.png qv4l2_64x64.png qv4l2.png qv4l2.svg \ snapshot.png video-television.png fileclose.png qv4l2_16x16.png qv4l2_32x32.png qv4l2.desktop \
utils/rds-ctl/Makefile.am +1 -1
@@ -2,4 +2,4 @@ bin_PROGRAMS = rds-ctl rds_ctl_SOURCES = rds-ctl.cpp rds_ctl_LDADD = ../../lib/libv4l2/libv4l2.la ../../lib/libv4lconvert/libv4lconvert.la ../../lib/libv4l2rds/libv4l2rds.la - +rds_ctl_LDFLAGS = $(STATIC_LDFLAGS)
utils/v4l2-compliance/Makefile.am +1 -0
@@ -6,6 +6,7 @@ v4l2_compliance_SOURCES = v4l2-compliance.cpp v4l2-test-debug.cpp v4l2-test-inpu v4l2-test-controls.cpp v4l2-test-io-config.cpp v4l2-test-formats.cpp v4l2-test-buffers.cpp \ v4l2-test-codecs.cpp v4l2-test-colors.cpp v4l2-compliance.h v4l2_compliance_CPPFLAGS = -I../common +v4l2_compliance_LDFLAGS = $(STATIC_LDFLAGS) if WITH_V4L2_COMPLIANCE_LIBV4L v4l2_compliance_LDADD = ../../lib/libv4l2/libv4l2.la ../../lib/libv4lconvert/libv4lconvert.la -lrt -lpthread
utils/v4l2-ctl/Makefile.am +1 -0
@@ -8,6 +8,7 @@ v4l2_ctl_SOURCES = v4l2-ctl.cpp v4l2-ctl.h v4l2-ctl-common.cpp v4l2-ctl-tuner.cp v4l2-ctl-streaming.cpp v4l2-ctl-sdr.cpp v4l2-ctl-edid.cpp v4l2-ctl-modes.cpp \ v4l2-tpg-colors.c v4l2-tpg-core.c v4l-stream.c v4l2_ctl_CPPFLAGS = -I../common +v4l2_ctl_LDFLAGS = $(STATIC_LDFLAGS) if WITH_V4L2_CTL_LIBV4L v4l2_ctl_LDADD = ../../lib/libv4l2/libv4l2.la ../../lib/libv4lconvert/libv4lconvert.la -lrt -lpthread
utils/v4l2-sysfs-path/Makefile.am +1 -1
@@ -1,4 +1,4 @@ bin_PROGRAMS = v4l2-sysfs-path v4l2_sysfs_path_SOURCES = v4l2-sysfs-path.c v4l2_sysfs_path_LDADD = ../libmedia_dev/libmedia_dev.la -v4l2_sysfs_path_LDFLAGS = $(ARGP_LIBS) +v4l2_sysfs_path_LDFLAGS = $(ARGP_LIBS) $(STATIC_LDFLAGS)
Signature · 1 line
2.7.4
Re: [v4l-utils PATCH 2/2] Add --with-static-binaries option to link binaries statically
Em Mon, 19 Sep 2016 16:22:30 +0300
Sakari Ailus <[email protected]> escreveu:
Quoted 52 lines
Add a new variable
STATIC_LDFLAGSto add the linker flags required for static linking for each binary built.Static and dynamic libraries are built by default but the binaries are otherwise linked dynamically. --with-static-binaries requires that static libraries are built.
Signed-off-by Sakari Ailus <[email protected]>--- configure.ac | 5 +++++ contrib/gconv/Makefile.am | 4 ++-- contrib/test/Makefile.am | 8 ++++---- lib/libv4l1/Makefile.am | 2 +- lib/libv4l2/Makefile.am | 2 +- utils/cec-compliance/Makefile.am | 2 +- utils/cec-ctl/Makefile.am | 1 + utils/cec-follower/Makefile.am | 2 +- utils/cx18-ctl/Makefile.am | 1 + utils/decode_tm6000/Makefile.am | 2 +- utils/dvb/Makefile.am | 10 +++++----- utils/ir-ctl/Makefile.am | 2 +- utils/ivtv-ctl/Makefile.am | 2 +- utils/keytable/Makefile.am | 2 +- utils/media-ctl/Makefile.am | 1 + utils/qv4l2/Makefile.am | 6 +++--- utils/rds-ctl/Makefile.am | 2 +- utils/v4l2-compliance/Makefile.am | 1 + utils/v4l2-ctl/Makefile.am | 1 + utils/v4l2-sysfs-path/Makefile.am | 2 +- 20 files changed, 34 insertions(+), 24 deletions(-)configure.ac +5
-0@@ -427,6 +427,11 @@ AM_CONDITIONAL([WITH_V4L2_COMPLIANCE_LIBV4L], [test x${enable_v4l2_compliance_li # append -static to libtool compile and link command to enforce static libs AS_IF([test x$enable_libdvbv5 = xno], [AC_SUBST([ENFORCE_LIBDVBV5_STATIC], ["-static"])]) AS_IF([test x$enable_libv4l = xno], [AC_SUBST([ENFORCE_LIBV4L_STATIC], ["-static"])]) +AC_ARG_WITH([static-binaries], AS_HELP_STRING([--with-static-binaries], [link binaries statically, requires static libraries to be built])) +AS_IF([test x$with_static_binaries = xyes], + [AS_IF([test x$enable_static = xno], + [AC_MSG_ERROR([--with-static-binaries requires --enable-static])])] + [AC_SUBST([STATIC_LDFLAGS], ["--static -static"])]) # misccontrib/gconv/Makefile.am +0
-0
contrib/gconv/Makefile.am gconv_base_sources = iconv/skeleton.c iconv/loop.c · line 12
Quoted 5 lines
contrib/gconv/Makefile.am +1
-1@@ -9,9 +9,9 @@ gconv_base_sources = iconv/skeleton.c iconv/loop.c arib-std-b24.c, en300-468-tab00.c: $(gconv_base_sources) ARIB_STD_B24_la_SOURCES = arib-std-b24.c jis0201.h jis0208.h jisx0213.h -ARIB_STD_B24_la_LDFLAGS = $(gconv_ldflags) -L@gconvsysdir@ -R @gconvsysdir@ -lJIS -lJISX0213 +ARIB_STD_B24_la_LDFLAGS = $(gconv_ldflags) -L@gconvsysdir@ -R @gconvsysdir@ -lJIS -lJISX0213 $(STATIC_LDFLAGS)
Instead of adding STATIC_LDFLAGS to all LDFLAGS, wouldn't be better to add the flags to LDFLAGS on configure.ac?
Regards,
Mauro
Re: [v4l-utils PATCH 2/2] Add --with-static-binaries option to link binaries statically
Hi Mauro,
Quoted 57 lines · Mauro Carvalho Chehab
Em Mon, 19 Sep 2016 16:22:30 +0300
Sakari Ailus <[email protected]> escreveu:Quoted 54 lines
Add a new variable
STATIC_LDFLAGSto add the linker flags required for static linking for each binary built.Static and dynamic libraries are built by default but the binaries are otherwise linked dynamically. --with-static-binaries requires that static libraries are built.
Signed-off-by Sakari Ailus <[email protected]>--- configure.ac | 5 +++++ contrib/gconv/Makefile.am | 4 ++-- contrib/test/Makefile.am | 8 ++++---- lib/libv4l1/Makefile.am | 2 +- lib/libv4l2/Makefile.am | 2 +- utils/cec-compliance/Makefile.am | 2 +- utils/cec-ctl/Makefile.am | 1 + utils/cec-follower/Makefile.am | 2 +- utils/cx18-ctl/Makefile.am | 1 + utils/decode_tm6000/Makefile.am | 2 +- utils/dvb/Makefile.am | 10 +++++----- utils/ir-ctl/Makefile.am | 2 +- utils/ivtv-ctl/Makefile.am | 2 +- utils/keytable/Makefile.am | 2 +- utils/media-ctl/Makefile.am | 1 + utils/qv4l2/Makefile.am | 6 +++--- utils/rds-ctl/Makefile.am | 2 +- utils/v4l2-compliance/Makefile.am | 1 + utils/v4l2-ctl/Makefile.am | 1 + utils/v4l2-sysfs-path/Makefile.am | 2 +- 20 files changed, 34 insertions(+), 24 deletions(-)configure.ac +5
-0@@ -427,6 +427,11 @@ AM_CONDITIONAL([WITH_V4L2_COMPLIANCE_LIBV4L], [test x${enable_v4l2_compliance_li # append -static to libtool compile and link command to enforce static libs AS_IF([test x$enable_libdvbv5 = xno], [AC_SUBST([ENFORCE_LIBDVBV5_STATIC], ["-static"])]) AS_IF([test x$enable_libv4l = xno], [AC_SUBST([ENFORCE_LIBV4L_STATIC], ["-static"])]) +AC_ARG_WITH([static-binaries], AS_HELP_STRING([--with-static-binaries], [link binaries statically, requires static libraries to be built])) +AS_IF([test x$with_static_binaries = xyes], + [AS_IF([test x$enable_static = xno], + [AC_MSG_ERROR([--with-static-binaries requires --enable-static])])] + [AC_SUBST([STATIC_LDFLAGS], ["--static -static"])]) # misccontrib/gconv/Makefile.am +0
-0@@ -9,9 +9,9 @@ gconv_base_sources = iconv/skeleton.c iconv/loop.c arib-std-b24.c, en300-468-tab00.c: $(gconv_base_sources)
Quoted 6 lines
contrib/gconv/Makefile.am gconv_base_sources = iconv/skeleton.c iconv/loop.c · line 12
Quoted 3 lines
contrib/gconv/Makefile.am +1
-1ARIB_STD_B24_la_SOURCES = arib-std-b24.c jis0201.h jis0208.h jisx0213.h -ARIB_STD_B24_la_LDFLAGS = $(gconv_ldflags) -L@gconvsysdir@ -R @gconvsysdir@ -lJIS -lJISX0213 +ARIB_STD_B24_la_LDFLAGS = $(gconv_ldflags) -L@gconvsysdir@ -R @gconvsysdir@ -lJIS -lJISX0213 $(STATIC_LDFLAGS)Instead of adding
STATIC_LDFLAGSto all LDFLAGS, wouldn't be better to add the flags to LDFLAGS on configure.ac?
That would affect libraries as well, which would break the build for shared libraries, say, if you just pass --with-static-binaries, you'll get both static and shared libraries as well as static binaries.
Signature · 2 lines
Sakari Ailus e-mail: [email protected] XMPP: [email protected]
Re: [v4l-utils PATCH 2/2] Add --with-static-binaries option to link binaries statically
In reply to Mauro Carvalho ChehabQuoted 6 lines · Mauro Carvalho Chehab
Em Mon, 19 Sep 2016 16:22:30 +0300
Sakari Ailus <[email protected]> escreveu:Quoted 3 lines
Add a new variable
STATIC_LDFLAGSto add the linker flags required for static linking for each binary built.
Quoted 6 lines
Quoted 4 lines
Static and dynamic libraries are built by default but the binaries are otherwise linked dynamically. --with-static-binaries requires that static libraries are built.
Instead of adding
STATIC_LDFLAGSto all LDFLAGS, wouldn't be better to add the flags to LDFLAGS on configure.ac?
I don't really like adding all those build variants into the configure script itself. It is already way too complex and adding another dimension does not make it better.
Why is passing --disable-shared --enable-static LDLAGS="--static -static" to configure not sufficient?
Thanks,
Gregor
Re: [v4l-utils PATCH 2/2] Add --with-static-binaries option to link binaries statically
Em Mon, 26 Sep 2016 19:41:39 +0200
Gregor Jasny <[email protected]> escreveu:
Quoted 14 lines · Mauro Carvalho Chehab
Quoted 6 lines
Em Mon, 19 Sep 2016 16:22:30 +0300
Sakari Ailus <[email protected]> escreveu:Quoted 3 lines
Add a new variable
STATIC_LDFLAGSto add the linker flags required for static linking for each binary built.Quoted 6 lines
Quoted 4 lines
Static and dynamic libraries are built by default but the binaries are otherwise linked dynamically. --with-static-binaries requires that static libraries are built.
Instead of adding
STATIC_LDFLAGSto all LDFLAGS, wouldn't be better to add the flags to LDFLAGS on configure.ac?
Quoted 6 lines
I don't really like adding all those build variants into the configure script itself. It is already way too complex and adding another dimension does not make it better.
Why is passing --disable-shared --enable-static LDLAGS="--static -static" to configure not sufficient?
That sounds better than adding an extra STATIC_LDFLAGS option, but, IMHO, this sounds confusing, and it is not documented.
The advantage of having an option is that the expected behavior can be documented in a way that the user will know what each option would be doing by calling ./configure --help. Yet, IMHO, the above parameters don't make clear about what type of output for executable files (static, dynamic, "partially" dynamic).
We could (should?) also print, at the ./configure "summary" what kind of libraries will be generated and what kind of executables.
Thanks,
Mauro
Re: [v4l-utils PATCH 2/2] Add --with-static-binaries option to link binaries statically
Hi guys,
Quoted 27 lines · Mauro Carvalho Chehab
Em Mon, 26 Sep 2016 19:41:39 +0200
Gregor Jasny <[email protected]> escreveu:Quoted 14 lines · Mauro Carvalho Chehab
Quoted 6 lines
Em Mon, 19 Sep 2016 16:22:30 +0300
Sakari Ailus <[email protected]> escreveu:Quoted 3 lines
Add a new variable
STATIC_LDFLAGSto add the linker flags required for static linking for each binary built.Quoted 6 lines
Quoted 4 lines
Static and dynamic libraries are built by default but the binaries are otherwise linked dynamically. --with-static-binaries requires that static libraries are built.
Instead of adding
STATIC_LDFLAGSto all LDFLAGS, wouldn't be better to add the flags to LDFLAGS on configure.ac?Quoted 6 lines
I don't really like adding all those build variants into the configure script itself. It is already way too complex and adding another dimension does not make it better.
Why is passing --disable-shared --enable-static LDLAGS="--static -static" to configure not sufficient?
That sounds better than adding an extra
STATIC_LDFLAGSoption, but, IMHO, this sounds confusing, and it is not documented.
Quoted 8 lines
The advantage of having an option is that the expected behavior can be documented in a way that the user will know what each option would be doing by calling ./configure --help. Yet, IMHO, the above parameters don't make clear about what type of output for executable files (static, dynamic, "partially" dynamic).
We could (should?) also print, at the ./configure "summary" what kind of libraries will be generated and what kind of executables.
It's an old thread... anyway, the INSTALL file is another option to put this. I'd just like that it'd be easy for people to find this information rather than require them to figure it out somehow. Not everyone is an expert in autoconf / automake --- certainly not me at least.
Another advantage of documenting this is that it tends to get tested more widely and if it doesn't work, it's obvious that it's broken rather than v4l-utils is being built the wrong way.
So, configure help text or INSTALL?
Signature · 4 lines
Regards, Sakari Ailus e-mail: [email protected]