From the archive
Install High Level Assembly (HLA) language compiler on Arch Linux x86_64
Useful things first
I am using Arch Linux x86_64 as my workstation operating system, which provides a lot of “bleeding edge” and up-to-date software. It has an HLA package from AUR so I don’t have to go to the source code and do a lot of compilation. AUR is quite amazing because it provides most of the software you may need as a student, developer or even a professional computer hacker.
To install the package, simply run aurget –Syu hla, and it will just automatically download and install it for you. However, after typing the first “Hello World” code, I encountered a few problems when I was trying to compile the code.
Just before we get to the compile errors, you can download a VIM syntax file here so that you get basic syntax highlighting for the hla file. It does not work really well but it is a good starting point for you to create your own syntax file.
Error:
ERROR! Could not locate the hlalib.a file. Have you set the 'hlalib' environment variable properly? ERROR! Could not locate the HLA INCLUDE directory. Have you set the HLAINC environment variable properly?
What’s wrong and the solution:
This is because the library files which are used to compile the file cannot be found. To solve the problem, you have to set the environment variables hlalib and hlainc. Those two folders can be /usr/hla/lib and /usr/hla/include on most systems if you are compiling from source code. In Arch Linux, however, they are /usr/lib and /usr/include. Therefore, the solution is pretty simple:
export hlalib=/usr/lib #put these two lines in .bashrc export hlainc=/usr/include
Just run the commands above and everything should work fine now. You may find the hlalib.a file in the /usr/lib folder, which tells you that the hlalib variable should point to the folder where the hlalib.a file is located. It may help you if you are using a system where you cannot get it to work using either /usr/hla/lib or /usr/lib. After fixing the library issues, I encountered a new error when I was trying to compile:
Error:
ld: i386 architecture of input file `hw.o' is incompatible with i386:x86-64 output ld: i386 architecture of input file `/usr/lib/hlalib.a(ex_hwExcept.o)' is incompatible with i386:x86-64 output ld: i386 architecture of input file `/usr/lib/hlalib.a(ex_Raise.o)' is incompatible with i386:x86-64 output (tens of lines here)... Error returned by ld = 256
What’s wrong and the solution:
The error comes from linking a 32-bit application with a 64-bit library. In short, you cannot use a 64-bit library to link a 32-bit application. Once you know what is wrong, the fix is even simpler:
hla -lmelf_i386 hw.hla #hw.hla is the name of the source code
This tells the hla program to use a 32-bit library to link the application, which will immediately fix the problem. By the way, you may need to enable the multilib repository to allow 32-bit libraries to be installed on your system.
Chitchat
Recently I found that doing web apps is definitely not the way forward in my career. I am not saying that creating web applications is something not worth doing, but I think it is not something that I want to spend the rest of my life doing. Meanwhile, I am taking a course at Monash University specialising in Network and Software Engineering, which motivates me to dig more into computer science and computer architecture.
I think HLA is definitely something worth learning, because it helps you understand how a computer works at a really low level. In order to learn this language, I chose the book The Art of Assembly Language Programming (AoA) by Randy Hyde. The first step is to install the HLA compiler.
Okay, here is the end of this post. Hope this can help you out with the errors you find in your compilation process. Thanks for reading, and happy coding.