carla icon indicating copy to clipboard operation
carla copied to clipboard

Additional Python API in pre-build carla package?

Open simon-zy opened this issue 4 years ago • 5 comments

CARLA version: 0.9.12 Platform/OS: ubuntu 18.04 Problem you have experienced: I am building carla PythonAPI on a ubuntu 18.04 machine with python version default to 3.6. I encountered the following error:

BuildPythonAPI.sh: Building Python API for Python 3.6.
compiling:
  - source/libcarla/libcarla.cpp
running bdist_egg
running egg_info
writing source/carla.egg-info/PKG-INFO
writing dependency_links to source/carla.egg-info/dependency_links.txt
writing top-level names to source/carla.egg-info/top_level.txt
reading manifest file 'source/carla.egg-info/SOURCES.txt'
writing manifest file 'source/carla.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
running build_ext
building 'carla.libcarla' extension
clang-8 -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Idependencies/include -I/usr/include/python3.6m -c source/libcarla/libcarla.cpp -o build/temp.linux-x86_64-3.6/source/libcarla/libcarla.o -isystem dependencies/include/system -fPIC -std=c++14 -Werror -Wall -Wextra -Wpedantic -Wno-self-assign-overloaded -Wdeprecated -Wno-shadow -Wuninitialized -Wunreachable-code -Wpessimizing-move -Wold-style-cast -Wnull-dereference -Wduplicate-enum -Wnon-virtual-dtor -Wheader-hygiene -Wconversion -Wfloat-overflow-conversion -DBOOST_ERROR_CODE_HEADER_ONLY -DLIBCARLA_WITH_PYTHON_SUPPORT -DLIBCARLA_IMAGE_WITH_PNG_SUPPORT=true
x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-Bsymbolic-functions -Wl,-z,relro -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 build/temp.linux-x86_64-3.6/source/libcarla/libcarla.o -Ldependencies/lib -o build/lib.linux-x86_64-3.6/carla/libcarla.cpython-36m-x86_64-linux-gnu.so /data/proj/carla/PythonAPI/carla/dependencies/lib/libcarla_client.a /data/proj/carla/PythonAPI/carla/dependencies/lib/librpc.a /data/proj/carla/PythonAPI/carla/dependencies/lib/libboost_filesystem.a /data/proj/carla/PythonAPI/carla/dependencies/lib/libRecast.a /data/proj/carla/PythonAPI/carla/dependencies/lib/libDetour.a /data/proj/carla/PythonAPI/carla/dependencies/lib/libDetourCrowd.a /data/proj/carla/PythonAPI/carla/dependencies/lib/libosm2odr.a /data/proj/carla/PythonAPI/carla/dependencies/lib/libxerces-c.a -lz /data/proj/carla/PythonAPI/carla/dependencies/lib/libproj.a /data/proj/carla/PythonAPI/carla/dependencies/lib/libsqlite3.a /data/proj/carla/PythonAPI/carla/dependencies/lib/libboost_python36.a -lpng -ljpeg -ltiff -lstdc++
/usr/bin/ld: /data/proj/carla/PythonAPI/carla/dependencies/lib/libproj.a(geodesic.c.o): relocation R_X86_64_32S against `.rodata.cst8' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /data/proj/carla/PythonAPI/carla/dependencies/lib/libproj.a(wkt1_generated_parser.c.o): relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /data/proj/carla/PythonAPI/carla/dependencies/lib/libproj.a(wkt2_generated_parser.c.o): relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
Util/BuildTools/Linux.mk:87: recipe for target 'PythonAPI' failed
make: *** [PythonAPI] Error 1

I looked up in the Setup.sh file and found that libproj.a is already built with the -fPIC flag, so what is the reason of the error above? Or alternatively, could you provide more versions of the PythonAPI in the pre-build package(like python 3.6, 3.8, etc)? I'm sorry if my English would confuse you.

simon-zy avatar Sep 06 '21 12:09 simon-zy

How to solve? I have the same problem.

JerryMazeyu avatar Feb 24 '22 09:02 JerryMazeyu

I met exactly the same issue.

noobC7 avatar Apr 02 '22 13:04 noobC7

Same problem, could someone solve this problem?

gawinwong avatar Jun 06 '22 11:06 gawinwong

I solve the problem by remove anaconda3 and use python 3.6.9.

rm -rf Build
make setup
make launch
make PythonAPI

gawinwong avatar Jun 06 '22 12:06 gawinwong

Possible Solution: Replace the build options for PROJ in setup.sh and make PythonAPI again: "-fPIC" --> "-DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=true"

I cannot understand the exact reason (maybe -fPIC is not used?) but I have built the egg file without those errors anymore and it can be imported into Python successfully.

ushio2021 avatar Jul 20 '22 02:07 ushio2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jun 02 '23 04:06 stale[bot]