diff mbox

[FFmpeg-devel] libopenjpeg: do not define OPJ_STATIC for shared builds

Message ID f149f2cd-d297-ec7d-4fcb-6f6edf6f6322@googlemail.com
State Superseded
Headers show

Commit Message

Andreas Cadhalpun Oct. 11, 2016, 3:50 p.m. UTC
Setting OPJ_STATIC when building shared libraries with openjpeg 2 causes
the openjpeg symbols to have visibility hidden and the final linker step
to fail due to undefined references.

Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
---
 libavcodec/libopenjpegdec.c | 3 +++
 libavcodec/libopenjpegenc.c | 3 +++
 2 files changed, 6 insertions(+)

Comments

Hendrik Leppkes Oct. 11, 2016, 5:13 p.m. UTC | #1
On Tue, Oct 11, 2016 at 5:50 PM, Andreas Cadhalpun
<andreas.cadhalpun@googlemail.com> wrote:
> Setting OPJ_STATIC when building shared libraries with openjpeg 2 causes
> the openjpeg symbols to have visibility hidden and the final linker step
> to fail due to undefined references.

Aren't these type of macros typically related to the way the library
(ie. openjpeg) is being linked into avcodec (or ffmpeg), and not what
kind of library we're building?

>
> Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
> ---
>  libavcodec/libopenjpegdec.c | 3 +++
>  libavcodec/libopenjpegenc.c | 3 +++
>  2 files changed, 6 insertions(+)
>
> diff --git a/libavcodec/libopenjpegdec.c b/libavcodec/libopenjpegdec.c
> index 65167e6..1f8dadf 100644
> --- a/libavcodec/libopenjpegdec.c
> +++ b/libavcodec/libopenjpegdec.c
> @@ -24,7 +24,10 @@
>   * JPEG 2000 decoder using libopenjpeg
>   */
>
> +#include "config.h"
> +#if !CONFIG_SHARED
>  #define  OPJ_STATIC
> +#endif
>
>  #include "libavutil/common.h"
>  #include "libavutil/imgutils.h"
> diff --git a/libavcodec/libopenjpegenc.c b/libavcodec/libopenjpegenc.c
> index 1443551..023fdf4 100644
> --- a/libavcodec/libopenjpegenc.c
> +++ b/libavcodec/libopenjpegenc.c
> @@ -24,7 +24,10 @@
>   * JPEG 2000 encoder using libopenjpeg
>   */
>
> +#include "config.h"
> +#if !CONFIG_SHARED
>  #define  OPJ_STATIC
> +#endif
>
>  #include "libavutil/avassert.h"
>  #include "libavutil/common.h"
> --
> 2.9.3
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Andreas Cadhalpun Oct. 11, 2016, 6:26 p.m. UTC | #2
On 11.10.2016 19:13, Hendrik Leppkes wrote:
> On Tue, Oct 11, 2016 at 5:50 PM, Andreas Cadhalpun
> <andreas.cadhalpun@googlemail.com> wrote:
>> Setting OPJ_STATIC when building shared libraries with openjpeg 2 causes
>> the openjpeg symbols to have visibility hidden and the final linker step
>> to fail due to undefined references.
> 
> Aren't these type of macros typically related to the way the library
> (ie. openjpeg) is being linked into avcodec (or ffmpeg), and not what
> kind of library we're building?

Indeed, you're right. Building a static ffmpeg fails, as well.
However, configure doesn't detect this, because it checks the header and
the function separately.
Also it adds -DOPJ_STATIC to EXTRALIBS, where it is rather useless,
instead of to CFLAGS, where it would affect the code. This explains the
explicit '#define  OPJ_STATIC', which shouldn't be needed at all.
And it just assumes that libopenjpeg is built statically...

I'll send a patch fixing configure. Consider this patch dropped.

Best regards,
Andreas
diff mbox

Patch

diff --git a/libavcodec/libopenjpegdec.c b/libavcodec/libopenjpegdec.c
index 65167e6..1f8dadf 100644
--- a/libavcodec/libopenjpegdec.c
+++ b/libavcodec/libopenjpegdec.c
@@ -24,7 +24,10 @@ 
  * JPEG 2000 decoder using libopenjpeg
  */
 
+#include "config.h"
+#if !CONFIG_SHARED
 #define  OPJ_STATIC
+#endif
 
 #include "libavutil/common.h"
 #include "libavutil/imgutils.h"
diff --git a/libavcodec/libopenjpegenc.c b/libavcodec/libopenjpegenc.c
index 1443551..023fdf4 100644
--- a/libavcodec/libopenjpegenc.c
+++ b/libavcodec/libopenjpegenc.c
@@ -24,7 +24,10 @@ 
  * JPEG 2000 encoder using libopenjpeg
  */
 
+#include "config.h"
+#if !CONFIG_SHARED
 #define  OPJ_STATIC
+#endif
 
 #include "libavutil/avassert.h"
 #include "libavutil/common.h"