zoukankan      html  css  js  c++  java
  • MinGW平台 openjpeg-2.1.0 静态编译后未定义引用的解决方法

    undefined reference to __imp_opj_xxx
    keyword:
       ffmpeg,openjpeg,OPJ_EXPORTS,OPJ_STATIC,opj_version,__imp_opj
    
    出错原因: 
        1. __declspec(dllexport) / __declspec(dllimport)
        2. __stdcall
    
    解决方法:
    openjpeg-2.1.0-modify.to.static.patch
    
    --- src/lib/openjp2/openjpeg.h.orig	2014-04-29 20:58:10 +0800
    +++ src/lib/openjp2/openjpeg.h	2016-03-26 01:07:32 +0800
    @@ -80,14 +80,14 @@
     /* http://gcc.gnu.org/wiki/Visibility */
     #if __GNUC__ >= 4
     #define OPJ_API    __attribute__ ((visibility ("default")))
    -#define OPJ_LOCAL  __attribute__ ((visibility ("hidden")))
    +#define OPJ_LOCAL  __attribute__ ((visibility ("default")))
     #else
     #define OPJ_API
     #define OPJ_LOCAL
     #endif
     #define OPJ_CALLCONV
     #else
    -#define OPJ_CALLCONV __stdcall
    +#define OPJ_CALLCONV 
     /*
     The following ifdef block is the standard way of creating macros which make exporting 
     from a DLL simpler. All files within this DLL are compiled with the OPJ_EXPORTS
    @@ -97,9 +97,9 @@
     defined with this macro as being exported.
     */
     #if defined(OPJ_EXPORTS) || defined(DLL_EXPORT)
    -#define OPJ_API __declspec(dllexport)
    +#define OPJ_API __attribute__ ((visibility ("default")))
     #else
    -#define OPJ_API __declspec(dllimport)
    +#define OPJ_API 
     #endif /* OPJ_EXPORTS */
     #endif /* !OPJ_STATIC || !_WIN32 */
     
    --- src/lib/openjp3d/openjp3d.h.orig	2014-04-29 20:58:10 +0800
    +++ src/lib/openjp3d/openjp3d.h	2016-03-26 00:08:35 +0800
    @@ -64,9 +64,9 @@
     defined with this macro as being exported.
     */
     #if defined(OPJ_EXPORTS) || defined(DLL_EXPORT)
    -#define OPJ_API __declspec(dllexport)
    +#define OPJ_API __attribute__((visibility ("default")))
     #else
    -#define OPJ_API __declspec(dllimport)
    +#define OPJ_API 
     #endif /* OPJ_EXPORTS */
     #endif /* !OPJ_STATIC || !WIN32 */
     
    --- src/lib/openmj2/openjpeg.h.orig	2014-04-29 20:58:10 +0800
    +++ src/lib/openmj2/openjpeg.h	2016-03-26 00:09:40 +0800
    @@ -66,9 +66,9 @@
     defined with this macro as being exported.
     */
     #if defined(OPJ_EXPORTS) || defined(DLL_EXPORT)
    -#define OPJ_API __declspec(dllexport)
    +#define OPJ_API __attribute__((visibility ("default")))
     #else
    -#define OPJ_API __declspec(dllimport)
    +#define OPJ_API 
     #endif /* OPJ_EXPORTS */
     #endif /* !OPJ_STATIC || !_WIN32 */
     
    --- thirdparty/include/zconf.h.orig	2014-04-29 20:58:10 +0800
    +++ thirdparty/include/zconf.h	2016-03-25 11:15:49 +0800
    @@ -277,9 +277,9 @@
     #  ifdef ZLIB_DLL
     #    if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500))
     #      ifdef ZLIB_INTERNAL
    -#        define ZEXTERN extern __declspec(dllexport)
    +#        define ZEXTERN extern __attribute__((visibility ("default")))
     #      else
    -#        define ZEXTERN extern __declspec(dllimport)
    +#        define ZEXTERN extern
     #      endif
     #    endif
     #  endif  /* ZLIB_DLL */
    @@ -306,11 +306,11 @@
     #if defined (__BEOS__)
     #  ifdef ZLIB_DLL
     #    ifdef ZLIB_INTERNAL
    -#      define ZEXPORT   __declspec(dllexport)
    -#      define ZEXPORTVA __declspec(dllexport)
    +#      define ZEXPORT   __attribute__((visibility ("default")))
    +#      define ZEXPORTVA __attribute__((visibility ("default")))
     #    else
    -#      define ZEXPORT   __declspec(dllimport)
    -#      define ZEXPORTVA __declspec(dllimport)
    +#      define ZEXPORT
    +#      define ZEXPORTVA
     #    endif
     #  endif
     #endif
    --- thirdparty/liblcms2/include/lcms2.h.orig	2016-03-26 00:00:04 +0800
    +++ thirdparty/liblcms2/include/lcms2.h	2016-03-25 23:59:52 +0800
    @@ -195,14 +195,14 @@
     #ifdef CMS_IS_WINDOWS_
     #  if defined(CMS_DLL) || defined(CMS_DLL_BUILD)
     #     ifdef __BORLANDC__
    -#        define CMSEXPORT    __stdcall _export
    +#        define CMSEXPORT    __attribute__((visibility ("default")))
     #        define CMSAPI
     #     else
     #        define CMSEXPORT    _stdcall
     #        ifdef CMS_DLL_BUILD
    -#            define CMSAPI   __declspec(dllexport)
    +#            define CMSAPI   __attribute__((visibility ("default")))
     #        else
    -#           define CMSAPI    __declspec(dllimport)
    +#           define CMSAPI
     #       endif
     #     endif
     #  else
    --- thirdparty/libpng/pngconf.h.orig	2014-04-29 20:58:10 +0800
    +++ thirdparty/libpng/pngconf.h	2016-03-25 11:15:20 +0800
    @@ -1315,9 +1315,9 @@
     
     #    ifndef PNG_IMPEXP
     #      ifdef PNG_BUILD_DLL
    -#        define PNG_IMPEXP __declspec(dllexport)
    +#        define PNG_IMPEXP __attribute__((visibility ("default")))
     #      else
    -#        define PNG_IMPEXP __declspec(dllimport)
    +#        define PNG_IMPEXP
     #      endif
     #    endif
     #  endif  /* PNG_IMPEXP */
    
  • 相关阅读:
    Git总结
    MongoDB基础总结
    Docker总结
    Java总结
    jQuery总结
    Bootstrap4总结
    QQ企业通--客户端登陆模块设计---知识点
    INI文件,WritePrivateProfileString()和GetPrivateProfileString()函数----转载
    C#调用Win32 的API函数--User32.dll ----转载
    C# 中[DllImport("user32.dll")]和extern用法和示例----转载
  • 原文地址:https://www.cnblogs.com/nlsoft/p/5322777.html
Copyright © 2011-2022 走看看