title: How to get the CImg library working for Qt
body: <p>I'm currently learning how to use Qt. I want to try out some simple image processing applications using Qt, and since I'm already familiar with CImg I want to use that. I guess it should be possible to do so, if not mark my question for deletion or something.</p>
  
  <p>My question is: how to get <em>CImg</em> working for Qt? <em>CImg</em> is a header file. Lets say its located on my desktop. I import it using Qt creator 4.1.0, by using the "add existing file..." in the rightclick menu on the header folder. Then my menu looks like this: </p>
  
  <p><a href="https://i.stack.imgur.com/zP8wK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zP8wK.png" alt="my project folder in qt"></a>.</p>
  
  <p>It compiles when I add <code>#include "CImg.h"</code>, but I can't use it, even when I'm trying to type <code>using namespace cimg_library</code> it will tell me that cimg_library doesn't exist. I also tried just creating a header file and copying the content of the <em>CImg.h</em> into it but then it simply fails to compile and the Qt Creator freezes.</p>
  
  <p>Edit: I managed to make the situation a bit better by adding the header location to the include code (like this: <code>#include "C:/Users/Marci/Desktop/CImg.h"</code> )I can now "see" CImg related stuff in the dev environment, and it won't bother me with not finding the constructor for CImg or anything like that. However when I try to compile while using anything CImg related it will give me around 20 linker errors. (Error code: LNK2019) My .pro file looks like this: </p>
  
  <pre><code>#-------------------------------------------------
  #
  # Project created by QtCreator 2016-11-08T17:08:58
  #
  #-------------------------------------------------
  
   QT       += core gui
  
   greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
  
   TARGET = grayscale
   TEMPLATE = app
  
  
  SOURCES += main.cpp\
           mainwindow.cpp
  
  HEADERS  += mainwindow.h \
               C:/Users/Marci/Desktop/CImg.h
  
  LIBS += -C:/Users/Marci/Desktop/ -CImg.h
  
  FORMS    += mainwindow.ui
  </code></pre>
  
  <p>Edit2: after implementing the changes that PeterT suggested in his comment my .pro file looks like this:</p>
  
  <pre><code>#-------------------------------------------------
  #
  # Project created by QtCreator 2016-11-08T17:08:58
  #
  #-------------------------------------------------
  
  QT       += core gui
  
  greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
  
  TARGET = grayscale
  TEMPLATE = app
  
  
  SOURCES += main.cpp\
           mainwindow.cpp
  
  HEADERS  += mainwindow.h \
  
  
  INCLUDEPATH += C:/Users/Marci/Desktop
  
  FORMS    += mainwindow.ui
  </code></pre>
  
  <p>And my mainwindow.cpp (in which i'm trying to create a CImg object) looks like this: </p>
  
  <pre><code>#include "mainwindow.h"
  #include "ui_mainwindow.h"
  #include &lt;CImg.h&gt;
  
  using namespace cimg_library;
  
  
  MainWindow::MainWindow(QWidget *parent) :
      QMainWindow(parent),
      ui(new Ui::MainWindow)
  {
      ui-&gt;setupUi(this);
  
      CImg&lt;unsigned char&gt; myimage(100,200);
  }
  
  MainWindow::~MainWindow()
  {
      delete ui;
  }
  </code></pre>
  
  <p>The compiler errors i get are: error: C2871: 'cimg_library': a namespace with this name does not exist
  error: C2065: 'CImg': undeclared identifier
  error: C2062: type 'unsigned char' unexpected</p>
  
  <p>I hope this is specific enough.</p>