Skip to content

Instantly share code, notes, and snippets.

@robodhruv
Last active September 10, 2023 17:23
Show Gist options
  • Star 74 You must be signed in to star a gist
  • Fork 12 You must be signed in to fork a gist
  • Save robodhruv/e2c0945cc78006b00d4206846bdb7657 to your computer and use it in GitHub Desktop.
Save robodhruv/e2c0945cc78006b00d4206846bdb7657 to your computer and use it in GitHub Desktop.
Installing ModelSim on Ubuntu

ModelSim Installation issues

Ubuntu 14.xx and above

Ignore this if you have not encountered any issue with the installation and running of ModelSim and Quartus on your system. You are very lucky. (Just Kidding! You have surely had this issue, only sorted.)

Hence assuming you have been following the procedure given in this guide. Most certainly, Quartus will install jsut fine, and so will ModelSim. The issue is in launching due to inappropriate linking etc.

Stage 1

This is the simplest error you would encounter. Navigate to the modelsim_ase folder and run:

cd /opt/modelsim_ase/bin/
./vsim

Unless you have not updated your Linux kernel in the last 3 years, you are most certain to encounter an error saying could not find ./../linux_rh60/vsim. To understand this (optional) you can open the file vsim and notice that in the if...elseif conditions, the default description points towards a folder for the Red Hat distro.
(This setup will only work for you without changes IF your Linux kernel is 3.x or below. Highly unlikely. Check using uname -r).

Okay, all of that aside, basically you need to replace this as (sudo is your friend!) :

*)                vco="linux" ;; # This is most likely to be line 212 (initially vco="linux_rh60")

Also, change the very first non-commented line to:

mode=${MTI_VCO_MODE:-"32"}

This should be adequate for most of you, and running /opt/modelsim_ase/bin/vsim will open a plain boring GUI. For that lot, thanks a lot for sticking around! Hope it helped. The others, keep following.

Stage 2

Here is where things get nasty. Does running the vsim script lead to:

** Fatal: Read failure in vlm process (0,0)
Segmentation fault (core dumped)

If yes, hang on. If not, I am sorry! Google is your friend!

I am guessing this issue came up for me because of the infinite existing packages on my system, including ROS. That seems to have ruined the setup for me, and hence more learning about the intricacies of compilation and linking. Totally worth it!

Okay, so here's what you would have to do. You probably need to build a new version of freetype, a font setting library and modify ModelSim to use it. You can download the source code for freetype here.

sudo apt-get build-dep -a i386 libfreetype6
# The above forced me to uninstall my ROS packages, and well.. I had no choice. Temporarily, let's remove them and proceed
cd ~/Downloads/
cd freetype-2.4.12
./configure --build=i686-pc-linux-gnu "CFLAGS=-m32" "CXXFLAGS=-m32" "LDFLAGS=-m32"
make -j8

Most certainly, the above would give you an error looking like:

checking whether the C++ compiler works... no
...
configure: error: C++ compiler cannot create executables

This is because you could be on a 64-bit system but you will also need the 32-bit versions of the libraries that it depends on. After an hour of fretting, here's what you'll have to do.

sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install build-essential
# You already had build-essential and gcc, g++ etc. But you will also need to install the 32 bit versions.

sudo apt-get install gcc-multilib g++-multilib \
lib32z1 lib32stdc++6 lib32gcc1 \
expat:i386 fontconfig:i386 libfreetype6:i386 libexpat1:i386 libc6:i386 libgtk-3-0:i386 \
libcanberra0:i386 libpng12-0:i386 libice6:i386 libsm6:i386 libncurses5:i386 zlib1g:i386 \
libx11-6:i386 libxau6:i386 libxdmcp6:i386 libxext6:i386 libxft2:i386 libxrender1:i386 \
libxt6:i386 libxtst6:i386

This just about solves the dependency issues and compiler errors. Run the following inside freetype... folder.

./configure --build=i686-pc-linux-gnu "CFLAGS=-m32" "CXXFLAGS=-m32" "LDFLAGS=-m32"
make -j8

This should nicely compile and give you the libraries in the directory objs/.libs/. Move this to the modelsim_ase folder and define the linkings. Almost done here...

mkdir /opt/modelsim_ase/lib32

sudo cp ~/Downloads/freetype-2.4.12/objs/.libs/libfreetype.so* /opt/modelsim_ase/lib32

sudo vim /opt/modelsim_ase/bin/vsim

Find the line which says

dir=`dirname $arg0`

(Note that this occurs in multiple locations. In simple terms, look at the one in the main sequence of execution, and not in the if statement. You can ignore the one under CYGWIN. Cygwin is for Windows. Windows is for losers! :p Apologies.)

Below this add the line:

export LD_LIBRARY_PATH=${dir}/lib32

Save this file. This would only be possible if you have sudo permissions. And finally!

cd /opt/modelsim_ase/bin/
./vsim

Hopefully, a plain boring GUI will show up!

Hope this helped. Cheers!
Dhruv

@te-bachi
Copy link

Thanks a lot for sharing the solution. Works with Linux Mint 19 Tara and Quartus 18.1 (just the path is different: /opt/intelFPGA_lite/18.1/modelsim_ase)

@dannyerdr
Copy link

thanks a lot

@v21cesc
Copy link

v21cesc commented Jan 23, 2019

Great, thanks

@LuizFelipeLemon
Copy link

Thank you very much!!!!

@AlefCS
Copy link

AlefCS commented Mar 15, 2019

Thank you so much. I was already frustrated because I wasn't finding any solution for this problem (because I tried to solve one and then another error appear until I couldn't solve something) but this totally worked.

@edwin-oetelaar
Copy link

Thank you very much.

@koko-ng
Copy link

koko-ng commented Apr 17, 2019

Thanks, a lot for this guide. Everything ran smoothly except that I had to remove libpng12-0 from the packages to install.

EDIT: I didn't read the guide completely ^^

@abdo1819
Copy link

abdo1819 commented Apr 29, 2019

it finally works thanks a lot by the way libpng12-0 wasn't found for me too but i remove it and it works great
i added this comment in fork and link to download it

@santosrafael
Copy link

It worked on Linux Mint 19.1 Tessa.
Thank you very much!

@Rainerino
Copy link

Thank you so much! It works on Ubuntu 19.10.

@clwe
Copy link

clwe commented Jan 17, 2020

Thanks! Works on Kubuntu 19.10 over here.

@tudor-sandu
Copy link

Thanks! worked on Ubuntu 19.04.

@cuciureansergiu
Copy link

cuciureansergiu commented Apr 26, 2020

If you still get on ubuntu

configure: error: C compiler cannot create executables

try

sudo apt-get install gcc-multilib

@ksielewi
Copy link

Thanks a lot!

@FedorChervyakov
Copy link

FedorChervyakov commented May 20, 2020

If you want to launch modelsim from Quartus, you have to edit quartus/adm/qenv.sh in the following way:

  • find the line export LD_LIBRARY_PATH=$QUARTUS_BINDIR:$LD_LIBRARY_PATH
  • prepend it with the path to a folder containing libfreetype 32-bit shared objects. So if you followed the instructions above, it should look like this: export LD_LIBRARY_PATH=/opt/modelsim_ase/lib32:$QUARTUS_BINDIR:$LD_LIBRARY_PATH

@jackfrye
Copy link

@FedorChervyakov can you please detail your changes to quartus_sh? I am having this issue, but the file looks entirely different that vsim so I am not exactly sure what lines to change.

Also, thanks to whoever posted what is at the top. I almost cried when the ModelSim window came up.

@FedorChervyakov
Copy link

FedorChervyakov commented May 25, 2020

@jackfrye I apologise for the inconvenience, you should edit the quartus/adm/qenv.sh instead of quartus/bin/quartus_sh. Kindly check the original comment, I've updated it with proper instructions.

@jackfrye
Copy link

@FedorChervyakov , I still cannot launch the ModelSim-Altera simulator from the tool. I seem to get this error message in the .rpt

Info: Starting NativeLink simulation with ModelSim-Altera software
Sourced NativeLink script /home/jfrye/intelFPGA_lite/19.1/quartus/common/tcl/internal/nativelink/modelsim.tcl
Warning: File test_run_msim_rtl_none.do already exists - backing up current file as test_run_msim_rtl_none.do.bak5
TCL READ VARNAME
Error: NativeLink simulation flow was NOT successful

@bernimgr
Copy link

bernimgr commented Jun 4, 2020

Hi,

Great job, it works great for me on Xubuntu 18.04.4 LTS !!
Some libs have not be found but it works great anyway!
Awesome!

Thanks a lot and keep the good job !

@Jellycious
Copy link

Hi,

Amazing fix. Works on Ubuntu 18.0.4.1

@cruelkiddy
Copy link

You saved my life for 2 times, one for Modelsim PE 15.1, one for Modelsim SE 10.2c. Thanks a lot !!!!!!!!!!

@kalindkaria
Copy link

kalindkaria commented Jul 4, 2021

Thanks a lot. It saved my time!
Got ModelSim running on 18.04 finally.

@Bingo600
Copy link

Bingo600 commented Sep 5, 2021

Your guide saved me too.
Quartus 13.01-sp1 on Linux Mint 17.
I'm running Quartus in 64bit mode , and at first "just" built Freetype with a plain "./configure" , to get 64bit modules.
Didn't work , so i followed your guide & built 32bit modules , now visim started fine.

Had to edit the env. file as per a hint in this thread , to get modelsim started from quartus , and now everything is perfect.

Thank you

Ps: The link to the Freetype bz2 archive is not working , the file has moved to the "archive"

@lf-
Copy link

lf- commented Sep 13, 2021

I have a script to build both a boomer fontconfig and a boomer freetype, which I need to resolve problems with FT_Done_MM_VAR symbol not found errors while dealing with the combination of new fontconfig and old freetype: instead, build both of them against each other, with appropriately old versions. You can get it from here: https://gist.github.com/lf-/3e642f409e99dd7faa8ce353992e53f4

I applied the suggested fixes and also added the custom LD_LIBRARY_PATH to the latter part of the vco script.

I also incidentally needed lib32-ncurses5-compat-libs from the AUR to run Quartus 18 on modern Arch Linux. Additionally, libpng12 was required from the repos.

@Kunkka1988
Copy link

Thanks. The confliction between freetype/fontconfig and vsim is root cause.
We don't have to select and use the 32bit vsim.

@benjamin051000
Copy link

benjamin051000 commented Sep 17, 2022

Not working in Fedora 36 (I doubt this is a supported OS but Quartus works fine so I'm not sure what's up with modelsim)

  • Modelsim 20.1 Lite
  • I set the custom installpath to be ~/.intelFPGA because I like to hide as much as possible in my homedir. Let me know if you think this could be the culprit
$ ./vsim
./vsim: line 182: /home/benjamin/.intelFPGA/20.1/modelsim_ase/bin/../linux/vsim: No such file or directory

But when I actually check that dir,

$ cd /home/benjamin/.intelFPGA/20.1/modelsim_ase/bin/../linux/    

$ ll | grep vsim
-rwxr-x---. 1 benjamin benjamin 6.8M Feb 28  2020 vsim
-rwxr-x---. 1 benjamin benjamin  35M Feb 28  2020 vsimk
-rw-r-----. 1 benjamin benjamin  87M Feb 28  2020 vsimk32.esf
-rw-r-----. 1 benjamin benjamin 170K Feb 28  2020 vsimka.mdb

$ file vsim
vsim: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, for GNU/Linux 2.6.18, BuildID[sha1]=14c9896a96df1d7224e4fd03ef7434e6432af57c, stripped

It's definitely there! What's going on? Even if I try to run this executable directly it doesn't work.

@lf-
Copy link

lf- commented Sep 17, 2022

@benjamin051000 that's actually a dynamic linker error. try running ldd with that executable path and see what it says. I expect you will find a missing library.

@benjamin051000
Copy link

@lf- This is what I'm seeing on Fedora 36:
image
The only thing I did that was non-standard is install to .intelFPGA so the file is hidden, but this shouldn't matter as far as I know. I'm not really sure how vsim startup works but I find it really weird that trying to run ./linux/vsim yields this error when file definitely sees it...

@yhkwon6658
Copy link

yhkwon6658 commented Sep 10, 2023

@benjamin051000
Centos also has same trouble shooting. I think this solution is for only ubuntu.
However, I found something.
vsim command mode is well working.
E.g.) vsim -c -do "vlib work; vlog *.v *.sv; vsim tb; run -all; quit"
It's work well for Dispalying to the terminal or File I/O
Also, I know using questasim(not modelsim) doesn't make any problem.

@benjamin051000
Copy link

@yhkwon6658 I have recently found that using https://github.com/89luca89/distrobox is the easiest solution of all: It containerizes your tool and allows you to choose a distro that the tool officially supports. This is my current go-to solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment