davidrmiller / biosim4

Biological evolution simulator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Trying to gauge how tricky to upgrade CImg.h on Ubuntu

tomachinz opened this issue · comments

Is this a trivial thing or more tricky?

Hello, so I'm on linux (Zorin OS 16) and I seem to need CImg.h, I tried to upgrade:

You can upgrade your CImg.h to version 2.8.4 or later by getting it from the appropriate Debian repository. Sorry I don't have the instructions at hand to do this.

Hmnmm. So I maybe stuck.

git clone https://github.com/davidrmiller/biosim4
cd biosim4/
test -d bin/Debug || mkdir -p bin/Debug
test -d obj/Debug/src || mkdir -p obj/Debug/src
g++ -Wall -fexceptions -g -fopenmp -I/usr/include/opencv4 -c src/signals.cpp -o obj/Debug/src/signals.o
g++ -Wall -fexceptions -g -fopenmp -I/usr/include/opencv4 -c src/main.cpp -o obj/Debug/src/main.o
g++ -Wall -fexceptions -g -fopenmp -I/usr/include/opencv4 -c src/params.cpp -o obj/Debug/src/params.o
g++ -Wall -fexceptions -g -fopenmp -I/usr/include/opencv4 -c src/peeps.cpp -o obj/Debug/src/peeps.o
g++ -Wall -fexceptions -g -fopenmp -I/usr/include/opencv4 -c src/random.cpp -o obj/Debug/src/random.o
g++ -Wall -fexceptions -g -fopenmp -I/usr/include/opencv4 -c src/simulator.cpp -o obj/Debug/src/simulator.o
g++ -Wall -fexceptions -g -fopenmp -I/usr/include/opencv4 -c src/spawnNewGeneration.cpp -o obj/Debug/src/spawnNewGeneration.o
g++ -Wall -fexceptions -g -fopenmp -I/usr/include/opencv4 -c src/survival-criteria.cpp -o obj/Debug/src/survival-criteria.o
g++ -Wall -fexceptions -g -fopenmp -I/usr/include/opencv4 -c src/unitTestBasicTypes.cpp -o obj/Debug/src/unitTestBasicTypes.o
g++ -Wall -fexceptions -g -fopenmp -I/usr/include/opencv4 -c src/unitTestConnectNeuralNetWiringFromGenome.cpp -o obj/Debug/src/unitTestConnectNeuralNetWiringFromGenome.o
g++ -Wall -fexceptions -g -fopenmp -I/usr/include/opencv4 -c src/unitTestGridVisitNeighborhood.cpp -o obj/Debug/src/unitTestGridVisitNeighborhood.o
g++ -Wall -fexceptions -g -fopenmp -I/usr/include/opencv4 -c src/genome-compare.cpp -o obj/Debug/src/genome-compare.o
g++ -Wall -fexceptions -g -fopenmp -I/usr/include/opencv4 -c src/analysis.cpp -o obj/Debug/src/analysis.o
g++ -Wall -fexceptions -g -fopenmp -I/usr/include/opencv4 -c src/basicTypes.cpp -o obj/Debug/src/basicTypes.o
g++ -Wall -fexceptions -g -fopenmp -I/usr/include/opencv4 -c src/createBarrier.cpp -o obj/Debug/src/createBarrier.o
g++ -Wall -fexceptions -g -fopenmp -I/usr/include/opencv4 -c src/endOfGeneration.cpp -o obj/Debug/src/endOfGeneration.o
g++ -Wall -fexceptions -g -fopenmp -I/usr/include/opencv4 -c src/endOfSimStep.cpp -o obj/Debug/src/endOfSimStep.o
g++ -Wall -fexceptions -g -fopenmp -I/usr/include/opencv4 -c src/executeActions.cpp -o obj/Debug/src/executeActions.o
g++ -Wall -fexceptions -g -fopenmp -I/usr/include/opencv4 -c src/feedForward.cpp -o obj/Debug/src/feedForward.o
g++ -Wall -fexceptions -g -fopenmp -I/usr/include/opencv4 -c src/genome.cpp -o obj/Debug/src/genome.o
g++ -Wall -fexceptions -g -fopenmp -I/usr/include/opencv4 -c src/getSensor.cpp -o obj/Debug/src/getSensor.o
g++ -Wall -fexceptions -g -fopenmp -I/usr/include/opencv4 -c src/grid.cpp -o obj/Debug/src/grid.o
g++ -Wall -fexceptions -g -fopenmp -I/usr/include/opencv4 -c src/imageWriter.cpp -o obj/Debug/src/imageWriter.o
src/imageWriter.cpp:13:10: fatal error: CImg.h: No such file or directory
13 | #include "CImg.h"
|          ^~~~~~~~
compilation terminated.
make: *** [Makefile:129: obj/Debug/src/imageWriter.o] Error 1

make -v
GNU Make 4.2.1
Built for x86_64-pc-linux-gnu
Copyright (C) 1988-2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Linux putin 5.11.0-40-generic #44~20.04.2-Ubuntu SMP Tue Oct 26 18:07:44 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

I'm not super pro on c so make is about all I know how to do.

Hi @tomachinz, unfortunately, I think that Zorin 16 is based on Ubuntu 20.04, and the version of CImg.h in that Ubuntu repository is broken. You'll need to install the package called cimg-dev, but not from the default Ubuntu 20.04 repository. I don't know the specific steps, but there is a way to override your package manager's default settings so that when you issue the command "sudo apt install cimg-dev", it will fetch that package from a non-default repository. Perhaps the version in the Debian "testing" repository is sufficiently recent. You'll need version 2.8.4 or later. That will take some research to find out how to do that, or maybe another reader can offer some pointers. Another option is to work in a virtual machine based on Ubuntu 21.04, and then the command "sudo apt install cimg-dev" will install a working version.

CImg is a single-header library, meaning you can simply download the header file from here CImg.h and place it in the project root directory. Then in the Makefile modify INC = -I/usr/include/opencv4 to INC = -I/usr/include/opencv4 -I./ and it should compile.

Thanks @vabenil , that sounds promising. However, note that the package manager would have pulled in a few additional dependencies with CImg.h, but I'm not sure which of those are required for this application. At least libopencv-dev is needed.

Thanks @vabenil , that sounds promising. However, note that the package manager would have pulled in a few additional dependencies with CImg.h, but I'm not sure which of those are required for this application. At least libopencv-dev is needed.

In arch linux at least installing CImg doesn't install opencv as a dependency. I had to manually install opencv and it's dependencies.

I've just got this running on my Windows 11 laptop, using WSL2. The standard Ubuntu distro for WSL2 is 20.04, but I followed these instructions to upgrade to 21.10:


I had to run

sudo apt install build-essential

to get g++ and make, but after that it was easy.

One nice feature of WSL2 is that the Linux file system is accessible through Windows Explorer, so it was easy to navigate to
Linux > Ubuntu-20.04 > home > geoff > biosim4 > images
and view the AVI files in Windows Media Player.....

@geoffarnold, very cool! Congrats and thanks for the report.

I haven't finished setting up the tools, though. gnuplot needs to be installed, and I need to sort out the Python dependencies.

Installing the default cimg-dev (version 2.4.5) for ubuntu doesn't work (as mentioned in the README), because of the following error:
/usr/include/CImg.h:413:10: fatal error: cv.h: No such file or directory

However, then I downloaded a newer version (2.9.4) of cimg-dev from here:
and this fixes the above problem.

I had a Kubuntu laptop I intended to upgrade to 21.10 which I did this morning. I can confirm that other than installing sudo snap install cimg-dev and modifying the biosim4.ini to more modest numbers for debug the program ran right out of the box and creates avi movies in the images directory. Very cool!

I've not investigated the neural net maps shown in the YouTube video, if they even exist in this got clone.

Excellent work David! Thanks!

I'm going to sound like a broken record but you can get around the specifics of your OS by reaching for a tool like docker (see #8, and yes I know it's a sledgehammer but it lets you get up and running quickly). happy to help if anyone's willing to try.

ezoic increase your site revenue