Q:

use qgis api in qtcreator

i have a college project that searches content in map. I did  all instruction written in this site:
http://kartoza.com/how-to-build-and-debug-qgis-with-qtcreator
then built my sample project.
this is my .pro file:
QT+= core gui xml

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = test
TEMPLATE =lib

SOURCES += main.cpp\
    mainwindow.cpp

HEADERS  += mainwindow.h

FORMS    += mainwindow.ui

INCLUDEPATH +=/home/amin/Documents/qgis/QGIS-master/src/core
INCLUDEPATH +=/home/amin/Documents/qgis/QGIS-master/src/core/symbology-ng
INCLUDEPATH +=/home/amin/Documents/qgis/QGIS-master/src/gui

DEFINES += GUI_EXPORT= CORE_EXPORT=

and this here is my source file:
QgsApplication app(argc, argv,true);

 QString myPluginsDir        = "/home/timlinux/apps/lib/qgis";
 QString myLayerPath         = "/home/timlinux/gisdata/brazil/BR_Cidades/";
 QString myLayerBaseName     = "Brasil_Cap";
 QString myProviderName      = "ogr";
 // Instantiate Provider Registry
 QgsProviderRegistry::instance(myPluginsDir);
 // create a maplayer instance
 QgsVectorLayer * mypLayer =new QgsVectorLayer(myLayerPath, myLayerBaseName,       myProviderName);
 QgsSymbolV2 * x= QgsSymbolV2::defaultSymbol(mypLayer->geometryType());
 QgsSingleSymbolRendererV2 *mypRenderer = new QgsSingleSymbolRendererV2(x);
 QList <QgsMapCanvasLayer> myLayerSet;
 mypLayer->setRendererV2(mypRenderer);
 if (mypLayer->isValid())
 {
    qDebug("Layer is valid");
 }
 else
 {
   qDebug("Layer is NOT valid");
 }

  // Add the Vector Layer to the Layer Registry
 QgsMapLayerRegistry::instance()->addMapLayer(mypLayer, TRUE);
 // Add the Layer to the Layer Set
 myLayerSet.append(QgsMapCanvasLayer(mypLayer, TRUE));

// Create the Map Canvas
QgsMapCanvas * mypMapCanvas = new QgsMapCanvas(0, 0);
mypMapCanvas->setExtent(mypLayer->extent());
mypMapCanvas->enableAntiAliasing(true);
mypMapCanvas->setCanvasColor(QColor(255, 255, 255));
mypMapCanvas->freeze(false);
// Set the Map Canvas Layer Set
mypMapCanvas->setLayerSet(myLayerSet);
mypMapCanvas->setVisible(true);
mypMapCanvas->refresh();

// Start the Application Event Loop
return app.exec();

it built successfully!
I solved all the built issue,but I dont know how to run it and set the run environment run path?

A:

try change TEMPLATE =lib in .pro with TEMPLATE = app

