pythonubuntu-22.04

How to resolve these make install errors for Python 3.11.9?


I am trying to configure and "make install" Python 3.11.9. However, it just quite without building a lib folder and bin folder is empty. Done on Ubuntu 22:04 installed with Python 3.10.12. Below are just a few.

Commands sent from debug folder:

../configure --prefix=/usr --with-ensurepip=install --enable-optimizations
make -j$(nproc) DESTDIR=/home/user/project/myapp.AppDir install

Error 1: A sample. There are many and they all appear red in color in PyCharm.

/usr/bin/ld: Python/errors.o: in function `_PyErr_Fetch':
/home/user/project/src/Python-3.11.9/debug/../Python/errors.c:428: undefined reference to `__gcov_indirect_call'
/usr/bin/ld: /home/user/project/src/Python-3.11.9/debug/../Python/errors.c:428: undefined reference to `__gcov_indirect_call_profiler_v4'
/usr/bin/ld: /home/user/project/src/Python-3.11.9/debug/../Python/errors.c:428: undefined reference to `__gcov_time_profiler_counter'
/usr/bin/ld: /home/user/project/src/Python-3.11.9/debug/../Python/errors.c:428: undefined reference to `__gcov_time_profiler_counter'
/usr/bin/ld: Python/errors.o: in function `PyErr_GivenExceptionMatches':
/home/user/project/src/Python-3.11.9/debug/../Python/errors.c:255: undefined reference to `__gcov_indirect_call'
/usr/bin/ld: /home/user/project/src/Python-3.11.9/debug/../Python/errors.c:255: undefined reference to `__gcov_indirect_call_profiler_v4'
/usr/bin/ld: /home/user/project/src/Python-3.11.9/debug/../Python/errors.c:255: undefined reference to `__gcov_time_profiler_counter'
/usr/bin/ld: /home/user/project/src/Python-3.11.9/debug/../Python/errors.c:255: undefined reference to `__gcov_time_profiler_counter'
/usr/bin/ld: Python/errors.o: in function `PyErr_ExceptionMatches':
/home/user/project/src/Python-3.11.9/debug/../Python/errors.c:294: undefined reference to `__gcov_indirect_call'
/usr/bin/ld: /home/user/project/src/Python-3.11.9/debug/../Python/errors.c:294: undefined reference to `__gcov_indirect_call_profiler_v4'
/usr/bin/ld: /home/user/project/src/Python-3.11.9/debug/../Python/errors.c:294: undefined reference to `__gcov_time_profiler_counter'
/usr/bin/ld: /home/user/project/src/Python-3.11.9/debug/../Python/errors.c:294: undefined reference to `__gcov_time_profiler_counter'

Error 2:

/usr/bin/ld: warning: creating DT_TEXTREL in a PIE
collect2: error: ld returned 1 exit status
make: *** [Makefile:1203: Programs/_freeze_module] Error 1

Error 3: This was the last message that appeared before termination.

# This is an expensive target to build and it does not have proper
# makefile dependency information.  So, we create a "stamp" file
# to record its completion and avoid re-running it.

Solution

  • After much try-and-error, I figured out the cause. My last command was insufficient. This command line:

    make -j$(nproc) DESTDIR=/home/user/project/myapp.AppDir install
    

    should instead be:

    make -j$(nproc)
    make -j$(nproc) DESTDIR=/home/user/project/myapp.AppDir install
    

    or

    make -j$(nproc) && make -j$(nproc) DESTDIR=/home/user/project/myapp.AppDir install
    

    Furthermore, according to documentation:

    Warning make install can overwrite or masquerade the python3 binary. make altinstall is therefore recommended instead of make install since it only installs exec_prefix/bin/pythonversion.

    So make altinstall could be used instead of make install if needed.

    evidence