Buildroot error : undefined reference to - ld.so - linux

I am new to Buildroot (using 2021.02.5 version on Ubuntu on a Virtual Machine) and trying to compile an OS for my ZedBorad (ARM processor) during my internship.
I followed the tutorial that was given to me to do so but I still can't get make to work without printing any error.... :(
I configured what I want that way :
Kernel > Linux Kernel disabled
Bootloader > U-Boot disabled
Toolchain > C library = glibc
Target Packages > python3, xml module, python-lxml and python-numpy all selected
Networking Applications > dhcpcd and dropbear selected
Right now, what is returned to me are errors due to undefined reference to ... :
More precisely, the end of my logs after running make is as follows :
/home/ouriacc/workspace/Buildroot/build-zb/host/lib/gcc/arm-buildroot-linux-gnueabihf/9.4.0/../../../../arm-buildroot-linux-gnueabihf/bin/ld: /home/ouriacc/workspace/Buildroot/build-zb/build/glibc-2.32-50-g737efa27fca5c97f566a2005687fda7d6659cd2e/build/elf/librtld.os: in function `fdopendir':
(.text+0x1a89c): undefined reference to `__GI___fxstat64'
/home/ouriacc/workspace/Buildroot/build-zb/host/lib/gcc/arm-buildroot-linux-gnueabihf/9.4.0/../../../../arm-buildroot-linux-gnueabihf/bin/ld: (.text+0x1a8c0): undefined reference to `__GI___fcntl64_nocancel'
/home/ouriacc/workspace/Buildroot/build-zb/host/lib/gcc/arm-buildroot-linux-gnueabihf/9.4.0/../../../../arm-buildroot-linux-gnueabihf/bin/ld: /home/ouriacc/workspace/Buildroot/build-zb/build/glibc-2.32-50-g737efa27fca5c97f566a2005687fda7d6659cd2e/build/elf/ld.so.new: hidden symbol `__getpid' isn't defined
/home/ouriacc/workspace/Buildroot/build-zb/host/lib/gcc/arm-buildroot-linux-gnueabihf/9.4.0/../../../../arm-buildroot-linux-gnueabihf/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status
make[4]: *** [Makefile:566 : /home/ouriacc/workspace/Buildroot/build-zb/build/glibc-2.32-50-g737efa27fca5c97f566a2005687fda7d6659cd2e/build/elf/ld.so] Erreur 1
make[3]: *** [Makefile:470 : elf/subdir_lib] Erreur 2
make[2]: *** [Makefile:9 : all] Erreur 2
make[1]: *** [package/pkg-generic.mk:250 : /home/ouriacc/workspace/Buildroot/build-zb/build/glibc-2.32-50-g737efa27fca5c97f566a2005687fda7d6659cd2e/.stamp_built] Erreur 2
make: *** [Makefile:23 : _all] Erreur 2
I read several threads on forums about this error but I still can't figure out exactly what I should do in my case. For what I understand, there is a problem with my ld.so library and I should add something to remove or fix this error in a Makefile but I don't know what to write, where to write it and even which Makefile I should edit (as there are at least 2)...
Does anybody has an answer or another solution to help me please ?

It seems that you use an external toolchain. Try to set LD_LIBRARY_PATH environment variable for your toolchain. For example:
export LD_LIBRARY_PATH="/opt/x86-64-core-i7--glibc--stable-2020.08-1/x86_64-buildroot-linux-gnu/lib64:$LD_LIBRARY_PATH"
in your case possible the following will be suitable:
export LD_LIBRARY_PATH="/home/ouriacc/workspace/Buildroot/build-zb/host/lib/gcc/arm-buildroot-linux-gnueabihf/9.4.0/../../../../arm-buildroot-linux-gnueabihf/lib64:$LD_LIBRARY_PATH"
You may do that in docker, if you use one or in the your shell environment.

Related

How to compile linux kernel subdirectory?

I want to compile linux kernel subdirectory just like this:
make M=drivers/staging/comedi/
Unfortunately when I do this I get this error:
ERROR: Kernel configuration is invalid.
include/generated/autoconf.h or include/config/auto.conf are missing.
Run 'make oldconfig && make prepare' on kernel src to fix it.
Makefile:648: include/config/auto.conf: Nie ma takiego pliku ani katalogu
make: *** [Makefile:719: include/config/auto.conf] Błąd 1
It may be fixed by this command:
make oldconfig
After executing it, I have to press enter for 2 minutes to select the default options everywhere, and then I get this error anyway:
AR drivers/staging/comedi//built-in.a
WARNING: Symbol version dump "Module.symvers" is missing.
Modules may not have dependencies or modversions.
MODPOST drivers/staging/comedi//Module.symvers
/bin/sh: scripts/mod/modpost: Nie ma takiego pliku ani katalogu
make[1]: *** [scripts/Makefile.modpost:111: drivers/staging/comedi//Module.symvers] Błąd 127
make: *** [Makefile:1701: modules] Błąd 2
I have seen many times in the videos people just building a subdirectory with one make M=somedir command. Why doesn't it work for me?

Read Nifti image with ITK in C++

I am sorry if the question is primitive, but I can't figure the problem. I want to read nifti image in C++ using ITK libraries. I have used the code on Github: https://gist.github.com/rafamanzo/a3c258f4f74e898e9418. It is very simple code to read an image. Then I configured ITK into my project using CMake. The following is my CMakeLists.txt file:
cmake_minimum_required(VERSION 2.8)
project(MyProject)
set(CMAKE_INSTALL_PREFIX "/home/itk")
set(ITK_DIR "/home/itk/InsightToolkit-4.13.0/bin/")
set(VTK_DIR "/home/vtk/VTK-8.1.0/bin/")
find_package(ITK REQUIRED)
find_package(VTK REQUIRED)
if (ITKVtkGlue_LOADED)
find_package(VTK REQUIRED)
include(${VTK_USE_FILE})
else()
find_package(ItkVtkGlue REQUIRED)
include(${ItkVtkGlue_USE_FILE})
set(Glue ItkVtkGlue)
endif()
include(${ITK_USE_FILE})
include(${VTK_USE_FILE})
add_executable(MyProject mainFile.cxx)
target_link_libraries(MyProject ${ITK_LIBRARIES})
"cmake .." is ran successfully.
But "make all" gives me an error:
make[2]: *** No rule to make target '/home/vtk/VTK-8.1.0/bin/lib/libvtkRenderingOpenGL2.so', needed by 'MyProject'. Stop.
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/MyProject.dir/all' failed
make[1]: *** [CMakeFiles/MyProject.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
And surprisingly, when I build the project from Eclipse, I got another error:
./bin/CMakeFiles/feature_tests.o: In function `main':
/home/MyProject/Debug/../bin/CMakeFiles/feature_tests.c:34: multiple definition of `main'
makefile:32: recipe for target 'MyProject' failed
./bin/CMakeFiles/3.6.2/CompilerIdC/CMakeCCompilerId.o:/home/MyProject/Debug/../bin/CMakeFiles/3.6.2/CompilerIdC/CMakeCCompilerId.c:540: first defined here
/usr/bin/ld: cannot find -l/home/vtk/VTK-8.1.0/bin/lib/libvtkRenderingContextOpenGL2-8.1.so
collect2: error: ld returned 1 exit status
make: *** [MyProject] Error 1
I am pretty sure that configuring ITK is easy, especially I have done it before, but to use ImageFileReader only. Any help is much appreciated. Thank you.
Just to read an image you don't need VTKGlue part of ITK nor VTK itself. And the reported problem comes from VTK. If you want to keep VTK (to be used for something else?), you should fix it. Maybe you need to set VTK_RENDERING_BACKEND to OpenGL2 or something similar. Try building some VTK examples using your VTK to see if those examples build and run. That might point you more precisely to the problem.

Is it possible to compile NASA Parallel Benchmarks (NPB) files in Linux using gfortran and openmpi?

I am attempting to run NPB benchmarking on my RHEL7.3 install but come into a similar issue as the question asked here
Error while building NAS benchmarks
Trying to make the BT benchmark, which is in fortran, I get the following error:
cd BT; make NPROCS=16 CLASS=W SUBTYPE= VERSION=
make[1]: Entering directory '/mnt/npb_install/NPB3.3-MPI/BT'
make[2]: Entering directory '/mnt/npb_install/NPB3.3-MPI/sys'
make[2]: Nothing to be done for 'all'
make[2]: Leaving directory '/mnt/npb_install/NPB3.3-MPI/sys'
../sys/setparams bt 16 W
make[2]: Entering directory '/mnt/npb_install/NPB3.3-MPI/BT'
make[3]: Entering directory '/mnt/npb_install/NPB3.3-MPI/BT'
gfortran -O -o ../bin/bt.W.16 bt.o make_set.o initialize.o exact_solution.o exact_rhs.o set_constants.o adi.o define.o copy_faces.o rhs.o solve_subs.o x_solve.o y_solve.o z_solve.o add.o error.o verifiy.o setup_mpi.o ../common/print_results.o ../common/timers.o btio.o -L/usr/lib/openmpi-x84_64/ -lmpi
/bin/ld: cannot find -lmpi
collect2: error: ld returned 1 exit status
make[3]: *** [bt-bt] Error 1
make[3]: Leaving direc.......
However I am not using Intel MPI but rather OpenMPI, though I don't full understand the implication of that.
My make.def file has the following mpi related settings
#-------------------------------------
# This is the fortran compiler usedd for MPI programs
#-----------------------------------------
MPIF77 = gfortran
# This links MPI fortran programs; usually the same as ${MPIF77}
FLINK = ${MPIF77}
#------------------------------------------
# These macros are passed to the linker to help link with MPI correctly
#-------------------------------------------
FMPI_LIB = -L/usr/lib/openmpi/lib/ -lmpi
#-----------------------------------------
# These macros are passed to the compiler to help find 'mpif.h'
#------------------------------------------
FMPI_INC = -I/usr/include/openmpi-x86_64/
Similar to those posted in the above question.
From the error, I assume that the input parameters -lmpi is not a valid input parameter for gfortran when compiling but removing it leads to a screen full of undefined references like:
file.f:(.text+0x123): undefined reference to 'mpi_whatever_'
Is it possible to compile NPB with gfortran? Or am I clearly doing something wrong here?
I have seen that using ifort is another option but I thought I'd ask the question before moving towards that possible solution
After hacking at it I resolved the issue with the following fixes, not sure what did it.
OpenMPI may have not been installed properly (was unable to call mpicc or other wrappers/comps), to fix it I ran the following commands
module avail
#displayed the openmpi-x86_64 module
module add open-x86_64
which mpirun
#displayed location of mpirun
The more likely fix was simply changing gfortran in the make.def file to mpif77

lmbench3 cross-compiling undefined pmap_set

I would like to cross-compile lmbench for ARM64, on a x86 machine. I have built my own cross-compiler according to the guide here: http://preshing.com/20141119/how-to-build-a-gcc-cross-compiler/
When I tried cross-compiling lmbench3 with this cross-compiler I first had to:
remove all the lines where bk.ver was used in the src/Makefile
replace bk.ver by 3 at line 200 of the Makefile, so that I have:
sed -e "s/<version>/3/g" < ../scripts/lmbench > $O/lmbench
Set CC=aarch64-linux-gcc, OS=aarch64-linux-gnu, CFLAGS="$CFLAGS -static"
Put all the glibc-2.20/sunrpc/rpc header files into /opt/cross/aarch64-linux/include/rpc folder
Then when I type the make command I get the following error:
gmake[1]: Entering directory `/home/florian/lmbench3/src'
aarch64-linux-gcc -O -DRUSAGE -DHAVE_uint=1 -DHAVE_int64_t=1 -DHAVE_DRAND48 -DHAVE_SCHED_SETAFFINITY=1 -o ../bin/aarch64-linux-gnu/bw_tcp bw_tcp.c ../bin/aarch64-linux-gnu/lmbench.a -lm
../bin/aarch64-linux-gnu/lmbench.a(lib_tcp.o): In function `tcp_done':
lib_tcp.c:(.text+0x18): undefined reference to `pmap_unset'
../bin/aarch64-linux-gnu/lmbench.a(lib_tcp.o): In function `tcp_connect':
lib_tcp.c:(.text+0x338): undefined reference to `pmap_getport'
../bin/aarch64-linux-gnu/lmbench.a(lib_tcp.o): In function `tcp_server':
lib_tcp.c:(.text+0x568): undefined reference to `pmap_unset'
lib_tcp.c:(.text+0x584): undefined reference to `pmap_set'
collect2: error: ld returned 1 exit status
gmake[1]: *** [../bin/aarch64-linux-gnu/bw_tcp] Error 1
gmake[1]: Leaving directory `/home/florian/lmbench3/src'
make: *** [lmbench] Error 2
I know that pmap_set, pmap_unset and pmap_getport are called in lib_tcp.c, but I don't find anywhere their definitions. When I compile lmbench3 for x86 I don't get this error, and I checked everywhere on the host machine for the definition of these functions, but still don't find them anywhere.
Does anyone know what to do with this error? I guess I still need to use RPC, so I'd prefer not commenting any line.
From the error info, ld didn't find the lib, try following
make results LDFLAGS=-ltirpc

undefined reference to a [function_name] error when compiling fortran under intel compiler

Recently when I try to compile a large Fortran code, I met an error, which is in terms of hypre:
/ccs/home/phimar/opt/hypre//lib/libHYPRE.a(par_cr.o): In function `hypre_BoomerAMGCoarsenCR1':
par_cr.c:(.text+0x20e): undefined reference to `_simd_drand48_pd64x2'
/ccs/home/xialing/opt/hypre//lib/libHYPRE.a(par_cr.o): In function `cr':
par_cr.c:(.text+0xd4e): undefined reference to `_simd_drand48_pd64x2'
/usr/bin/ld: link errors found, deleting executable `/tmp/work/phimar/NGA_2way/bin/arts'
make[1]: *** [arts] Error 1
make[1]: Leaving directory `/autofs/na3_home1/phimar/NGA/src'
make: *** [default] Error 2
which seems to me that it has something to do with the compiler or the hypre src itself. So I tried to start from a clean version, unzip the hypre 2.6.0b zip file and then load the Intel compiler (with the newest version 13.1.3.192 on Titan). But I ended up with the same error.
Do offer your wisdom if this rings a bell. Really appreciate your help!

Resources