Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linker error when importing #26

Open
ShnitzelKiller opened this issue Feb 7, 2019 · 7 comments
Open

Linker error when importing #26

ShnitzelKiller opened this issue Feb 7, 2019 · 7 comments

Comments

@ShnitzelKiller
Copy link
Contributor

ShnitzelKiller commented Feb 7, 2019

When I attempt to import this package (tried different python versions, no difference), I get the following error:

import OpenEXR

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: /local1/jamesn8/anaconda3/envs/exrtest/lib/python3.5/site-packages/OpenEXR.cpython-35m-x86_64-linux-gnu.so: undefined symbol: _ZNK3Imf14TypedAttributeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEE12writeValueToERNS_7OStreamEi

I'm running linux, but this is an identical issue to AcademySoftwareFoundation/openexr#207 which pertains to the OSX version. See that thread for more info . The exact undefined symbol is the same as described in the post by jbartolozzi. I'm just opening the issue here in case it can be better addressed as a problem with the binding library (if that's indeed what it is).

@tiagoshibata
Copy link
Contributor

You can use a demangler (such as https://demangler.com/) to demangle the C++ symbol. It resolves to Imf::TypedAttribute<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::writeValueTo(Imf::OStream&, int) const.

If I'm not mistaken it should resolve to a symbol in the OpenEXR library. Is it installed and available in your dynamic linker path? If you compiled the C++ library from source, try setting LD_LIBRARY_PATH to the folder containing it.

@tiagoshibata
Copy link
Contributor

Another possibility is that you compiled the C++ library and the Python bindings with incompatible flags. GCC had ABI changes for C++11 (see this stack overflow post). You might have a recent version of GCC installed and an old version of the library, which was compiled with an older GCC release.

If my previous answer did not help, try listing the symbols in the library and check if the missing one is available. Check if the exact signature matches (including the __cxx11 namespace in basic_string). If not, recompile either of them (follow the instructions in the stack overflow page).


If none of this helps you, please give us more information about your system (distro, OpenEXR library version, where the library came from (system repository or local build), GCC version used to build the library and the bindings...)

@jbartolozzi
Copy link

Most likely an issue with anaconda using the latest OpenEXR libraries (2.3.x)
This module seems to ship with 1.3x with pip

@zkk0911
Copy link

zkk0911 commented Mar 30, 2019

HI ShnitzelKiller , I have the same issue, Have you addressed this problem @ShnitzelKiller

@tiagoshibata I have done nothing with the GCC. the openexr version is 1.3.2 installed with command "pip install OpenEXR"

@tiagoshibata
Copy link
Contributor

I have done nothing with the GCC

Running pip install OpenEXR will download the sources for the Python bindings and compile them locally in your machine. If the OpenEXR library was compiled with the old C++ ABI and the OpenEXR bindings are compiled with the new one, it won't work.

If my previous answer did not help, try listing the symbols in the library and check if the missing one is available. Check if the exact signature matches (including the __cxx11 namespace in basic_string).

Did you try this? readelf -Ws /path/to/libIlmImf.so | grep writeValueTo should do it. If the symbol with the __cxx11 prefix is missing, compile the bindings with -D_GLIBCXX_USE_CXX11_ABI=0 (pass this flag to the package being compiled when you do pip install).

@tiagoshibata
Copy link
Contributor

BTW, here's a more detailed and authoritative reference: https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html

If you get linker errors about undefined references to symbols that involve types in the std::__cxx11 namespace or the tag [abi:cxx11] then it probably indicates that you are trying to link together object files that were compiled with different values for the _GLIBCXX_USE_CXX11_ABI macro. This commonly happens when linking to a third-party library that was compiled with an older version of GCC. If the third-party library cannot be rebuilt with the new ABI then you will need to recompile your code with the old ABI.

If none of this helps you, please give us more information about your system (distro, OpenEXR library version, GCC version used to build the bindings...)

@ShnitzelKiller
Copy link
Contributor Author

HI ShnitzelKiller , I have the same issue, Have you addressed this problem @ShnitzelKiller

@tiagoshibata I have done nothing with the GCC. the openexr version is 1.3.2 installed with command "pip install OpenEXR"

I ended up using OpenCV.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants