Unable to compile and run simple Ada application - macos

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!)

Related

What is the meaning of 'ld: library not found for -lm'

I'm a beginner at Fortran code. I install gfortran from the homebrew to my apple silicon mac. The path show in the terminal when I type which fortran is /opt/homebrew/bin/gfortran
I try to use bash shell to run a 'hello world' fortran file on the Desktop (.f90 file). I typed the following command in the terminal. gfortran prog01_01.f90. But it does not work. The error says: ld: library not found for -lm and collect2: error: ld returned 1 exit status. I have no idea how to deal with this problem.
Can anyone please help me this out?
This means that the compiler cannot find the basic mathematical library libm. It should normally be included in your GLIBC or other standard C library installation and be available in the appropriate library directories and I would expect that your package manager would complain that something is missing.
Anyway, you simply have to fix your software installation, we cannot tell you more without details about your system and your software packages. You can try to install GLIBC if you did not install it yet.

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...

Can binutils Be Built Without libiberty? Or Can report_times Be Disabled?

TLDR: Getting fatal error 'failed to get process times' on cross-native build of gcc. Can I remove report_times code from gcc.c OR use gcc command line option to disable report_times OR build gcc without libiberty (which contains pex_get_times used by report_times
DETAIL
After beating my head against various problems I've (finally) successfully used the Android NDK standalone toolchain to build binutils 2.23 and gcc 4.70.
My current problem is getting it to run on my device.
I've written a standard 'hello world' (copied from here) to test gcc on my device. When I run:
arm-linux-eabi-gcc hello.c -o hello
or:
arm-linux-eabi-gcc hello.c
I get the following error:
arm-linux-eabi-gcc: fatal error: failed to get process times: No such file or directory.
Google did not return much except for links to gcc.c source. Examining the source, I found the error in a function (module? extension?) called report_times. The error is returned by the function (module? extension?) pex_get_times....I'm guessing it does so if it can't get the process times.
The pex_get_times function (module? extension? I'm not sure what it is) is defined in libiberty. I can use --disable-build-libiberty, but it doesn't help for the host (my NookHD) gcc build.
My question(s):
Can this portion of gcc.c be safely (and easily) removed...i.e. the report_times function and everything associated with it?
or
Is there a command line option to tell arm-linux-eabi-gcc NOT to use report_times?
or
Is there a way to disable build of libiberty for host/target for both gcc and binutils, and would that fix the error?
As always...I'll keep researching while awaiting an answer.
Found this about an hour after posting this question. Maybe two.
Apparently report_times is part of debugging symbols (?) for GCC. To exclude report_times (which causes the 'failed to get process times' from the original question) you have to build the non-debug...or release...version of gcc.
To do this, I used info from this link: http://www-gpsg.mit.edu/~simon/gcc_g77_install/build.html
BUT, I omitted the -g from the LIBCXXFLAGS and LIBCFLAGS and I added LIBCPPFLAGS without -g just in case. Ran make DESTDIR=/staging/install/path install-host, tarballed and transferred to device. No more 'failed to get process times' error.
I am seeing another error, but it is not related to this question

Building InstallJammer's installkit on Windows

I'm using InstallJammer to build cross-platform installers for my application (Windows, Linux & Mac). However, InstallJammer development has been discontinued and the official forum is now closed.
I need to build the installkit for Windows, because I'll have to make some changes to the Windows install manifest, in order to add Windows 7 support (otherwise the installer displays the message "This program might not have installed correctly").
I grabbed the latest installkit sources from here: http://sourceforge.net/projects/installjammer/files/installkit/1.2.15/installkit-1.2.15.tar.gz/download
I found this topic http://www.installjammer.com/forums/viewtopic.php?f=3&p=9258 which helped me get started.
I grabbed latest version of MinGW and typed ./configure && make. It started the build process, but there was this error while trying to compile TCL:
c:/installkit-1.2.15/src/tcl/win/tclWinReg.c:750:29: error: lvalue required as increment operand
Since these sources are kind of old, I figured I should try with an older GCC version (I was using 4.7.2). So I downgraded MinGW's GCC to version 3.4.5 and tried again.
This time, TCL built fine. Everything was going well, until it failed to build something called 'miniarc' (I don't know what it is), with the following error message:
miniarc.o:miniarc.c:(.text+0x370c): undefined reference to `_imp__strtoull'
miniarc.o:miniarc.c:(.text+0x37c9): undefined reference to `_imp__strtoull'
miniarc.o:miniarc.c:(.text+0x3cb6): undefined reference to `_imp__strtoull'
miniarc.o:miniarc.c:(.text+0x3e78): undefined reference to `_imp__strtoull'
miniarc.o:miniarc.c:(.text+0x3e9f): undefined reference to `_imp__strtoull'
miniarc.o:miniarc.c:(.text+0x3ff5): more undefined references to `_imp__strtoull' follow
collect2: ld returned 1 exit status
Strange thing is that there's no reference to imp_strtoull inside miniarc.c.
Moving on, I tried to build it in Ubuntu, since I didn't know what else to do, and it worked! GCC version was 4.4.3. So I went and searched for GCC 4.4.3 for MinGW, but the closest version was 4.4.0. I grabbed these and tried again. Same tcl build error (regarding tclWinReg.c).
Then I went back to GCC 4.7.2 and replaced TCL & TK sources (8.4) with the latest ones (8.5) and tried again.
TCL and TK both built fine, and so did some other libs, but when it came to 'miniarc', it failed again. This time with a different error:
undefined reference to `TclIncrVar2'
Apparently, this function no longer exists in TCL 8.5.
So, I'm out of ideas. I even tried emailing the original (and only) InstallJammer developer, but still got no answer (I don't even know if his email is the same).
Does anyone have any suggestions?
EDIT: I should add that I have very little experience with Makefiles and the last time I coded in C was 8 years ago in college. So, I apologize if there is something obvious about all this that I didn't notice.
I don't like the solution, but here's how I got it working:
Using GCC 3.4.5, I started the make process by typing ./configure && make;
The make process stops with an error (mentioned above) when it reaches 'miniarc';
Then, manually, I built a DLL (strtoull.dll) from file strtoull.o (below is the exact command-line I typed);
gcc -pipe -shared -o strtoull.dll strtoull.o -lz -L/c/installkit-1.2.15/Windows/lib /c/installkit-1.2.15/Windows/lib/libtclstub84s.a"
After that, I copied strtoull.dll to miniarc/build and to windows/system32;
Then I entered folder miniarc/build and typed:
gcc -pipe -shared -o miniarc01.dll miniarc.o sha1.o md5.o -lz -L/c/installkit-1.2.15/Windows/lib "/c/installkit-1.2.15/Windows/lib/libtclstub84s.a" strtoull.dll
Finally, I typed make again so it could continue building the rest of the stuff.

CROSS-COMPILE FOR MIPS PROCESSOR

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.

Resources