(DEBIAN) Weird error when building Python from source - python

After running make I am getting this weird error or something more like an error
Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -fvisibility=hidden -I./Include/internal -I. -I./Include -DPy_BUILD_CORE -o Objects/descrobject.o Objects/descrobject.c
^Cmake: *** [Makefile:1803: Objects/descrobject.o] Interrupt
Any Idea Why??

Related

Makefile:179: recipe for target 'obj/demo.o' failed make: *** [obj/demo.o] Error 1

When I run !make command in yolov4, I face the issue:
chmod +x *.sh
gcc -Iinclude/ -I3rdparty/stb/include -DOPENCV `pkg-config --cflags opencv4 2> /dev/null || pkg-config --cflags opencv` -DGPU -I/usr/local/cuda/include/ -DCUDNN -Wall -Wfatal-errors -Wno-unused-result -Wno-unknown-pragmas -fPIC -Ofast -DOPENCV -DGPU -DCUDNN -I/usr/local/cudnn/include -c demo.c -o obj/demo.o
demo.c:1:10: fatal error: network.h: No such file or directory
#include "network.h"
^~~~~~~~~~~
compilation terminated.
Makefile:179: recipe for target 'obj/demo.o' failed
make: \*\*\* \[obj/demo.o\] Error 1
Firstly it work fine, then I change in the darknet/src/dectector.c file for early save weights after 500 iteration and also change in the cfg/yolov4-custom.cfg file change the max_batches values 500500 to 500.
I don't think so it should create issue during the execution of !make file.
Someone have any suggestion? Anyone face this issue please guide me.
I run training command for yolov4 I face the issue access denied then I again run !make file at this command error came.

C++ Boost + Python: undefined reference to Py_Dealloc

I'm trying to use the Python module on Boost. However, I'm getting an error that I cannot find what to do with.
It seems a missing switch or something, but I really could not find...
Does anyone have a clue?
Thanks!!!
/usr/include/python3.8/object.h|478|undefined reference to `_Py_Dealloc'|
System data:
Using Code::blocks, Python 3.8, Linux Mint, installed Boost by apt-get
Build log:
g++ -Wall -fexceptions -g -I/usr/lib/x86_64-linux-gnu/ -I/usr/include/python3.8/ -I/home/tavares/Downloads/boost/boost_1_77_0/stage/lib -c /home/tavares/Trabalho/pesquisa/softwares/optpipeline/PyOPY/PyOPI/bark.cpp -o obj/Debug/bark.o
g++ -Wall -fexceptions -g -I/usr/lib/x86_64-linux-gnu/ -I/usr/include/python3.8/ -I/home/tavares/Downloads/boost/boost_1_77_0/stage/lib -c /home/tavares/Trabalho/pesquisa/softwares/optpipeline/PyOPY/PyOPI/main.cpp -o obj/Debug/main.o
g++ -L/usr/lib/x86_64-linux-gnu/ -o bin/Debug/PyOPI obj/Debug/bark.o obj/Debug/main.o -lboost_program_options -lboost_system -lboost_python38
/usr/bin/ld: obj/Debug/bark.o: in function `_Py_DECREF':
/usr/include/python3.8/object.h:478: undefined reference to `_Py_Dealloc'
/usr/bin/ld: obj/Debug/bark.o: in function `boost::python::detail::none()':
/usr/local/include/boost/python/detail/none.hpp:16: undefined reference to `_Py_NoneStruct'
/usr/bin/ld: /usr/local/include/boost/python/detail/none.hpp:16: undefined reference to `_Py_NoneStruct'
/usr/bin/ld: obj/Debug/bark.o: in function `boost::python::api::object::object()':
/usr/local/include/boost/python/object_core.hpp:400: undefined reference to `_Py_NoneStruct'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu//libboost_python38.so: undefined reference to `PyExc_ValueError'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu//libboost_python38.so: undefined reference to `PyLong_AsLong'
This is kinda old, but try adding
$(python3.10-config --ldflags --embed)
to the commands at the linking phase.
Your link command becomes something like
g++ -L/usr/lib/x86_64-linux-gnu/ -o bin/Debug/PyOPI obj/Debug/bark.o obj/Debug/main.o -lboost_program_options -lboost_system -lboost_python38
$(python3.10-config --ldflags --embed)
Hope this helps someone.

Pybind11 TypeError. Python does not recognize known type

I'm totally out of ideas. In short:
>>> franka_o80.function_using_mode(o80.Mode.QUEUE)
TypeError: dummy3(): incompatible function arguments. The following argument types are supported:
1. (arg0: o80::Mode) -> None
Invoked with: Mode.QUEUE
In details:
There is a software o80, it has C++ enum Mode, and it is compiled into o80.so. There are also pybind11 bindings, exporting enum Mode into o80.Mode in o80_python.so.
There is a toy example o80_example with correspondent o80_example.so and o80_example_python.so. I can do:
import o80
import o80_example
o80_example.function_accepting_mode(o80.Mode.QUEUE)
There is my project, where I am doing same stuff, but I get what I pasted above. It seems like pybind finds no relations between Mode in o80_python.so and o80::Mode in code. I can even do pybind11::class_<o80::Mode>("OtherMode");, and then pass OtherMode in my function_using_mode - pybind sees no troubles. Functions from o80 are generally working, the problem is only in types.
Also as a symptom:
This is normal: (arg0: o80.Mode) -> None
This is what I have: (arg0: o80::Mode) -> None
What I tried:
Playing with typedef and unsing namespace
Checking that typeid().hash_code and typeid().name are the same in o80 and franka_o80 - they are the same
Putting files in same directories as original - no help
Looking at compile instructions:
o80_example:
/usr/bin/c++ -fPIC -Wl,--no-as-needed -Wall -Wextra -Wpedantic -Wl,--no-as-needed -Wall -Wextra -Wpedantic -Wl,--no-as-needed -Wall -Wextra -Wpedantic -Wl,--no-as-needed -Wall -Wextra -Wpedantic -Wl,--no-as-needed -Wall -Wextra -Wpedantic -Wl,--no-as-needed -Wall -Wextra -Wpedantic -shared -Wl,-soname,libo80_example.so -o libo80_example.so CMakeFiles/o80_example.dir/src/driver_in.cpp.o CMakeFiles/o80_example.dir/src/driver_out.cpp.o CMakeFiles/o80_example.dir/src/standalone.cpp.o CMakeFiles/o80_example.dir/src/driver.cpp.o -Wl,-rpath,/home/franka_panda/o80/install/lib::::::::::::::::::::::::::::::::::::::::::::::::::::::::: /usr/lib/x86_64-linux-gnu/libboost_filesystem.so.1.71.0 /usr/lib/x86_64-linux-gnu/libboost_system.so.1.71.0 /usr/lib/x86_64-linux-gnu/libboost_thread.so.1.71.0 /home/franka_panda/o80/install/lib/libo80.so /home/franka_panda/o80/install/lib/libsynchronizer.so /home/franka_panda/o80/install/lib/libtime_series.so /home/franka_panda/o80/install/lib/libshared_memory.so /usr/lib/x86_64-linux-gnu/librt.so /home/franka_panda/o80/install/lib/libreal_time_tools.so /usr/lib/x86_64-linux-gnu/libboost_filesystem.so.1.71.0 /usr/lib/x86_64-linux-gnu/libboost_system.so.1.71.0 /usr/lib/x86_64-linux-gnu/libboost_thread.so.1.71.0 /usr/lib/x86_64-linux-gnu/libboost_atomic.so.1.71.0 -lpthread -lpthread -ledit -lcurses -lnsl -lglut -lGL -lGLU -lX11 -lXmu -lm /home/franka_panda/o80/install/lib/libsignal_handler.so
/usr/bin/c++ -DBOOST_ALL_NO_LIB -DBOOST_ATOMIC_DYN_LINK -DBOOST_FILESYSTEM_DYN_LINK -DBOOST_SYSTEM_DYN_LINK -DBOOST_THREAD_DYN_LINK -DRT_PREEMPT -DUSING_pybind11 -Do80_example_py_EXPORTS -I/home/franka_panda/o80/src/o80_example/include -I/home/franka_panda/o80/src/o80_example/SYSTEM -isystem /usr/include/python3.8 -isystem /home/franka_panda/o80/install/include -isystem /usr/include/eigen3 -Wl,--no-as-needed -Wall -Wextra -Wpedantic -Wl,--no-as-needed -Wall -Wextra -Wpedantic -Wl,--no-as-needed -Wall -Wextra -Wpedantic -Wl,--no-as-needed -Wall -Wextra -Wpedantic -Wl,--no-as-needed -Wall -Wextra -Wpedantic -Wl,--no-as-needed -Wall -Wextra -Wpedantic -fPIC -fvisibility=hidden -std=gnu++17 -o CMakeFiles/o80_example_py.dir/srcpy/wrappers.cpp.o -c /home/franka_panda/o80/src/o80_example/srcpy/wrappers.cpp
/usr/bin/c++ -fPIC -Wl,--no-as-needed -Wall -Wextra -Wpedantic -Wl,--no-as-needed -Wall -Wextra -Wpedantic -Wl,--no-as-needed -Wall -Wextra -Wpedantic -Wl,--no-as-needed -Wall -Wextra -Wpedantic -Wl,--no-as-needed -Wall -Wextra -Wpedantic -Wl,--no-as-needed -Wall -Wextra -Wpedantic -shared -o o80_example.cpython-38-x86_64-linux-gnu.so CMakeFiles/o80_example_py.dir/srcpy/wrappers.cpp.o -Wl,-rpath,/home/franka_panda/o80/build/o80_example:/home/franka_panda/o80/install/lib:::::::::::::::: /usr/lib/x86_64-linux-gnu/libpython3.8.so libo80_example.so /home/franka_panda/o80/install/lib/libo80.so /home/franka_panda/o80/install/lib/libsynchronizer.so /home/franka_panda/o80/install/lib/libtime_series.so /home/franka_panda/o80/install/lib/libshared_memory.so /usr/lib/x86_64-linux-gnu/librt.so /home/franka_panda/o80/install/lib/libreal_time_tools.so /usr/lib/x86_64-linux-gnu/libboost_filesystem.so.1.71.0 /usr/lib/x86_64-linux-gnu/libboost_system.so.1.71.0 /usr/lib/x86_64-linux-gnu/libboost_thread.so.1.71.0 /usr/lib/x86_64-linux-gnu/libboost_atomic.so.1.71.0 -lpthread -lpthread -ledit -lcurses -lnsl -lglut -lGL -lGLU -lX11 -lXmu -lm /home/franka_panda/o80/install/lib/libsignal_handler.so
franka_o80:
/usr/bin/c++ -fPIC -Wl,--no-as-needed /usr/local/lib/libreal_time_tools.so /usr/local/lib/libshared_memory.so /usr/local/lib/libsignal_handler.so /usr/local/lib/libsynchronizer.so /usr/local/lib/libtime_series.so /usr/local/lib/libo80.so -Wl,-rpath,/usr/local/lib -shared -Wl,-soname,libfranka_o80_cpp.so -o libfranka_o80_cpp.so CMakeFiles/franka_o80_cpp.dir/src/driver.cpp.o CMakeFiles/franka_o80_cpp.dir/src/driver_input_output.cpp.o CMakeFiles/franka_o80_cpp.dir/src/driver_input.cpp.o CMakeFiles/franka_o80_cpp.dir/src/driver_output.cpp.o CMakeFiles/franka_o80_cpp.dir/src/kinematics.cpp.o CMakeFiles/franka_o80_cpp.dir/src/standalone.cpp.o CMakeFiles/franka_o80_cpp.dir/src/states.cpp.o CMakeFiles/franka_o80_cpp.dir/src/state.cpp.o -L/opt/ros/noetic/lib -Wl,-rpath,/opt/ros/noetic/lib -lfranka -lpinocchio /usr/lib/x86_64-linux-gnu/libboost_system.so.1.71.0 /usr/lib/x86_64-linux-gnu/libboost_thread.so.1.71.0 -lrt -lpthread /usr/lib/x86_64-linux-gnu/libboost_atomic.so.1.71.0 -lpthread
/usr/bin/c++ -DBOOST_ALL_NO_LIB -DBOOST_ATOMIC_DYN_LINK -DBOOST_SYSTEM_DYN_LINK -DBOOST_THREAD_DYN_LINK -DROSCONSOLE_BACKEND_LOG4CXX -DROS_BUILD_SHARED_LIBS=1 -DROS_PACKAGE_NAME=\"franka_o80\" -DRT_PREEMPT -DUSING_pybind11 -Dfranka_o80_EXPORTS -I/opt/ros/noetic/include -I/opt/ros/noetic/include/libfranka -I/opt/ros/noetic/share/xmlrpcpp/cmake/../../../include/xmlrpcpp -I/usr/include/eigen3 -isystem /usr/include/python3.8 -fPIC -fvisibility=hidden -Wl,--no-as-needed -std=gnu++17 -o CMakeFiles/franka_o80.dir/src/wrappers.cpp.o -c /home/franka_panda/franka_o80/src/wrappers.cpp
/usr/bin/c++ -fPIC -Wl,--no-as-needed /usr/local/lib/libreal_time_tools.so /usr/local/lib/libshared_memory.so /usr/local/lib/libsignal_handler.so /usr/local/lib/libsynchronizer.so /usr/local/lib/libtime_series.so /usr/local/lib/libo80.so -Wl,-rpath,/usr/local/lib -shared -Wl,-soname,libfranka_o80_cpp.so -o libfranka_o80_cpp.so CMakeFiles/franka_o80_cpp.dir/src/driver.cpp.o CMakeFiles/franka_o80_cpp.dir/src/driver_input_output.cpp.o CMakeFiles/franka_o80_cpp.dir/src/driver_input.cpp.o CMakeFiles/franka_o80_cpp.dir/src/driver_output.cpp.o CMakeFiles/franka_o80_cpp.dir/src/kinematics.cpp.o CMakeFiles/franka_o80_cpp.dir/src/standalone.cpp.o CMakeFiles/franka_o80_cpp.dir/src/states.cpp.o CMakeFiles/franka_o80_cpp.dir/src/state.cpp.o -L/opt/ros/noetic/lib -Wl,-rpath,/opt/ros/noetic/lib -lfranka -lpinocchio /usr/lib/x86_64-linux-gnu/libboost_system.so.1.71.0 /usr/lib/x86_64-linux-gnu/libboost_thread.so.1.71.0 -lrt -lpthread /usr/lib/x86_64-linux-gnu/libboost_atomic.so.1.71.0 -lpthread
I can't see where the dark magic happens.
My CMakeLists.txt:
# franka_o80_cpp
add_library(franka_o80_cpp SHARED ..........)
target_include_directories(franka_o80_cpp PUBLIC ${franka_control_INCLUDE_DIRS})
target_include_directories(franka_o80_cpp PUBLIC ${pinocchio_INCLUDE_DIRS})
target_include_directories(franka_o80_cpp PUBLIC ${EIGEN3_INCLUDE_DIRS})
target_link_directories(franka_o80_cpp PUBLIC ${franka_control_LIBRARY_DIRS})
target_link_libraries(franka_o80_cpp PUBLIC franka)
target_link_libraries(franka_o80_cpp PUBLIC pinocchio)
target_link_libraries(franka_o80_cpp PUBLIC Boost::system Boost::thread)
target_link_libraries(franka_o80_cpp PUBLIC rt pthread)
target_compile_options(franka_o80_cpp PUBLIC -Wl,--no-as-needed)
target_link_options(franka_o80_cpp PUBLIC -Wl,--no-as-needed /usr/local/lib/libreal_time_tools.so /usr/local/lib/libshared_memory.so /usr/local/lib/libsignal_handler.so /usr/local/lib/libsynchronizer.so /usr/local/lib/libtime_series.so /usr/local/lib/libo80.so -Wl,-rpath,/usr/local/lib)
# franka_o80
if (pybind11_FOUND)
add_library(franka_o80 MODULE src/wrappers.cpp)
target_compile_definitions(franka_o80 PRIVATE USING_pybind11)
target_link_libraries(franka_o80 PRIVATE pybind11::module)
target_link_libraries(franka_o80 PRIVATE ${PYTHON_LIBRARIES})
target_link_libraries(franka_o80 PRIVATE franka_o80_cpp)
set_target_properties(franka_o80 PROPERTIES PREFIX "")
endif()
Code, rather boring:
pybind11::module::import("o80");
m.def("fucntion_using_mode", [](o80::Mode){});
Same things happen with all other types, Mode is just for simplicity. Ubuntu 20.04, g++ 9.3.0. Please help. o80 has overengineered ecosystem, it will take weeks to integrate with it. I'll provide all logs I can. Thank you.
UPD: changed lnking options from -lo80 to o80.so, still doesn't work.
For pybind11 to treat two classes as the same, not only their name should be equal, but also the file. o80's bindings were compiled with path_to_sources/install/include included, but my bindings were compiled with /usr/local/include included, so Python did not recognize them.

Python subprocess.check_call works in a different way than bash

I'm trying to run Rscript via Python using subprocess.check_call.
Rscript is very simple it just checks if Rpackage exists, and if not it installs it.
local({r <- getOption("repos")
r["CRAN"] <- "https://cloud.r-project.org/"
options(repos=r)
})
if (!require("glue")) install.packages("glue")
When I run such command in bash
Rscript packages.R
it works fine.
But when I tried to run it using subprocess.check_call
subprocess.check_call(f"Rscript packages.R",
shell=True,
env=self.env)
I got such error:
* installing *source* package 'glue' ...
** package 'glue' successfully unpacked and MD5 sums checked
** libs
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -fpic -g -O2 -fdebug-prefix-map=/build/r-base-3.3.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c glue.c -o glue.o
gcc: error trying to exec 'cc1': execvp: No such file or directory
/usr/lib/R/etc/Makeconf:132: recipe for target 'glue.o' failed
make: *** [glue.o] Error 1
ERROR: compilation failed for package 'glue'
* removing '/usr/local/lib/R/site-library/glue'
The downloaded source packages are in
'/tmp/Rtmpym9Dy9/downloaded_packages'
You evidently took away (the useful value for) PATH by providing your own environment. If you want to be like the shell, make only the minimum necessary changes to the environment you inherit.

Python and C++ integration.Problems with dynamic library

I use Swig.(Mac os 10.13)
My shell script:
swig -c++ -python -o example_wrap.cpp example.i
g++ -c -std=c++17 -fPIC example.cpp
g++ -c -std=c++17 -fPIC example_wrap.cpp -o example_wrap.o \
-I/usr/local/Cellar//python/3.7.2_2/Frameworks/Python.framework/Versions/3.7/include/python3.7m
ld -bundle -macosx_version_min 10.13 -flat_namespace \
-undefined suppress -o _example.so *.o
I spent enough time to seek how to create C++ dynamic library for Python, but I have never used the last line.Most often I create a library from an IDE.
g++ -shared is more familiar, but it doesn't work.
Many such errors appear:
Undefined symbols for architecture x86_64:
"_PyArg_ParseTuple", referenced from:
_wrap_printTree(_object*, _object*) in example_wrap.o
I know about this methods from Python.h.
So, the questions are - how does the last line work(ld -bundle ...)? Are there other methods to create the dynamic library?How can I use g++ -shared?
Here is a small CMakeLists.txt that should work for the example you posted:
cmake_minimum_required(VERSION 3.10) # change this to your needs
project(foo VERSION 0.0 LANGUAGES CXX C)
find_package(SWIG REQUIRED)
include(${SWIG_USE_FILE})
find_package(PythonLibs)
include_directories(${PYTHON_INCLUDE_PATH})
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
set(CMAKE_SWIG_FLAGS "")
add_library(exampleImpl SHARED example.h example.cpp)
target_compile_features(exampleImpl PUBLIC cxx_std_17)
set_source_files_properties(example.i PROPERTIES CPLUSPLUS ON)
swig_add_library(example LANGUAGE python SOURCES example.i)
swig_link_libraries(example ${PYTHON_LIBRARIES} exampleImpl)
To make sure cmake uses the right python library, you can pass an appropriate option upon configure time, see here.

Categories

Resources