# Config RISCV with GSL library on Ubuntu

**URL:** <https://forums.sifive.com/t/config-riscv-with-gsl-library-on-ubuntu/3339>\
**Category:** RISC-V\
**Created:** [February 14, 2020, 12:21pm UTC](https://forums.sifive.com/t/config-riscv-with-gsl-library-on-ubuntu/3339 "2020-02-14T12:21:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![asiddiqui](https://avatars.discourse-cdn.com/v4/letter/a/47e85d/32.png) [@asiddiqui](https://forums.sifive.com/u/asiddiqui)\
**Post date:** [February 14, 2020, 12:21pm UTC](https://forums.sifive.com/t/config-riscv-with-gsl-library-on-ubuntu/3339/1 "2020-02-14T12:21:11Z")

</div>

Hello,  
I’m trying to compile GSL with RISCv compiler.  
if i configure GSL for cross comiling with the following command

./configure --host=riscv64-unknown-elf --prefix=$ path to riscv install toolchain/bin

then it gives the following error

riscv-unknown-elf-gcc/lib/libgsl.a(fdiv.o): ABI is incompatible with that of the selected emulation:  
target emulation `elf64-littleriscv' does not match`elf32-littleriscv’

and if i use 32bit flags in the config command

./configure --host=riscv64-unknown-elf --prefix=$ path to riscv install toolchain/bin --with-march=rv32i --with-mabi=ilp32

then the failure is incompatible libraries.

Can anyone please guide me what is the mistake and what i’m missing.  
Thank you.

---

<div class="post-metadata">

**Author:** ![jimw](https://avatars.discourse-cdn.com/v4/letter/j/f14d63/32.png) [@jimw](https://forums.sifive.com/u/jimw)\
**Post date:** [February 14, 2020, 5:39pm UTC](https://forums.sifive.com/t/config-riscv-with-gsl-library-on-ubuntu/3339/2 "2020-02-14T17:39:18Z")

</div>

You are using --host=riscv64-unknown-elf but the error message mentions riscv-unknown-elf. riscv-unknown-elf is a non-standard configure triplet, suggests maybe you are using Liviu’s toolchain. Anyways, it looks like your compiler is 32-bit by default, so you probably need to use riscv32-unknown-elf (or riscv-unknown-elf) as the --host option to make this work. If you really want 64-bit code, then you need to configure for riscv64-unknown-elf and add -march/-mabi options to emit 64-bit code.

---

<div class="post-metadata">

**Author:** ![asiddiqui](https://avatars.discourse-cdn.com/v4/letter/a/47e85d/32.png) [@asiddiqui](https://forums.sifive.com/u/asiddiqui)\
**Post date:** [February 17, 2020, 1:40pm UTC](https://forums.sifive.com/t/config-riscv-with-gsl-library-on-ubuntu/3339/3 "2020-02-17T13:40:02Z")

</div>

Hello Jim,  
Thank you for your reply.

i’m trying to cross compile GSL library([https://www.gnu.org/software/gsl/](https://www.gnu.org/software/gsl/)) for RISCV architecture.  
i used the following command to configure the GSL library for cross comiling

**./configure --host=riscv64-unknown-elf --build=x86\_64-pc-linux-gnu --target=riscv64-unknown-elf --prefix=$RISCV CFLAGS="-march=rv32i -mabi=ilp32"**

and the incompatible issue is now resolved.

i have another issue “ram size problem”  
The error is

**main.elf section `.text' will not fit in region` ram’**  
**/home/ali/Microsemi\_SoftConsole\_v5.3/riscv-unknown-elf-gcc/bin/…/lib/gcc/riscv64-unknown-elf/7.2.0/…/…/…/…/riscv64-unknown-elf/bin/ld: region `ram’ overflowed by 288784 bytes.**

i think now the code is much bigger than the allowed ram.  
Do you have any idea how can i solve this…???

Thank you very much.

---

<div class="post-metadata">

**Author:** ![jimw](https://avatars.discourse-cdn.com/v4/letter/j/f14d63/32.png) [@jimw](https://forums.sifive.com/u/jimw)\
**Post date:** [February 17, 2020, 5:28pm UTC](https://forums.sifive.com/t/config-riscv-with-gsl-library-on-ubuntu/3339/4 "2020-02-17T17:28:32Z")

</div>

You need to make the program smaller or the target memory bigger. Using a -march with more features would help. Compiling with -Os if not already would help. Maybe the prorgam has optional features that can be configured off to reduce program size. I don’t know GSL so I can’t offer any specific suggestions.

---

<div class="post-metadata">

**Author:** ![asiddiqui](https://avatars.discourse-cdn.com/v4/letter/a/47e85d/32.png) [@asiddiqui](https://forums.sifive.com/u/asiddiqui)\
**Post date:** [February 18, 2020, 7:43am UTC](https://forums.sifive.com/t/config-riscv-with-gsl-library-on-ubuntu/3339/5 "2020-02-18T07:43:47Z")

</div>

Thank you Jim,  
I compiled with -Os and the size is approx 70% reduce but bigger than my memory.  
I also tried to delete some folder but the size remains the same in memory.  
if you have another idea then please share.  
Thank you for your help.
