I'm getting the following error whenever I build the RISCV-Qemu-Virt-GCC Project using "make" command

/usr/local/Cellar/riscv-gnu-toolchain/main/lib/gcc/riscv64-unknown-elf/13.2.0/…/…/…/…/riscv64-unknown-elf/bin/ld: final link failed: file in wrong format

collect2: error: ld returned 1 exit status

make: *** [build/RTOSDemo.axf] Error 1

I didn’t edit the makefile or any other files, what could be the error and what could be the solution?

I’m a Mac user

How did you install the RISC-V toolchain? I have the following version and I am able to successfully build this project on Ubuntu -

$ /usr/bin/riscv64-unknown-elf-gcc --version
riscv64-unknown-elf-gcc () 10.2.0
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1 Like

I’m trying to run it on windows 10. Also, I downloaded the required toolchain from GitHub and I added it to the path but still the same error is occurring.
Ps. the toolchain is successfully installed because the version command doesn’t give an error and it gives the same respond as yours.

And you earlier tried on Mac, right? Possible for you try on Ubuntu to confirm if the problem is OS specific?

Would you please share the link where you downloaded from so that I can try the same.

Would you please share the response.

I tried on Mac and it worked great! I can’t try it on ubuntu because I need it on windows.

The link is: I can’t add a link but it is on github riscv-collab/riscv-gnu-toolchain

The response is:

riscv64-unknown-elf-gcc (GCC) 10.1.0
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

I’m sorry for the late reply. I’v been busy

I’m afraid that makefile has both host OS and external dependencies, which it shouldn’t. Try converting it to the style of this more host agnostic makefile: FreeRTOS/FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/build/gcc at main · FreeRTOS/FreeRTOS · GitHub which works on Windows…and if that solves your problem them please submit the updated makefile in a pull request :wink: