SAP / PyRFC

Asynchronous, non-blocking SAP NW RFC SDK bindings for Python
http://sap.github.io/PyRFC
Apache License 2.0
500 stars 132 forks source link

Issues with building wheel on Linux #325

Closed EuroV8 closed 1 year ago

EuroV8 commented 1 year ago

Hi, I am currently writing an app targeting android which uses PyRFC, but I can't seem to get the library to work on Linux. I can't build the wheel and I'm getting this error: [DEBUG]: ld: error: /home/[username]/saprfcsdk/nwrfcsdk/lib/libsapnwrfc.so: unknown file type [DEBUG]: ld: error: /home/[username]/saprfcsdk/nwrfcsdk/lib/libsapucum.so: unknown file type [DEBUG]: clang-14: error: linker command failed with exit code 1 (use -v to see invocation) [DEBUG]: error: command '/home/[username]/.buildozer/android/platform/android-ndk-r25b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++' failed with exit code 1 [DEBUG]: error: subprocess-exited-with-error

while building the app with Buildozer, which builds every dependency for the app to package it inside the apk. The same goes for trying to install the package with pip :

`Defaulting to user installation because normal site-packages is not writeable Collecting pyrfc Using cached pyrfc-2.8.3.tar.gz (286 kB) Installing build dependencies ... done Getting requirements to build wheel ... done Preparing metadata (pyproject.toml) ... done Building wheels for collected packages: pyrfc Building wheel for pyrfc (pyproject.toml) ... error error: subprocess-exited-with-error

× Building wheel for pyrfc (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [22 lines of output] 750 Patch Level 11 /tmp/pip-build-env-ci2oa4vc/overlay/lib/python3.11/site-packages/setuptools/config/pyprojecttoml.py:66: _BetaConfiguration: Support for [tool.setuptools] in pyproject.toml is still beta. config = read_configuration(filepath, True, ignore_option_errors, dist) running bdist_wheel running build running build_py creating build creating build/lib.linux-x86_64-cpython-311 creating build/lib.linux-x86_64-cpython-311/pyrfc copying src/pyrfc/_utils.py -> build/lib.linux-x86_64-cpython-311/pyrfc copying src/pyrfc/_exception.py -> build/lib.linux-x86_64-cpython-311/pyrfc copying src/pyrfc/init.py -> build/lib.linux-x86_64-cpython-311/pyrfc running build_ext building 'pyrfc._cyrfc' extension creating build/temp.linux-x86_64-cpython-311 creating build/temp.linux-x86_64-cpython-311/src creating build/temp.linux-x86_64-cpython-311/src/pyrfc gcc -DNDEBUG -g -fwrapv -O3 -Wall -march=x86-64 -mtune=generic -O3 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection -g -ffile-prefix-map=/build/python/src=/usr/src/debug/python -flto=auto -ffat-lto-objects -march=x86-64 -mtune=generic -O3 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection -g -ffile-prefix-map=/build/python/src=/usr/src/debug/python -flto=auto -march=x86-64 -mtune=generic -O3 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection -g -ffile-prefix-map=/build/python/src=/usr/src/debug/python -flto=auto -fPIC -DNDEBUG -D_LARGEFILE_SOURCE -D_CONSOLE -D_FILE_OFFSET_BITS=64 -DSAPonUNIX -DSAPwithUNICODE -DSAPwithTHREADS -DSAPonLIN -I/usr/include/python3.11 -c src/pyrfc/_cyrfc.cpp -o build/temp.linux-x86_64-cpython-311/src/pyrfc/_cyrfc.o -Wall -O2 -fexceptions -funsigned-char -fno-strict-aliasing -Wall -Wno-uninitialized -Wno-deprecated-declarations -Wno-unused-function -Wcast-align -fPIC -pthread -minline-all-stringops -I/home/euro/saprfcsdk/nwrfcsdk/include g++ -shared -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -flto=auto -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -flto=auto build/temp.linux-x86_64-cpython-311/src/pyrfc/_cyrfc.o -L/usr/lib -lsapnwrfc -lsapucum -o build/lib.linux-x86_64-cpython-311/pyrfc/_cyrfc.cpython-311-x86_64-linux-gnu.so -L/home/euro/saprfcsdk/nwrfcsdk/lib /home/euro/saprfcsdk/nwrfcsdk/lib/libsapnwrfc.so: file not recognized: file format not recognized collect2: error: ld returned 1 exit status error: command '/usr/bin/g++' failed with exit code 1 [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for pyrfc Failed to build pyrfc ERROR: Could not build wheels for pyrfc, which is required to install pyproject.toml-based projects`

I have also added the following env. variables (in .bashrc): export LD_LIBRARY_PATH="/home/euro/saprfcsdk/nwrfcsdk/lib/:$LD_LIBRARY_PATH" export SAPNWRFC_HOME="/home/euro/saprfcsdk/nwrfcsdk"

I am using Manjaro Linux with kernel 6.1.31-2-MANJARO. I'd appreciate it if someone could help/share their experience with a similar issue, thanks.

EuroV8 commented 1 year ago

Solved the problem, issue was with the incorrect selected architecture of the SAP NWRFC SDK downloaded on Sap for Me...