How to compile with FLTK under Ubuntu - c++

I am using Code:blocks under Ubuntu 12.04 LTS. I am attempting to compile my first program using FLTK and I get the following errors.
Linking console executable: bin/Debug/<project name removed for security reasons>
/usr/bin/ld: cannot find -lXft
/usr/bin/ld: cannot find -lfontconfig
/usr/bin/ld: cannot find -lfontconfig
/usr/bin/ld: cannot find -lXinerama
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 0 seconds)
4 errors, 0 warnings
Is there something else I need to install, or a path I need to add?

To build an FLTK project in Code::Blocks 16.01 on UBUNTU 16.04.
Install FLTK and two additional packages:
$ sudo apt install fltk1.3-dev
$ sudo apt install libxft-dev
$ sudo apt install libxinerama-dev
After this, you can define an FLTK project, and build it without problems.
If you do not install the libxft-dev and libXinerama-dev packages, you will indeed get these error messages listed in question about missing libraries (-lXft, -lfontconfig, -lXinerama).
The reason these packages are not installed automatically with fltk1.3-dev is because they're only 'suggested', and not a hard dependency. This can be seen here:
package: libfltk1.3-dev
However, the 'fltk-config' flag which is used by Code:Blocks to decide what libraries to link in requires them.
For more detail on the fltk-config flag, see:
Beginners Guide to fltk-config
For completeness, here the links to the 2 additional packages:
package: libxft-dev
package: libxinerama-dev

The dev version of libraries used by FLTK might be missing http://packages.ubuntu.com/precise/libfltk1.3 .
You can use apt-get to install them : libxft-dev, libfontconfig1-dev and libxinerama-dev.

You obviously do not have libXft, libfontconfig and libXinerama installed on your machine. If you installed FLTK using Ubuntu package manager, then you should report missing dependency information in the FLTK package.
Typically we do this by finding out who is the package maintainer, and send e-mail to that person.

I managed to get code:blocks 13.12 working with FTLK on Raspberry Pi using Raspian. CodeBlocks gave me those same errors "cannot find -lXft" "cannot find -lfontconfig" and "cannot find -lXinerama".
I used the add/remove software provided with Raspian and searched for each of the following libraries libxft-dev, libfontconfig1-dev and libxinerama-dev and then I installed them using the package manager. When I restarted codeblocks FLTK worked fine!

Related

Error during project compilation in QT [duplicate]

I just reinstalled QtCreator, created new project (Qt Application) an got this after compilation:
/usr/bin/ld: **cannot find -lGL**
collect2: error: ld returned 1 exit status
make: *** [untitled1] Error 1
18:07:41: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project untitled1 (kit: Desktop Qt 5.1.0 GCC 32bit)
When executing step 'Make'
(Project is empty, I did'n commit any changes)
Qt Creator 2.7.2
Based on Qt 5.1.0 (32 bit)
Ubuntu 13.04
How do I solve this problem?
You should install package "libgl1-mesa-dev":
sudo apt install libgl1-mesa-dev
you don't need to install anything. libGL is already installed with Ubuntu, you just need to soft link it. (tested for ubuntu 14.x and 15.x, might work for later versions)
First locate the GL library
Then link it under /usr/lib
If the library is missing, it can be installed via libgl1-mesa-dev package
Here is how you could do this:
$ locate libGL
/usr/lib/i386-linux-gnu/mesa/libGL.so.1
/usr/lib/i386-linux-gnu/mesa/libGL.so.1.2.0
/usr/lib/x86_64-linux-gnu/libGLEW.so.1.10
/usr/lib/x86_64-linux-gnu/libGLEW.so.1.10.0
/usr/lib/x86_64-linux-gnu/libGLEWmx.so.1.10
/usr/lib/x86_64-linux-gnu/libGLEWmx.so.1.10.0
/usr/lib/x86_64-linux-gnu/libGLU.so.1
/usr/lib/x86_64-linux-gnu/libGLU.so.1.3.1
/usr/lib/x86_64-linux-gnu/mesa/libGL.so.1
/usr/lib/x86_64-linux-gnu/mesa/libGL.so.1.2.0
/usr/lib/x86_64-linux-gnu/mesa-egl/libGLESv2.so.2
/usr/lib/x86_64-linux-gnu/mesa-egl/libGLESv2.so.2.0.0
$ sudo ln -s /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1 /usr/lib/libGL.so
The gui Qt module is included by default. If you don't want to use it in a project (e.g., it is a library or only uses stdio), you need to specify that in the .pro file.
QT -= gui
And the linker won't attempt to find lGL regardless of whether it is installed.
My case is admittedly a bit odd, since the main reason to use Qt is to create gui's. Installing the GL library is certainly not difficult, I just wanted to know why my quick and dirty Hello World wanted it.
write:
yum provides */libGL.so
after providing:
yum install mesa-libGL-devel mesa-libGLU-devel
This worked for me:
sudo ln -s /usr/lib/libEGL1.so /usr/lib/libGL.so
My system is Ubuntu 16.04 on x86 computer(with NVIDIA GeForce GPU).
Check the library files located in /usr/lib/x86_64-linux-gnu
ls -al /usr/lib/x86_64-linux-gnu/libG*
If you see the broken link, reinstall libgl1-mesa-glx
sudo apt install --reinstall libgl1-mesa-glx
And, recheck library.
In my case: I have installed QT 32 bit lib in Win10 64 bit and it ran into error, I change to all 64 bit and QT creator run smoothly.
Solved this problem just a minute ago in suse.
Just do the following step below and QTCreator should works just fine.
sudo zypper install --type pattern devel_basis

Error with homebrew + opencv + libpng

On Mac OS Maverick I have installed OpenCV with a brew install opencv.
I created a simple program (copied from this tutorial). Compilation worked fine but when running the executable I get the following error:
dyld: Library not loaded: /usr/local/lib/libpng16.16.dylib
Referenced from: /usr/local/lib/libopencv_highgui.2.4.dylib
Reason: Incompatible library version: libopencv_highgui.2.4.dylib requires version 33.0.0 or later, but libpng16.16.dylib provides version 32.0.0
Trace/BPT trap: 5
I checked that libpngwas properly installed via brew install libpng and ran a brew upgrade to make sure everything was up-to-date.
Running locate libpng16.dylib returns:
/Applications/GIMP.app/Contents/Resources/lib/libpng16.16.dylib
/usr/local/Cellar/libpng/1.6.10/lib/libpng16.16.dylib
/usr/local/Cellar/libpng/1.6.12/lib/libpng16.16.dylib
/usr/local/Cellar/libpng/1.6.13/lib/libpng16.16.dylib
/usr/local/Cellar/libpng/1.6.15/lib/libpng16.16.dylib
/usr/local/lib/libpng16.16.dylib
Any idea?
The best solution is to fully uninstall libpng and re-install it:
$ sudo brew uninstall libpng
$ sudo rm '/usr/local/bin/libpng-config'
$ for i in `brew link --overwrite --dry-run libpng`; do sudo rm $i; done
$ sudo brew install libpng
If you need to install opencv:
$ sudo brew tap homebrew/science
$ sudo brew install opencv
Homebrew should ensure that you the correct dependencies install. However, it's possible that you have more than one version of libpng16 installed at different paths. Have a look in...
/usr/lib
/opt/local/lib
If you find any versions of the library in these locations then they may be causing the wrong one to be loaded when your program starts. As a quick fix you can try typing DYLD_LIBRARY_PATH=/usr/local/lib before your program name on the command line. In the longer term you may need to remove the conflicting versions altogether.
This answer is for OSX users who installed through Conda, more specifically the conda-forge channel (I'm not sure about others).
Conda ends up installing its own libpng in the environment and you can update it with conda upgrade libpng.
I guess this is basically a bug with the opencv recipe on conda-forge.

Cannot find library when building with Qt Creator

I'm using ubuntu 12.04 64-bit.
I when building a project I receive an error:
cannot find -lNSPR
collect2: ld returned 1 exit status
the .pro file contains
libraries.path = /opt/my_dir
libraries.files = \
engine/x64/libNSPR.so \
Why can't it find the library?
The only workaround so far - I just put libNSPR.so into /usr/lib/x86_64-linux-gnu directory.
From there linker picked the library and build was successful.
I understand that it's not the best way to solve the problem, so constuctive criticism is welcome.
Install Qt libraries by apt-get
sudo apt-get install libqt4-core libqt4-gui
Also you can install for having all libraries
sudo apt-get install libqt4-*

Qt: can't find -lGL error

I just reinstalled QtCreator, created new project (Qt Application) an got this after compilation:
/usr/bin/ld: **cannot find -lGL**
collect2: error: ld returned 1 exit status
make: *** [untitled1] Error 1
18:07:41: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project untitled1 (kit: Desktop Qt 5.1.0 GCC 32bit)
When executing step 'Make'
(Project is empty, I did'n commit any changes)
Qt Creator 2.7.2
Based on Qt 5.1.0 (32 bit)
Ubuntu 13.04
How do I solve this problem?
You should install package "libgl1-mesa-dev":
sudo apt install libgl1-mesa-dev
you don't need to install anything. libGL is already installed with Ubuntu, you just need to soft link it. (tested for ubuntu 14.x and 15.x, might work for later versions)
First locate the GL library
Then link it under /usr/lib
If the library is missing, it can be installed via libgl1-mesa-dev package
Here is how you could do this:
$ locate libGL
/usr/lib/i386-linux-gnu/mesa/libGL.so.1
/usr/lib/i386-linux-gnu/mesa/libGL.so.1.2.0
/usr/lib/x86_64-linux-gnu/libGLEW.so.1.10
/usr/lib/x86_64-linux-gnu/libGLEW.so.1.10.0
/usr/lib/x86_64-linux-gnu/libGLEWmx.so.1.10
/usr/lib/x86_64-linux-gnu/libGLEWmx.so.1.10.0
/usr/lib/x86_64-linux-gnu/libGLU.so.1
/usr/lib/x86_64-linux-gnu/libGLU.so.1.3.1
/usr/lib/x86_64-linux-gnu/mesa/libGL.so.1
/usr/lib/x86_64-linux-gnu/mesa/libGL.so.1.2.0
/usr/lib/x86_64-linux-gnu/mesa-egl/libGLESv2.so.2
/usr/lib/x86_64-linux-gnu/mesa-egl/libGLESv2.so.2.0.0
$ sudo ln -s /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1 /usr/lib/libGL.so
The gui Qt module is included by default. If you don't want to use it in a project (e.g., it is a library or only uses stdio), you need to specify that in the .pro file.
QT -= gui
And the linker won't attempt to find lGL regardless of whether it is installed.
My case is admittedly a bit odd, since the main reason to use Qt is to create gui's. Installing the GL library is certainly not difficult, I just wanted to know why my quick and dirty Hello World wanted it.
write:
yum provides */libGL.so
after providing:
yum install mesa-libGL-devel mesa-libGLU-devel
This worked for me:
sudo ln -s /usr/lib/libEGL1.so /usr/lib/libGL.so
My system is Ubuntu 16.04 on x86 computer(with NVIDIA GeForce GPU).
Check the library files located in /usr/lib/x86_64-linux-gnu
ls -al /usr/lib/x86_64-linux-gnu/libG*
If you see the broken link, reinstall libgl1-mesa-glx
sudo apt install --reinstall libgl1-mesa-glx
And, recheck library.
In my case: I have installed QT 32 bit lib in Win10 64 bit and it ran into error, I change to all 64 bit and QT creator run smoothly.
Solved this problem just a minute ago in suse.
Just do the following step below and QTCreator should works just fine.
sudo zypper install --type pattern devel_basis

installing SDL on fedora

I installed FEDORA and SDL and wish to program graphics in C. on compilation, I am getting lot of undefined references to SDL_MapRGB, SDL_Init etc
I searched the file system SDL.dll is missing..
how to solve this problem?
Linux does not use .dll files for storing libraries, but .so.
Anyhow, to install SDL in fedora:
sudo yum install SDL*
This will install the complete SDL library with associated devel packages.
You will also probably want to install the Development Tools group of packages (for gcc and other build tools):
sudo yum groupinstall 'Development Tools'
When compiling, you will need to tell GCC which library to link:
gcc mycoolapp.c -o myapp -lSDL -lSDL_mixer