Having trouble compiling 32-bit binary on 64-bit linux armv8 machine - c++

I am trying to use a c++ ARM 32-bit library on a Jetson Tx2, which is an ARM 64-bit linux machine. When I try to compile some of the sample code provided with the library I get the following compilation error:
/usr/bin/ld: skipping incompatible /home/nvidia/libroyale/bin/libroyale.so
when searching for -lroyale
/usr/bin/ld: cannot find -lroyale
collect2: error: ld returned 1 exit status
CMakeFiles/sampleCameraInfo.dir/build.make:94: recipe for target
'sampleCameraInfo' failed
make[2]: *** [sampleCameraInfo] Error 1
CMakeFiles/Makefile2:67: recipe for target
'CMakeFiles/sampleCameraInfo.dir/all' failed
make[1]: *** [CMakeFiles/sampleCameraInfo.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
I assume that this error is because the 32-bit library is somehow incompatible with a 64-bit machine.
I have been browsing other StackOverflow forums on similar issues, and in accordance with those forum recommendations added the -m32 flag to CXXFLAGS and LDFLAGS when I compile. However, I then get the following error:
g++: error: unrecognized command line option ‘-m32’
CMakeFiles/sampleCameraInfo.dir/build.make:62: recipe for target
'CMakeFiles/sampleCameraInfo.dir/sampleCameraInfo.cpp.o' failed
make[2]: *** [CMakeFiles/sampleCameraInfo.dir/sampleCameraInfo.cpp.o] Error 1
CMakeFiles/Makefile2:67: recipe for target
'CMakeFiles/sampleCameraInfo.dir/all' failed
make[1]: *** [CMakeFiles/sampleCameraInfo.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
Some other StackOverflow threads said that in order to use the -m32 flag, one has to run the command:
sudo apt-get install g++-multilib
I don't think that the installation is working correctly, as I'm getting the following errors:
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
g++-multilib:armhf : Depends: cpp:armhf (>= 4:5.3.1-1ubuntu1) but it is
not going to be installed
Depends: gcc-multilib:armhf (>= 4:5.3.1-1ubuntu1) but it is not going to be installed
Depends: g++:armhf (>= 4:5.3.1-1ubuntu1) but it is not going to be installed
Depends: g++-5-multilib:armhf (>= 5.3.1-3~) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
Any suggestions would be very much appreciated. Thanks!
UPDATE: I realized that the -m32 flag is only supported on x86 linux machines. Does anyone know if there is some equivalent for ARM machines?

I had a look at the GCC documentation, especially on the following pages:
https://gcc.gnu.org/onlinedocs/gcc-7.1.0/gcc/x86-Options.html
https://gcc.gnu.org/onlinedocs/gcc-7.1.0/gcc/AArch64-Options.html
Looks like for the GNU compilers x86 is one type of CPU; you can create 16-, 32- or 64-bit code for this CPU type.
However it also looks like for the GNU compilers 32-bit ARM CPUs and 64-bit ARM CPUs are two completely different CPU types.
Therefore compiling for 32-bit ARM with a 64-bit ARM compiler is the same as compiling for x86 with an ARM compiler: It won't work.
Of course the 32-bit library will not be accepted; an ARM compiler would not accept a x86 library, either.

Related

Problems with compiling C++/Cuda code after Linux update

We have an in-house C++-code which partly uses CUDA. The CUDA-code is spread between the files "cuda_kernel.hpp" and "cuda_kernel.cu".
All was good and the code compiled both on my local machine and our cluster.
Now I had to update my Linux from impish to jammy, which I did on Friday. When trying to compile said project today I received the following error message:
Making all in dergeraet
make[1]: Entering directory '/home/paul/Projekte/DerGeraet/dergeraet'
make all-am
make[2]: Entering directory '/home/paul/Projekte/DerGeraet/dergeraet'
CXX poisson.o
make[2]: *** No rule to make target '/usr/include/c++/10/new', needed by 'cuda_kernel.o'. Stop.
make[2]: Leaving directory '/home/paul/Projekte/DerGeraet/dergeraet'
make[1]: *** [makefile:306: all] Error 2
make[1]: Leaving directory '/home/paul/Projekte/DerGeraet/dergeraet'
make: *** [Makefile:374: all-recursive] Error 1
So I checked whether nvcc was installed. nvcc --version returned nothing so I followed the instructions on https://developer.nvidia.com/cuda-downloads to install cuda and then ran sudo apt install nvidia-cuda-toolkit. Now when calling nvcc --version Linux returns
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2021 NVIDIA Corporation
Built on Thu_Nov_18_09:45:30_PST_2021
Cuda compilation tools, release 11.5, V11.5.119
Build cuda_11.5.r11.5/compiler.30672275_0
Ok, me thinks, let's compile again but the error-message still remains the same.
I checked '/usr/include/c++/10/new' and there is only
'/usr/include/c++/11/new', i.e., no '/usr/include/c++/10' folder.
I am really out of clues here. Tried reinstalling cuda twice with different version numbers (11.6 and 11.7) but the error persisted. Is this some weird incompatibility issues between gcc and nvcc?
Other in-house code (without CUDA) compiles fine, thus I think it must be a cuda-related problem.
Thanks for any help in advance!
This error was caused by an incomplete host g++ installation. In this case the libstdc++-10-dev package was either missing or incorrectly installed.

Vulkan SDK Version 1.1.85.0 linking on Kubuntu 18.10

I'm currently working on a game engine with vulkan.
I just wanted to try whether it compiles on linux, but I don't know how to link my Vulkan SDK libraries. I downloaded the "vulkansdk-linux-x86_64-1.1.85.0.tar.gz" from the LunarG homepage, but now I dont know what I should link under "target_link_libraries".
I tried to link the "libvulkan.so" from the lib folder, but it does not work.
Some help from you would be great, because I never worked with CMAKE on linux.
/usr/bin/ld: cannot find -lvulkan
collect2: error: ld returned 1 exit status
make[3]: *** [CMakeFiles/Untitled.dir/build.make:669: ../output_linux /Untitled] Error 1
make[2]: *** [CMakeFiles/Makefile2:73: CMakeFiles/Untitled.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:85: CMakeFiles/Untitled.dir/rule] Error 2
make: *** [Makefile:118: Untitled] Error 2
Thanks for help,
Marlon
The SDK's Linux Getting Started Guide found in your SDK tarball and at this link explains much of this. In fact, there's even a section called "Using Vulkan in CMake Projects" that shows how to use the FindVulkan CMake module. The SDK also contains numerous example programs, also built with CMake.

linking error cxx: cannot find -lvulkan

When I tried to compile example from Anvil framework for Vulkan I get following errors:
[ 97%] Linking CXX executable OutOfOrderRasterization
/usr/bin/ld: cannot find -lvulkan
collect2: error: ld returned 1 exit status
CMakeFiles/OutOfOrderRasterization.dir/build.make:126: recipe for target 'OutOfOrderRasterization' failed
make[2]: *** [OutOfOrderRasterization] Error 1
CMakeFiles/Makefile2:72: recipe for target 'CMakeFiles/OutOfOrderRasterization.dir/all' failed
make[1]: *** [CMakeFiles/OutOfOrderRasterization.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
How i need to configure Vulkan to resolve it? (Ubuntu)
Check you LIBRARY paths. You might need to download and install vulkan. There should a .so file in one your library paths(/usr/lib{,64},/lib{,64}, /usr/share/lib{,64}) named to the effect of libvulkan.numbers.so.
See this ask ubuntu question: https://askubuntu.com/questions/796442/ld-cannot-find-lvulkan
CMake versions 3.7 and later ship with a FindVulkan.cmake module that finds the Vulkan includes and library for you if you have a Vulkan SDK installed and the VULKAN_SDK environment variable set. The CMake module also finds the includes and library if you have installed a Vulkan package to your system directories. The Getting Started guide on the LunarXchange website has some additional detail.

ld: library not found for -lrt

I am trying to run a project that was made and works for Ubuntu but on Mac OS. And when I am doing the make I got the following error:
ld: library not found for -lrt
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [consumer] Error 1
make[1]: *** [CMakeFiles/consumer.dir/all] Error 2
make: *** [all] Error 2
I can't see any library with that name at thole project.
Can anyone explain what it is and how to solve it?
On old Linux systems, several functions, such as clock_gettime, are documented to need -lrt for old versions of GNU libc. This is no more the case on recent glibc (after 2.17 from 2013).
So you can remove -lrt from your Makefile (and remove the thing from your cmake configuration thing generating it).
BTW, removing -lrt should also fit for recent Linux distributions.
PS. If you are paying support for your Linux system, you should ask your support for advice.

Porting Eigen3 library for Chrome's Portable Native Client (PNaCl) build error

So I have an AWS instance (the free tier one) running with Ubuntu 16.04. There I have installed nacl_sdk (which is working and has allowed me to access their sample sites with success) and naclports which I used to port opencv with which I had trouble with at first due to errors with zlib but got it working after I added i386 architecture and did sudo apt-get update on the system and installed necessary i386 programs.
Note I have depot_tools installed as well.
Now I am trying to install the eigen3 library for pnacl as well but I am getting an error and I am not sure how to understand it nor how exactly it gets built to fix it.
The command that I ported opencv with was
$ NACL_ARCH=pnacl make opencv
And I tried these two commands for building eigen3 with the same results (shown below)
$ NACL_ARCH=pnacl make eigen3
$ bin/webports install eigen3
This is the very end of terminal output (the entire message is very long):
######################################################################
Building eigen3
######################################################################
chdir /home/ubuntu/Work/ExternCode/naclports/src/out/build/eigen3/build_pnacl
make -j1 basicstuff cholesky determinant geo_transformations inverse
Scanning dependencies of target basicstuff
Building CXX object test/CMakeFiles/basicstuff.dir/basicstuff.cpp.o
Linking CXX executable basicstuff
Built target basicstuff
Scanning dependencies of target cholesky
[100%] Building CXX object test/CMakeFiles/cholesky.dir/cholesky.cpp.o
clang: error: unable to execute command: Killed
clang: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 3.7.0 (https://chromium.googlesource.com/a/native_client/pnacl-clang.git cf0dc7f6e6123dfa9b8834b56743315300b34e6c) (https://chromium.googlesource.com/a/native_client/pnacl-llvm.git baa63524b6b493ec2a6aa2c5193d9f25c0c33191)
Target: le32-unknown-nacl
Thread model: posix
clang: note: diagnostic msg: PLEASE submit a bug report to http://llvm.org/bugs/ and include the crash backtrace, preprocessed source, and associated run script.
clang: note: diagnostic msg:
test/CMakeFiles/cholesky.dir/build.make:62: recipe for target 'test/CMakeFiles/cholesky.dir/cholesky.cpp.o' failed
make[3]: *** [test/CMakeFiles/cholesky.dir/cholesky.cpp.o] Error 254
CMakeFiles/Makefile2:14386: recipe for target 'test/CMakeFiles/cholesky.dir/all' failed
make[2]: *** [test/CMakeFiles/cholesky.dir/all] Error 2
CMakeFiles/Makefile2:14393: recipe for target 'test/CMakeFiles/cholesky.dir/rule' failed
make[1]: *** [test/CMakeFiles/cholesky.dir/rule] Error 2
Makefile:5128: recipe for target 'cholesky' failed
make: *** [cholesky] Error 2
webports: Build failed: 'eigen3' [pnacl/release]
clang: error: unable to execute command: Killed
It looks like your AWS instance killed clang, so perhaps it ran out of memory. The free tier gives 1 MiB of RAM and that might not be enough for what you're trying to do.