Hidden attribute on gcc compilation breaks desktop Java bindings (Bug #3077)


Added by Pete Warden over 3 years ago. Updated almost 3 years ago.


Status:Done Start date:
Priority:High Due date:
Assignee:Andrey Pavlenko % Done:

0%

Category:java bindings
Target version:3.0
Affected version:branch 'master' (3.0-dev) Operating System:Linux
Difficulty: HW Platform:Any
Pull request:https://github.com/Itseez/opencv/pull/1012

Description

The recent switch to using -fvisibility=hidden on gcc platforms means that all functions in libopencv_java249.so are inaccessible to Java programs.

Steps to reproduce:
- Compile latest code on Ubuntu 12.04 (or a similar gcc platform)
- Follow the Java ant tutorial instructions, or run the ant command on the prebuilt samples/java/ant project

Expected:
The program should show matrix output

Actual:
The program fails with the following message:
Exception in thread "main" java.lang.UnsatisfiedLinkError: org.opencv.core.Mat.n_Mat(IIIDDDD)J

Notes:
This is the commit that contained the change:
https://github.com/Itseez/opencv/pull/881

Here's a patch that gets me compiling again:

--- a/cmake/OpenCVCompilerOptions.cmake
+++ b/cmake/OpenCVCompilerOptions.cmake
@ -252,8 +252,8 @ set(OPENCV_EXTRA_EXE_LINKER_FLAGS_DEBUG "${OPENCV_EXTRA_EXE_LINKER_FLAGS_DEBUG

  1. set default visibility to hidden
    if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_OPENCV_GCC_VERSION_NUM GREATER 399)
    - add_extra_compiler_option(fvisibility=hidden)
    add_extra_compiler_option(-fvisibility-inlines-hidden)
    # add_extra_compiler_option(-fvisibility=hidden)
    # add_extra_compiler_option(-fvisibility-inlines-hidden)
    endif()

I'd imagine a better fix would be to override the default visibility for the generated native interface code, but I don't know where that would go.


Associated revisions

Revision 01e97331
Added by Andrey Pavlenko over 3 years ago

fix for #3077
removing "-fvisibility=hidden" gcc option due to lack of `__attribute__ ((visibility("default")))` in jni_md.h/JNIEXPORT

History

Updated by Vladislav Vinogradov over 3 years ago

  • Assignee set to Andrey Pavlenko
  • Category set to java bindings

Updated by Andrey Pavlenko over 3 years ago

Generated JNI methods should have external visibility.

  • Priority changed from Normal to High
  • Start date deleted (2013-06-07)
  • Target version set to 3.0

Updated by Andrey Pavlenko over 3 years ago

  • Pull request set to https://github.com/Itseez/opencv/pull/1012

Updated by Andrey Pavlenko almost 3 years ago

  • Status changed from Open to Done
  • HW Platform set to Any
  • Operating System set to Linux
  • Affected version changed from branch 'master' (2.4.9) to branch 'master' (3.0-dev)

Also available in: Atom PDF