CROSS-COMPILE FOR MIPS PROCESSOR - mips32

i have developed an application for android platform.It is for ARM processor.It's working fine.I want to try the same application on Android running on MIPS(32 bit) processor.I tried to cross-compile the application but could not generate the shared library.I am using MIPS ndk and android source code customized for MIPS processor.While generating static library , it is not showing any errors but while generating the shared library,i am getting following errors:
/home/user/android-ndk-r7m/toolchains/mips-linux-android-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/mips-linux-android/4.4.3/../../../../mips-linux-android/bin/ld: /home/user/workspace/testing/ccl_obj/libccl.a(teccl_call_initiate.o): relocation R_MIPS_HI16 against `__gnu_local_gp' can not be used when making a shared object; recompile with -fPIC
/home/user/workspace/testing/ccl_obj/libccl.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
make: * [obj/local/mips-r2/libhello-jni.so] Error 1
Please suggest any solution.
Thanks

The error seems to suggest what to do.
When compiling your source code, add the -fPIC compiler flag.

Just in case if somebody face this problem.run
make clean
make
I got similar problem today and running clean resolved my problem.

Related

Unable to compile and run simple Ada application

Very new to Ada and have started to learn by doing a Hello World tutorial in GNAT GPS. I'm having a hard time figuring out an error when I compile my code. The error looks like a source file dir issue. But I'm highly unfamiliar with the error output in this type of IDE.
Here is the code I'm trying to compile and run (file: main.adb):
with Ada.Text_IO;
procedure Main is
begin
Ada.text_IO.Put_Line("Hello world!");
null;
end Main;
Image of code and GPS IDE
Here's the build error I'm receiving:
gprbuild -d -P/Users/myname/Desktop/Test/default.gpr /Users/myname/Desktop/Test/src/main.adb
Compile
[Ada] main.adb
Bind
[gprbind] main.bexch
[Ada] main.ali
Link
[link] main.adb
ld: library not found for -lSystem
collect2: error: ld returned 1 exit status
gprbuild: link of main.adb failed
gprbuild: failed command was: /users/myname/opt/gnat/2019/bin/gcc main.o b__main.o -L/Users/myname/Desktop/Test/obj/ -L/Users/myname/Desktop/Test/obj/ -L/users/myname/opt/gnat/2019/lib/gcc/x86_64-apple-darwin17.7.0/8.3.1/adalib/ /users/myname/opt/gnat/2019/lib/gcc/x86_64-apple-darwin17.7.0/8.3.1/adalib/libgnat.a -Wl,-rpath,#executable_path/ -Wl,-rpath,#executable_path/../../..//opt/gnat/2019/lib/gcc/x86_64-apple-darwin17.7.0/8.3.1/adalib -o main
[2019-10-19 11:34:54] process exited with status 4, elapsed time: 01.95s
I'm assuming I installed Ada incorrectly and or GPS. Any suggestions or thoughts? Thank you.
Update/Additional thoughts:
One other thing I'm assuming is that the project is unable to find the Ada source code since the project is saved on the /desktop?
I see you’re running on macOS and using GNAT CE 2019. You need to install Xcode (from the app store, under Develop).
I wrote it up here, but to summarise,
In future, Apple won’t provide includes in /usr/include but instead in the SDK,
clang knows about this but GCC doesn’t,
AdaCore’s response has been to generate their compiler with the system root inside the Xcode SDK,
the system root affects libraries as well as headers,
so no Xcode means no system libraries (in spite of the libraries being in /usr/lib as always!)

Some doubts on kernel building

I was trying to build a kernel for my android device. I would have used my Linux system for building a kernel but unfortunately it had its hdd failed. So I am now using Windows 10 WSL for building the kernel. I am really new in building kernel and I have a few doubts:
When I tried to use arm-linux-gnueabihf 4.7 for making clean I got this error:
ccache execv 'my toolchain path' execv format error
I tried it with few other toolchains but same error came. Then I used arm-eabi 4.8 which worked correctly. This solved the problem but I would like to know what the error was and what caused it and is there a fix?
How should I know what toolchain I should use for building kernels like some people tell me to use a toolchain some people tell me to use someother toolchain.
When I tried to build the kernel with arm-eabi 4.8 I got an error
/home/inkiluz/kernel/security/tima_uevent/tima_uevent.c:217:1: fatal error: opening dependency file security/tima_uevent/.tima_uevent.o.d: No such file or directory
module_exit(tima_uevent_exit);
^
compilation terminated.
Is this a toolchain error or did i do something wrong? How can I rectify this?
Here is the the error log: https://del.dog/diwijegetu.
Please do help me out...

GCC giving an error for a file that has no errors and saying it's the wrong file format/extension

I am compiling an app for 32bit machines since the creator of the app made it 64 bit. I made sure all the libraries and DLLs are 32bit, which they are. I have an issue when I compile, however. When I compile using sh make.sh, I get an error when it gets to the GCC building part. make.sh just makes sure that all the needed libraries are there for this project. There's no errors in the Makefile, make.sh, or any of the C++ files. I've been wasting hours trying to figure this out.
Here's a screenshot if it helps:
Needed to enable -D_WIN32 os flag in make.sh.

CMake: The C Compiler is not able to compile a simple test program

I am trying to cross-compile the Azure IoT SDK C for a Mips processor. Cross-compiling an older version of the same SDK using an older version of CMake (2.8.12.2) works just fine, so I doubt it's the code itself. I am guessing it's the Mips GCC compiler.
Error message:
CMake Error at /usr/share/cmake-3.10/Modules/CMakeTestCCompiler.cmake:52 (message):
The C compiler
"/usr/local/mipsisa32r2el/r23/bin/mipsisa32r2el-axis-linux-gnu-gcc"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: /home/axis/azure-iot-sdk-c/cmake/iotsdk_linux/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/make" "cmTC_2cc84/fast"
/usr/bin/make -f CMakeFiles/cmTC_2cc84.dir/build.make CMakeFiles/cmTC_2cc84.dir/build
make[1]: Entering directory '/home/axis/azure-iot-sdk-c/cmake/iotsdk_linux/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_2cc84.dir/testCCompiler.c.o
/usr/local/mipsisa32r2el/r23/bin/mipsisa32r2el-axis-linux-gnu-gcc --sysroot=/usr/local/mipsisa32r2el/r23 -o CMakeFiles/cmTC_2cc84.dir/testCCompiler.c.o -c /home/axis/azure-iot-sdk-c/cmake/iotsdk_linux/CMakeFiles/CMakeTmp/testCCompiler.c
Linking C executable cmTC_2cc84
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_2cc84.dir/link.txt --verbose=1
/usr/local/mipsisa32r2el/r23/bin/mipsisa32r2el-axis-linux-gnu-gcc --sysroot=/usr/local/mipsisa32r2el/r23 -rdynamic CMakeFiles/cmTC_2cc84.dir/testCCompiler.c.o -o cmTC_2cc84
/usr/local/mipsisa32r2el/r23/lib/gcc/mipsisa32r2el-axis-linux-gnu/4.7.2/../../../../mipsisa32r2el-axis-linux-gnu/bin/ld: this linker was not configured to use sysroots
collect2: error: ld returned 1 exit status
CMakeFiles/cmTC_2cc84.dir/build.make:97: recipe for target 'cmTC_2cc84' failed
make[1]: *** [cmTC_2cc84] Error 1
make[1]: Leaving directory '/home/axis/azure-iot-sdk-c/cmake/iotsdk_linux/CMakeFiles/CMakeTmp'
Makefile:126: recipe for target 'cmTC_2cc84/fast' failed
make: *** [cmTC_2cc84/fast] Error 2
Unfortunately, I am stuck with the Mips GCC compiler I have. Is there a way to disable this test-program check?
Solution was to add these to the toolchain-file:
SET (CMAKE_C_COMPILER_WORKS 1)
SET (CMAKE_CXX_COMPILER_WORKS 1)
CMake tries to compile an executable using "standard" (as per what CMake thinks is standard) compiler options and tries to run that executable, so to see if the compiler is working. The executable is simple like int main(int argc, char *argv[]) { return argc - 1; }.
You can't do that when cross-compiling. Because usually you can't link with a proper C standard library, you don't have printf, or _start or _exit or similar, passing arguments to main is implementation-defined, or you need a special linker script, or there's no emulator for your architecture, so can't run cross-compiled source on the host, etc... Simply: you usually can't run the cross-compiled executable on the host, and most of the time even the compilation is hard enough to do.
The common solution is to set before project():
set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY")
So that CMake will try to compile a static library not an executable, as explained in cmake docs CMAKE_TRY_COMPILE_TARGET_TYPE. This avoids running the linker and is intended for cross-compiling.
You can set CMAKE_C_COMPILER_WORKS and it will omit the check in CMakeTestCCompiler.cmake, but CMAKE_TRY_COMPILE_TARGET_TYPE is a more proper solution.
Well this problem is really annoying, i faced this issue for 2 day now I got solution.
Let me explain my issue first
When I delete NDK and Cmake from Sdk folder and Run my application then grable install NDK and Cmake again.
Only that time Application run and when try to run again i get this error The C Compiler is not able to compile a simple test program.
Before i was using ndkVersion "22.0.7026061" then change to thisndkVersion "21.1.6352462" and IT WORKED.
I think this is NDK problem and most of answer are outdated try this i hope this will HELP.
If using CMake GUI, you can add a boolean entry named
CMAKE_CXX_COMPILER_FORCED
then set it to True.
This will skip checking process for this build.
Ran into the same problem while re-compiling a project. Turned out that the compiler had been updated in the meantime.
After removing the build directory and creating it again, the compilation completed without errors.

Relocation truncated to fir error with pgi and gcc compilers

I am getting an error with gcc(7.2.0) and also pgi(18.4) compilers.
There is a scientific application (in fortran) that I am compiling that has some dependencies.
These dependencies are compiled with -fPIC flag.
While compiling the main application, I get an error "relocation truncated to fit".
When I add the flag -mcmodel=medium(pgi), the compilation succeds.
But I am not willing to add this flag for some reasons.
Also when I compile the main application with -fPIC, i get linker error and a suggestion to add --no-relax flag.
After adding the same, I still get the relocation error.
Is there any way I can compile without the -mcmodel=medium flag?
Edit:
Also, when using gnu compilers, whatever mcmodel I use, I am getting the relocation error. Can this be something related to an old linker. Because I think, the application and its dependencies are compiled with 64 bit libraries, and the linker is what I assume operates with 32 bit libraries. As a reason for successful compilation with pgi when I perform /ld-linux.so --list , I get an error saying cannot map to zero fill pages. And while running the executable, I get a message as Killed.

Resources