Tag: install

Swtching Flutter from snap to native

Swtching Flutter from snap to native

Reinstalling Flutter on UbuntuA recent update saw Flutter compiles on Ubuntu broken due to an issue with lld. This was only on Flutter installed under snap. To fix it, I removed Flutter and reinstalled it from Git. There were a few issues after that so I’ve documented them here. This is the process.

First remove Flutter

sudo snap remove flutter

Then install it manually

cd ~

git clone https://github.com/flutter/flutter.git -b stable

Now modify .bashrc  (I prefer gedit but nano will do)

nano ~/.bashrc

Add this line at the end:

export PATH="$PATH:$HOME/flutter/bin"

Save it then do

source ~/.bashrc

Test the installation

flutter doctor

There may be some missing bits but this should fix them

sudo apt-get install clang cmake ninja-build pkg-config libgtk-3-dev

and repeat flutter doctor until things are ok.

Now I still had some issues

Flutter doctor told me I had a different Dart installed.

So first remove the old one

sudo snap remove dart

Check with

which dart

My configuration still had the wrong dart in it. I searched these

cat /etc/environment 
cat ~/.profile 
cat ~/.bash_profile 
cat /etc/bash.bashrc 
grep -r "dart" ~/.bashrc ~/.bash_profile ~/.profile /etc/environment /etc/bash.bashrc 2
then did
echo $PATH

Which showed no dart references so

ls -la /usr/bin/dart
which dart
sudo apt remove dart

which dart
dart --version
flutter doctor

I then found that it was trying to use a snap version of cmake

cd your_project
flutter clean
rm -rf build/
rm -rf linux/build/

and removed Cmake cache files

rm -rf linux/flutter/ephemeral/
rm linux/CMakeCache.txt 2>/dev/null

Finally I regenerated the build configuration

flutter pub get
flutter config --enable-linux-desktop
flutter create

and all was well and after adding the correct SDK path into the project files, it finally compiled on Linux again. Phew!

New tutorial on installing SDL on Linux

New tutorial on installing SDL on Linux

SDl Demo programWell you might say, “Don’t many Linux distros have SDL installed so people can play games?” and the answer is yes but not the development files and headers, and that’s what this shows you how to do along with a simple program to test that you can compile and run.

You’ll also need clang or gcc installed but as you can do that with a simple sudo apt install clang, it’s hardly worth a tutorial on its own.

However you also need to install VS Code and the C/C++ extension. Go to the VS Code website, download the Linux x64 version and double click on it to install it. After that from a terminal type code and it’ll appear. You then need to select extensions (5th icon down the left hand side) and pick the Microsoft C/C++ extension and install it.

I’ve added a new tutorial on the Tutorials page How to Install SDL on Linux. That includes a link to a demo file (its just above the screenshot) containing all three source code files and four VS Code configuration files for VS Code.

This program is almost identical to the asteroids_ch25 file (it draws lots of random size and colour rectangles on screen) but has been upgraded for Clang 10 and also what looks like a bug with search paths. There’s an extra line in Tasks.json to include the path to the SDL2 header files or you’ll get a can’t find a particular SDL header error when you compile.

Building code with VS Code is easy to understand once you “get” how the Folder works. I always keep the .vscode folder in there with the four C/C++ JSON configuration files and all source for that whatever it is you are compiling.  In the screenshot below (from WinSCP), you can see the path is /home/david/Projects/Examples and it contains the .vscode folder the three source files and demo which is the compiled code.  In VS Code I opened Examples as the Folder.

VS Code Folder

 

The .vscode folder is greyed out because the . means it’s normally hidden.

Hyper-V VMs are not all the same

Hyper-V VMs are not all the same

Hyper-V Ubuntu installOne of the big problems with Hyper-V and Ubuntu in particular is the clipboard or lack of it. I had 18.04 LTS installed with an X Org RDP login. This worked perfectly and I could have a full screen in my Monitor and could copy/paste.  Don’t underestimate copy/paste.

It’s a real PITA if you have to use say WinSCP to copy files over. I think WinSCP is excellent BTW but the amount of labour saving that copy/paste has done since some genius thought it up is immeasurable. That and allowing the full screen of the monitor are two highly important things.

Sadly the 20.04 LTS didn’t seem to allow it. Copy/paste didn’t work between my Windows PC (host) and Ubuntu (guest). There’s nothing worse than losing a feature you’ve grown fond of.

If you follow these instructions for creating a Hyper-V 18.04, you get the screen size popup but not with 20.04 LTS. For that you have to follow these instructions!

It’s things like this that suggest why Linux Desktop has never been that successful. You can waste many hours getting simple things working and sometimes like Copy/Paste they break between versions. And this is with Ubuntu, probably the biggest and best known and supported Distro.