FBX Python Bindings fails on Ubuntu because of undefined symbol xmlFree

FBX Python Bindings fails on Ubuntu because of undefined symbol xmlFree

Anonymous
Not applicable
4,595 Views
7 Replies
Message 1 of 8

FBX Python Bindings fails on Ubuntu because of undefined symbol xmlFree

Anonymous
Not applicable

As the title says, FBX Python Bindings fails on Ubuntu.

More precisely, FBX Python Bindings generates FbxCommon.py and fbx.so without any errors, but when I import FbxCommon.py from Python interpreter it fails because of the following exception.

 

>>> import FbxCommon

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/(my_workspace)/PythonBindings/build/Distrib/site-packages/fbx/FbxCommon.py", line 1, in <module>
    from fbx import *
ImportError: /(my_workspace)/PythonBindings/build/Distrib/site-packages/fbx/fbx.so: undefined symbol: xmlFree

 

 

My build environment is as follow:

 

As I debugged this issue, I've found that this issue is strongly related to this topic.

The Makefile of Python bindings (PythonBindings/build/Python38_x64/Makefile) generated by sip has the following code in it.

 

LIBS = -L/(my_workspace)/sdk/lib/gcc/x64/release -lz -lxml2 /(my_workspace)/sdk/lib/gcc/x64/release/libfbxsdk.a 

 

and it leads to the following command on build

 

.... ipfbxFbxDouble3.o sipfbxFbxDouble2.o sipfbxFbxDateTime.o sipfbxFbxDistance.o sipfbxFbxBlob.o -L/(my_workspace)/sdk/lib/gcc/x64/release -lz -lxml2 /(my_workspace)/sdk/lib/gcc/x64/release/libfbxsdk.a

 

However, it seems libfbxsdk.a has to reference xml2, so it should be specified before -lxml2 argument.

 

I solved this problem by editing SIP module script to generate Makefile like this.

 

LIBS = -L/(my_workspace)/sdk/lib/gcc/x64/release /(my_workspace)/sdk/lib/gcc/x64/release/libfbxsdk.a -lz -lxml2

 

 

but is there any better solution? It's a bit weird to do this every time I use FBX Python Bindings on ubuntu.

I tried to use SIP 4.19.22 but it didn't work.

0 Likes
4,596 Views
7 Replies
Replies (7)
Message 2 of 8

regalir
Autodesk
Autodesk

Hi, I can't say for sure because I don't have access to an Ubuntu machine, but I can see two possible causes:

 

a) are you sure you have libxml2 properly installed on your machine? On Linux/MacOS, the FBX SDK relies on the fact that both the libxml2 and libz are part of the system libraries.

 

b) there may be an issue with the sipconfig on Ubuntu.

 

I have tried to build the FBX Python Bindings on Centos 7.7 and, while I do have the same sequence: -L{fbxsdk_path} -lz -lxml2 {fbxsdk_path}/libfbxsdk.a, the fbx.so did properly compile. Then, when I do import FbxCommon I don't get any unresolved symbols.

 

/bin/Python2.7 (which is a 2.7.5)

sipconfig.py  located in: /usr/lib64/python2.7/site-packages

/bin/sip version 4.14.6

0 Likes
Message 3 of 8

Anonymous
Not applicable

Thank you for your advice.

 


a) are you sure you have libxml2 properly installed on your machine? On Linux/MacOS, the FBX SDK relies on the fact that both the libxml2 and libz are part of the system libraries.

 

Yes, libxml2 comes with ubuntu, but it is libxml2-dev that is required to build FBX SDK. I installed it by sudo apt install libxml2-dev and I think this will properly install the library.

 

 

b) there may be an issue with the sipconfig on Ubuntu.

 

I have tried to build the FBX Python Bindings on Centos 7.7 and, while I do have the same sequence: -L{fbxsdk_path} -lz -lxml2 {fbxsdk_path}/libfbxsdk.a, the fbx.so did properly compile. Then, when I do import FbxCommon I don't get any unresolved symbols.

 

/bin/Python2.7 (which is a 2.7.5)

sipconfig.py  located in: /usr/lib64/python2.7/site-packages

/bin/sip version 4.14.6


 

I tried to build FBX SDK with Python2.7, and sip-4.14.6, but it didn't work, either. I cannot figure out why your environment can generate the sequence where -lxml2 comes before libfbxsdk.a, but maybe it is because of the difference between ubuntu and centos.

 

If anyone knows this cause, please let us know!

 

0 Likes
Message 4 of 8

Anonymous
Not applicable

I installed centos 8 and built the FBX Python bindings, and it worked fine! -lxml2 does come before libfbxsdk.a.

 

I didn't know but it seems Autodesk's linux support is more like CentOS support. So from now on, I'll use CentOS for developing fbx. Thank you.

0 Likes
Message 5 of 8

Anonymous
Not applicable

I solved this problem by editing SIP module script to generate Makefile like this.

Could you be a little more specific? I see 124 different files in /sip, and no such line in `fbx_module.sip`. Thank  you!

0 Likes
Message 6 of 8

Anonymous
Not applicable

Ah nevermind, found it! Within the `sipconfig.py` file...

0 Likes
Message 7 of 8

Anonymous
Not applicable

Yes, that's what I edited. More specifically, I edited line 534 of sipconfig.py like this:

 

# the original code

libs.extend(self.optional_list("LIBS"))

 

# I changed to this

libs = self.optional_list("LIBS").extend(libs)

0 Likes
Message 8 of 8

andreaa6EP2A
Community Visitor
Community Visitor

Where is the file that you modified by editing SIP module script to generate Makefile like this. Did you only change "sipconfig.py"?

If I change the sipconfig.py doesn't create the LIBS line correctly of Python bindings (PythonBindings/build/Python38_x64/Makefile) as your.

LIBS = -L/(my_workspace)/sdk/lib/gcc/x64/release /(my_workspace)/sdk/lib/gcc/x64/release/libfbxsdk.a -lz -lxml2

 Can you please help me. 

 

I Know it works in CentOs, but I'm using Ubuntu 20.04 and I have the same problem as you. G++ 9.