Thursday, July 23, 2020

how to install oracle instant client and sqlplus on CentOS in VM machine

Download ZIP files :-
from here : Oracle RPMs for linux

You have to download following ZIP files :- (I installed for 64 bit). There are two ways to install instantclient :- first by zip files and second by  rpms.
by zip :-
download following   zips :-

    instantclient-basic-linux.x64-11.2.0.4.0.zip
    instantclient-jdbc-linux.x64-11.2.0.4.0.zip
    instantclient-odbc-linux.x64-11.2.0.4.0.zip
    instantclient-sdk-linux.x64-11.2.0.4.0.zip
    instantclient-sqlplus-linux.x64-11.2.0.4.0.zip
    instantclient-tools-linux.x64-11.2.0.4.0.zip

unzip in folder /opt/oracle
then

 Download all files in a folder ( I've downloaded here : /opt/software/)  , Then UNZIP all files :- like this

    # unzip instantclient-basic-linux.x64-11.2.0.4.0.zip

    # unzip instantclient-jdbc-linux.x64-11.2.0.4.0.zip

    # unzip instantclient-odbc-linux.x64-11.2.0.4.0.zip
    # unzip instantclient-sdk-linux.x64-11.2.0.4.0.zip
    # unzip instantclient-sqlplus-linux.x64-11.2.0.4.0.zip
    # unzip instantclient-tools-linux.x64-11.2.0.4.0.zip


and place that unzipped directory(instantclient_11_2) to  (as I saved in)" /opt/oracle/instantclient_11_2"

open gedit as root user and open file "/etc/profile". Add following lines at the end of file :

    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/oracle/instantclient_11_2

    export PATH=$PATH:/opt/oracle/instantclient_11_2

    export TNS_ADMIN=/opt/oracle/instantclient_11_2/network/admin

    export ORACLE_HOME=/opt/oracle/instantclient_11_2

    export CLASSPATH=$CLASSPATH:/opt/oracle/instantclient_11_2

    export JAVA_HOME=/usr/java/jdk1.8.0_211-amd64
 

Here must installed jdk1.8 at least may be by rpm. You may download it via it's website.

save and close profile file.
remember that java version should   be java 8.
Now open Text editor as root and create following file :-

 named tnsnames.ora and add following lines :-
-----------------------------------------------
    ora11gr2 =
       (DESCRIPTION =
          (ADDRESS_LIST =
             (ADDRESS = (PROTOCOL = TCP)(HOST = oel11gr2.oraclehomenet.com)(PORT = 1521))
          )
          (CONNECT_DATA =
             (SERVICE_NAME = ora11gr2)
          )
       )
-------------------------------------------------

Alias for  database name :-

<alias> =

     (DESCRIPTION =
        (ADDRESS = (PROTOCOL = TCP)(HOST = <ip>)(PORT = <port>))
            (CONNECT_DATA =
              (SERVER = DEDICATED)
                  (SERVICE_NAME = <dbname>)
    )
  )

-------------------------------------------------
Because this file is created manually so you need to consider these things :

    ora11gr2 is name of SID which is alias to  Global Database Name and may be same as in server side file.
    oel11gr2.oraclehomenet.com which is fully qualified domain name of host named oel11gr2 ( here I gave oel for oracle enterprise linux ) where oracle database server is installed.
    save this tnsnames.ora file to "/opt/oracle/instantclient_11_2/network/admin"

sqlnet.ora file:-


    # sqlnet.ora Network Configuration File: /opt/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/sqlnet.ora
    # Generated by Oracle configuration tools.
----------------------------------------------------------------------
    NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)

    ADR_BASE = /opt/oracle/instantclient_11_2
----------------------------------------------------------------------
listner.ora file :-

    # listener.ora Network Configuration File: /opt/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
    # Generated by Oracle configuration tools.
---------------------------------------------------------------------
    LISTENER =
      (DESCRIPTION_LIST =
        (DESCRIPTION =
          (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
          (ADDRESS = (PROTOCOL = TCP)(HOST = server1.db.net)(PORT = 1521))
        )
      )

    ADR_BASE_LISTENER = /opt/oracle/instantclient_11_2/network/admin
------------------------------------------------------------------
put all these 3 files in /opt/oracle/instantclient_11_2/network/admin


You may copy these three files from database server from path

"/opt/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/"

and paste here in " /opt/oracle/instantclient_11_2/network/admin/" and modify some parts of files.

if there is no "network/admin/" directory then create them in /opt/oracle/instantclient_11_2/
now  open terminal and give following command to get sql prompt :-

     $ sqlplus scott@ora11gr2

    Password : <Enter password for oracle database user scott and press enter>
    SQL>

Done.

if sqlplus is not working, it may be because of permissions. To set it, set permission of sqlplus and files do this :-

# chmod -R 777 /opt/oracle 

or

# chmod -R 775 /opt/oracle 

where "/opt/oracle" is parent directory of "instantclient_11_2". And here give all permissions to all or for user and group. Add users in this group to protect from others.

To set default editor in sqlplus do this :-

place this file named "login.sql" in location :

 "/opt/oracle/instantclient_11_2/network/sqlplus/admin"

if it is not present, then create it with path.

 and set this path to "SQLPATH" enviornment variabe in "/etc/profile" along with other environment variables. As :

export SQLPATH=/opt/oracle/instantclient_11_2/network/sqlplus/admin

if there is no such directory in that path then create it as given above with path.
 

create and name the file as "login.sql" in above path of directory and its content should be :

 "define _editor=gedit" 

OR 

define _editor=/usr/bin/vim

# of course without quotes,  note :- there is space between "define" and "_editor" and not in both side of "=" .

command to get editor in sqlplus is :-

SQL> ed file1.sql

or

SQL> ed file1

execute as :-

SQL> @ file1 "press Enter Here"

or

SQL> @ file1.sql "press Enter here"

or with path to sql file as :-

SQL>ed /opt/sql-scripts/a

SQL>@/opt/sql-scripts/a

and now here is your output.

if  oracle sqlplus doesn't connect then open firewall settings and add user defined  ports : 1158 & 1521 both in oracle server and oracle instant client PC and as with permanent option choosen.

as follows :

how to connect mysql and Qt and building QMSQL driver & make them loaded.

how to connect mysql and Qt and building QMSQL driver & make them loaded.

 hello all of you.

first install Qt( i installed in location /opt/Qt and choose "select all" ). now install mysql as folllows:-
1.  download mysql from official website. ( search "indexof mysql " in google).
2. install all rpms, you may be use systems configured as in client server model and so Qt must be in MySQL client.
3. run this command :- ( I am doing this in centos 6.6 VM)
    # service mysql start <--| (press enter) ( this is required for insertting  password for root)
4. then open file from location  given in "/root/.mysql_secret" file in root user folder.
that file contains password for root user of mysql database.
4.  set database as given step by step.
5. install mysql workbench.
6. make some users - database - tables - insert rows.
now this setups mysql server.

on client install all mysql rpms except mysql-server.xx.xx.rpm

7. now install in client mysql workbench (same as in server).
8. get connected in user  say "rahul" and password "rahul" host "oracle"

# mysql -u rahul -h oracle -p <--|
# password : <--| enter password for user rahul.
mysql >
if you get this prompt then you are successfully setuped client and server mysql.

now after installing Qt in  "/opt/Qt"
give this command for compilling  mysql plugin from qt source code:-
1. # cd /opt/Qt/5.3/Src/qtbase/src/plugins/sqldrivers/mysql <--|
2. # /opt/Qt/5.3/gcc_64/bin/qmake "INCLUDEPATH+=/usr/include" "LIBS+=-L/usr/lib64/mysql -lrt -ldl -lmysqlclient_r -lz -lcrypt -lnsl -lm -lssl -lcrypto" mysql.pro

3 # make
4. # make install
this will install plugin in appropriate location.
then check that plugin in following code :-
----------------------------------------------------
#include <QCoreApplication>
#include <QtSql>
#include <QtDebug>
#include <QSqlDatabase>

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
    db.setHostName("oracle");
    db.setDatabaseName("music");
    //db.setPort(3306);
    db.setUserName("rahul");
    db.setPassword("rahul");
    if(db.open())
        qDebug() << " database connection open";
    else
        qDebug() << "cannot open database";



    return a.exec();
}

----------------------------------------------------
be sure add  "sql" tag in " project_file_name.pro" file as :-
QT +=  core sql
-----------------------------------------------------


How to use occi to connect C++ with oracle 11gR2.

 ( I assume you have already installed oracle 11g R2 server in on VM and in second VM oracle instant client 11gr2 and sever's  sid is "orcl" and in client you are using codeblocks  17.12 for C++ editor. You must be able to issue sqlplus command in instant client side successfully )

    #include <iostream>
    #include <occi.h>
    #include <iomanip>
    using namespace oracle::occi;
    using namespace std;
    int main()
    {
        const string user="rahul", passwd = "rahul", connstring = "orcl";
        Environment *env =  Environment::createEnvironment();
        Connection *conn = env->createConnection(user, passwd, connstring);
        string strstmt = "select *from emp";
        Statement *stmt = conn->createStatement(strstmt);

        ResultSet *rs = stmt->executeQuery();

while(rs->next())
    {
        cout << setw(4) << rs->getInt(1) << "\t" << setw(6) << rs->getString(2) << "\t"
         << setw(9) << rs->getString(3) << "\t" << setw(4) << rs->getInt(4) << "\t"
         << setw(9) << rs->getString(5) << "\t" << setw(4) << rs->getInt(6) << "\t"
         << setw(4) << rs->getInt(7) << "\t" << setw(5) << rs->getInt(8)<< endl;

    }
        stmt->closeResultSet(rs);
        conn->terminateStatement(stmt);
        env->terminateConnection(conn);
        Environment::terminateEnvironment(env);
        return 0;
    }


now to compile do following :-
-------------------------------------
include clntsh, occi, nnz11 in  :- projects->build options->linkersettings->link libraries->clntsh , occi, nnz11


projects->build options->linker settings->search directories ->compiler-> {path to include dir for oracle} as I given -> /opt/oracle/instantclient_11_2/sdk/include

then :-
then in linker -> /opt/oracle/instantclient_11_2  this is  for library



now build your project  and output should be :-


building shared object file( .so) in C for singly linked list data stucture for as in linux and calling this in to project.


this is my post on data structure :- singly linked list :-

first we create shared library file:-
-------------------------------------

in code blocks file-> new -> projects -> shared library -> select c or c++ (I chosen c)


then give full of your project path where you want to crearte shared lib file.

give project title :- this will be your final shared lilbrary file name.remove main.c  from project.

file -> new -> file -> c/c++ header file -> give file name with full path.

open file in text editor. and type following code :-
------------------------------------------------------------

    #ifndef SINGLYLL_H_INCLUDED
    #define SINGLYLL_H_INCLUDED

    struct node
    {
        int data;
        struct node * link;
    };

     struct node *start, *p;
     int count;
     void display( struct node * start);
     void search( struct node *start, int data);
     struct node * addatbegin( struct node *start, int data);
     struct node * addatend( struct node*start, int data);
     struct node * addafter( struct node * start, int data, int item);
     struct node * addbefore( struct node * start, int data, int item);
     struct node * createlist( struct node * start, int n);
     struct node * del( struct node* start, int data);
     struct node * reverse( struct node *start);

    #endif // SINGLYLL_H_INCLUDED

 then file-> new -> file -> c/c++ source file -> select c -> full path and name of source file.
( Be sure to check mark in Debug and Release )

(i chosen singlyllc.c)

open source file in text editor. and type following code :-

    #include "singlyll.h"
    #include <stdio.h>
    #include <stdlib.h>

    void display(struct node* start)
    {
        if(start == NULL)
        {
            printf("list is empty\n");

            return;
        }

        printf("List : ");

        count = 0;

        for(p = start; p != NULL; p = p->link)
        {
            printf("%d \t", p->data);
            count++;

        }
        printf("\n\n");
    }

    void search(struct node* start, int item)
    {
        struct node* p = start;

        int pos = 1;

        for(;p != NULL; p = p->link)
        {
            if(p->data == item )
            {
                printf( "item %d found at position %d \n", item, pos);
                return;
            }
            pos++;
        }

        printf("item %d not found in list\n", item);
    }

    struct node* addatbegin( struct node* start, int item)
    {
        struct node *temp  = (struct node*) malloc(sizeof(struct node));

        temp->data = item;
        temp->link = start;

        start = temp;

        count++;
        return start;

    }

    struct node* addatend(struct node* start, int item)
    {
        struct node* p = start, *temp;

        temp = (struct node*) malloc(sizeof(struct node));
        temp->link = NULL;
        temp->data = item;

        while(p->link!= NULL)
         {
            p = p->link;
         }

        p->link  = temp;

        count++;
        return start;
    }

    struct node* addafter(struct node* start,int data, int item)
    {
        p = start;
        struct node *temp;

        while( p != NULL)
        {
            printf("p->data = %d\n",p->data );
            if(p->data == item)
            {
                temp = (struct node*) malloc(sizeof(struct node));
                temp->data = data;
                temp->link = p->link;
                p->link = temp;

                count++;
                return start;
            }

            p = p->link;
        }

        printf(" not present in the list\n");
        return start;
    }

    struct node* addbefore(struct node* start, int data, int item)
    {
        struct node*temp;

        if(start == NULL)
        {
            printf("list is empty\n");
            return start;
        }

        //insert before the first struct node

        if(item == start->data)
        {
            temp = (struct node*) malloc(sizeof(struct node));
            temp->data = data;
            temp->link = start;
            start = temp;
            count++;

        }

         p = start;

         while(p->link != NULL)
         {
             if(p->link->data == item)
             {
                temp = (struct node*)malloc(sizeof(struct node));
                temp->data = data;

                temp->link = p->link;

                p->link = temp;

                count++;
                return start;
             }

             p = p->link;
         }


         printf("%d not present in the list\n", item);
         return start;
    }

     struct node* createlist(struct node* start, int n)
     {
        int i, data;
        count = 0;
        start = NULL;

        if( n == 0)
        {
            return start;
        }

        printf("Element to be inserted : ");
        scanf("%d", &data);

        start = addatbegin(start, data);

        for( i = 2; i <= n; i++ )
        {
            printf("Element to be inserted : ");
            scanf("%d",&data);

            start = addatend(start, data);
        }

        return start;
     }
    struct node* del(struct node* start, int data)
    {
        struct node*p, *temp;

        if(start == NULL)
        {
            printf("The list is empty \n");
            count  = 0;
            return start;
        }

        if(start->data == data)
        {
            temp= start;
            start = start->link;
            free(temp);
            count--;
            return start;
        }

        p = start;

        while(p->link != NULL)
        {
            if( p->link->data == data)
            {
                temp = p->link;
                p->link = temp->link;
                free(temp);

                count--;
                return start;
            }
            p = p->link;
        }

        printf("Element %d not found\n", data);

        return start;
    }

    struct node* reverse(struct node* start)
    {
        struct node*prev, *ptr, *next;


        prev = NULL;
        ptr = start;

        while(ptr != NULL)
        {
            next = ptr->link;
            ptr->link = prev;
            prev = ptr;
            ptr = next;
        }

        start = prev;

        return start;
    }

if header file singlyll.h is not in intellisense, then reparse project.

now go to project -> build options -> in compiler flags check mark on :-


then go to project -> properties -> buld targets -> left pan -> select release -> rename from liblibfilename.so to  libfilename.so and from Debug also.


 then  compile project.
this will produce "libsinglyll_c.so" (in my case ). now this is our shared lib file.
Note to add ".so" file in include directive, add path of ".so" file in LD_LIBRARY_PATH environment variable in file "/etc/profile" for global recognition of all users in that OS or in home directory file"~/.bashrc" or "~/.bash_profile" for only in current user or in "/usr/lib64/" system directory for all applications.
--------------------------------------------------------------------

Now open file -> new -> project -> console project -> select C -> give project name and full path of your project. ( image 8.png, image 9.png) -> next -> finish.

give this project name :- linklist

now in main.c type following code :-
------------------------------------

    #include <stdio.h>
    #include <stdlib.h>
    #include <singlyll.h>

    int main()
    {

        start = p = NULL;

        int choice = 0, data, item, n;

        while(1)
        {
          printf("1.  Create List\n"
                 "2.  Display List\n"
                 "3.  Count\n"
                 "4.  Search in List\n"
                 "5.  Add at beginning / Add at empty List\n"
                 "6.  Add at end of List\n"
                 "7.  Add after node in List \n"
                 "8.  Add before node in List\n"
                 "9.  Delete  in List\n"
                 "10. Reverse Linked List\n"
                 "11. Quit\n");

          printf("Enter your choice : ");
          scanf("%d",&choice);

            switch(choice)
            {
            case 1: printf("Enter number of nodes : ");
                    scanf("%d", &n);
                    start = createlist(start, n);
                    break;

            case 2: display(start);
                    break;

            case 3: printf("\n number of nodes are : %d\n", count);
                    break;

            case 4: printf("Enter element to be searched : ");
                    scanf("%d", &data);
                    search( start, data);
                    break;

            case 5: printf("Enter element to be inserted : ");
                    scanf("%d", &data);
                    start = addatbegin(start, data);
                    break;

            case 6: printf("Enter element to be inserted : ");
                    scanf("%d", &data);
                    start = addatend(start, data);
                    break;

            case 7: printf("Enter element to be inserted : ");
                    scanf("%d", &data);
                    printf("Enter element after which to be inserted : ");
                    scanf("%d", &item);

                    start = addafter( start, data, item);
                    break;

            case 8: printf("Enter element to be inserted : ");
                    scanf("%d", &data);
                    printf("Enter element before which to be inserted : ");
                    scanf("%d", &item);

                    start = addbefore(start, data, item);
                    break;

            case 9: printf("Enter element to be deleted : ");
                    scanf("%d", &item);
                    start = del(start, item);
                    break;

            case 10: start = reverse(start);
                    break;

            case 11: exit(0);

            default : printf("\nWrong choice\n");

            }

       }

        return 0;
    }


     Now goto project -> build options -> Left pane -> Release and in right pane -> linker settings ->
    add following path ( path of your shared lib file "libsinglyll_c.so" ) :-
    "/opt/projects/code blocks/C/data structures/shared lib files/singlyll_c/bin/Release/libsinglyll_c.so" or you may copy libsinglyll_c.so file to /usr/lib/ for universal use ( that means for all ).

then in search directories (header file path)->
"/opt/projects/code blocks/C/data structures/shared lib files/singlyll_c" or copy in
/usr/include/ for  universal use.
then compile your project.

this will create executable file. then run this in terminal.
--------------------------------------------------------------
FINISHED your project.


Dual boot menu windows 10 & CentOS 7 linux

 infile :-write a file "windows10"
as follows :-

     #!/bin/sh -e
    echo "Adding Windows" >&2
    cat << EOF

    menuentry "Windows 10"
    {
      set root=(hd0,1)
      chainloader +1
    }

    EOF

change permission and copy this file to : -

    # chmod +x windows10

    # cp window10 /etc/grub.d/.


then give command   :-                                  

    # grub2-mkconfig  --output=/boot/grub2/grug.cfg

there will errors. Don't warry. this  will generate file :-

    /boot/grub2/grub.cfg.new


and having folowing entry :-

in grub.cfg.new :-
--------------

    ### BEGIN /etc/grub.d/30_os-prober ###
    menuentry 'Windows 10 (loader) (on /dev/sdb1)' --class windows --class os $menuentry_id_option 'osprober-chain-2CFA4829FA47EE20' {
        insmod part_msdos
        insmod ntfs
        set root='hd0,msdos1'
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-bios=hd1,msdos1 --hint-efi=hd1,msdos1 --hint-baremetal=ahci1,msdos1 --hint='hd0,msdos1'  2CFA4829FA47EE20
        else
          search --no-floppy --fs-uuid --set=root 2CFA4829FA47EE20
        fi
        parttool ${root} hidden-
        drivemap -s (hd0) ${root}
        chainloader +1
    }
    ### END /etc/grub.d/30_os-prober ###


rename file

     # mv  gurb.cfg grub.cfg.original.backup
     #mv grub.cfg.new grub.cfg


if you want to change timeout setting  search "TIMEOUT=5" . This will be two times. On both  set timeout as you want  , i set it 30 seconds.
save and exit.
--------------------------------------
in grubenv file for default selection as "window" in grub menu :-
------------------

    # GRUB Environment Block
    #saved_entry=CentOS Linux (3.10.0-862.el7.x86_64) 7 (Core)
    saved_entry=Windows 10 (loader) (on /dev/sdb1)



how to install glassfish server without setup in centos 7.5

 i have centos 7.5 as server. I am going  to install glassfish server in centos 7.5 server. i did like this :-

    for this you have to install jdk-8u181-linux-x64.rpm then
in /etc/profile

    export JAVA_HOME=/usr/java/jdk1.8.0_20
    export PATH=$JAVA_HOME/bin:$PATH

 then run following command  and create user "glassfish":-

    # useradd -s /bin/bash -g glassfish

glassfish                                                                      

  # chown -R glassfish: /opt/glassfish4/                                                                                  

# passwd glassfish
    Changing password for user glassfish.
    New password:

create a file in "/etc/systemd/system/glassfish.service"
and write following :-

    [Unit]
    Description = Glassdfish server 4.1
    After = syslog.target network.target

    [Service]
    user=glassfish
    ExecStart = /usr/java/jdk1.8.0_20/bin/java -jar /opt/glassfish4/glassfish/lib/client/appserver-cli.jar start-domain
    ExecStop = /usr/java/jdk1.8.0_20/bin/java  -jar /opt/glassfish4/glassfish/lib/client/appserver-cli.jar stop-domain
    ExecReload = /usr/java/jdk1.8.0_20/bin/java  -jar /opt/glassfish4/glassfish/lib/client/appserver-cli.jar restart-domain

    Type = forking

    [Install]
    WantedBy = multi-user.target


    now run commands :-

        # systemctl start glassfish.service
        # systemctl status glassfish.service

        it should show following output :-

        [glassfish@serverglassfish ~]$ systemctl status glassfish
        ● glassfish.service - Glassdfish server 4.1
           Loaded: loaded (/etc/systemd/system/glassfish.service; enabled; vendor preset: disabled)
           Active: active (running) since Thu 2019-07-25 13:03:22 IST; 18s ago
          Process: 13937 ExecStart=/usr/java/jdk1.8.0_20/bin/java -jar /opt/glassfish4/glassfish/lib/client/appserver-cli.jar start-domain (code=exited, status=0/SUCCESS)
         Main PID: 13956 (java)
            Tasks: 88
           CGroup: /system.slice/glassfish.service
                   └─13956 /usr/java/jdk1.8.0_20/bin/java -cp /opt/glassfish4/glassfi...

        now enable glassfish server :-

        # systemctl enable glassfish

 run in web browser :-

    localhost:8080

this will show

    Your server is now running

 now to go in admin mode :-

    localhost:4848



Wednesday, July 22, 2020

fixing error :- /usr/bin/ld: cannot find -lGL in Qt


after installing of Qt5.7 and building a simple "hello word" gui project  if you encounter following error :-

    20:38:00: Running steps for project untitled...
    20:38:00: Starting: "/opt/Qt/5.7/gcc_64/bin/qmake" /opt/project/qt/untitled/untitled.pro -r -spec linux-g++ CONFIG+=debug CONFIG+=qml_debug
    Info: creating stash file /opt/project/qt/build-untitled-Desktop_Qt_5_7_0_GCC_64bit-Debug/.qmake.stash
    20:38:00: The process "/opt/Qt/5.7/gcc_64/bin/qmake" exited normally.
    20:38:00: Starting: "/usr/bin/make"
    /opt/Qt/5.7/gcc_64/bin/uic ../untitled/mainwindow.ui -o ui_mainwindow.h
    g++ -c -pipe -g -std=gnu++11 -Wall -W -D_REENTRANT -fPIC -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../untitled -I. -I../../../Qt/5.7/gcc_64/include -I../../../Qt/5.7/gcc_64/include/QtWidgets -I../../../Qt/5.7/gcc_64/include/QtGui -I../../../Qt/5.7/gcc_64/include/QtCore -I. -I. -I../../../Qt/5.7/gcc_64/mkspecs/linux-g++ -o main.o ../untitled/main.cpp
    g++ -c -pipe -g -std=gnu++11 -Wall -W -D_REENTRANT -fPIC -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../untitled -I. -I../../../Qt/5.7/gcc_64/include -I../../../Qt/5.7/gcc_64/include/QtWidgets -I../../../Qt/5.7/gcc_64/include/QtGui -I../../../Qt/5.7/gcc_64/include/QtCore -I. -I. -I../../../Qt/5.7/gcc_64/mkspecs/linux-g++ -o mainwindow.o ../untitled/mainwindow.cpp
    /opt/Qt/5.7/gcc_64/bin/moc -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I/opt/Qt/5.7/gcc_64/mkspecs/linux-g++ -I/opt/project/qt/untitled -I/opt/Qt/5.7/gcc_64/include -I/opt/Qt/5.7/gcc_64/include/QtWidgets -I/opt/Qt/5.7/gcc_64/include/QtGui -I/opt/Qt/5.7/gcc_64/include/QtCore -I. -I/usr/include/c++/4.8.5 -I/usr/include/c++/4.8.5/x86_64-redhat-linux -I/usr/include/c++/4.8.5/backward -I/usr/lib/gcc/x86_64-redhat-linux/4.8.5/include -I/usr/local/include -I/usr/include ../untitled/mainwindow.h -o moc_mainwindow.cpp
    g++ -c -pipe -g -std=gnu++11 -Wall -W -D_REENTRANT -fPIC -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../untitled -I. -I../../../Qt/5.7/gcc_64/include -I../../../Qt/5.7/gcc_64/include/QtWidgets -I../../../Qt/5.7/gcc_64/include/QtGui -I../../../Qt/5.7/gcc_64/include/QtCore -I. -I. -I../../../Qt/5.7/gcc_64/mkspecs/linux-g++ -o moc_mainwindow.o moc_mainwindow.cpp
    g++ -Wl,-rpath,/opt/Qt/5.7/gcc_64/lib -o untitled main.o mainwindow.o moc_mainwindow.o   -L/opt/Qt/5.7/gcc_64/lib -lQt5Widgets -L/usr/lib64 -lQt5Gui -lQt5Core -lGL -lpthread
    /usr/bin/ld: cannot find -lGL
    collect2: error: ld returned 1 exit status
    make: *** [untitled] Error 1
    20:38:02: The process "/usr/bin/make" exited with code 2.
    Error while building/deploying project untitled (kit: Desktop Qt 5.7.0 GCC 64bit)
    When executing step "Make"
    20:38:02: Elapsed time: 00:02.


then
for this you need to install following rpms :-

    expat-2.1.0-10.el7_3.i686.rpm
    expat-2.1.0-10.el7_3.x86_64.rpm
    expat-devel-2.1.0-10.el7_3.i686.rpm
    expat-devel-2.1.0-10.el7_3.x86_64.rpm
    expat-static-2.1.0-10.el7_3.i686.rpm
    expat-static-2.1.0-10.el7_3.x86_64.rpm
    gl-manpages-1.1-7.20130122.el7.noarch.rpm
    libdrm-2.4.83-2.el7.i686.rpm
    libdrm-2.4.83-2.el7.x86_64.rpm
    libdrm-devel-2.4.83-2.el7.i686.rpm
    libdrm-devel-2.4.83-2.el7.x86_64.rpm
    libglvnd-1.0.1-0.8.git5baa1e5.el7.i686.rpm
    libglvnd-glx-1.0.1-0.8.git5baa1e5.el7.i686.rpm
    libpciaccess-0.14-1.el7.i686.rpm
    libpciaccess-0.14-1.el7.x86_64.rpm
    libpciaccess-devel-0.14-1.el7.i686.rpm
    libpciaccess-devel-0.14-1.el7.x86_64.rpm
    libselinux-2.5-12.el7.i686.rpm
    libselinux-2.5-12.el7.x86_64.rpm
    libsepol-2.5-8.1.el7.i686.rpm
    libsepol-2.5-8.1.el7.x86_64.rpm
    libsepol-devel-2.5-8.1.el7.i686.rpm
    libsepol-devel-2.5-8.1.el7.x86_64.rpm
    libX11-1.6.5-1.el7.i686.rpm
    libX11-1.6.5-1.el7.x86_64.rpm
    libX11-common-1.6.5-1.el7.noarch.rpm
    libX11-devel-1.6.5-1.el7.i686.rpm
    libX11-devel-1.6.5-1.el7.x86_64.rpm
    libXau-1.0.8-2.1.el7.i686.rpm
    libXau-1.0.8-2.1.el7.x86_64.rpm
    libXau-devel-1.0.8-2.1.el7.i686.rpm
    libXau-devel-1.0.8-2.1.el7.x86_64.rpm
    libxcb-1.12-1.el7.i686.rpm
    libxcb-1.12-1.el7.x86_64.rpm
    libxcb-devel-1.12-1.el7.i686.rpm
    libxcb-devel-1.12-1.el7.x86_64.rpm
    libXdamage-1.1.4-4.1.el7.i686.rpm
    libXdamage-1.1.4-4.1.el7.x86_64.rpm
    libXdamage-devel-1.1.4-4.1.el7.i686.rpm
    libXdamage-devel-1.1.4-4.1.el7.x86_64.rpm
    libXext-1.3.3-3.el7.i686.rpm
    libXext-1.3.3-3.el7.x86_64.rpm
    libXext-devel-1.3.3-3.el7.i686.rpm
    libXext-devel-1.3.3-3.el7.x86_64.rpm
    libXfixes-5.0.3-1.el7.i686.rpm
    libXfixes-5.0.3-1.el7.x86_64.rpm
    libXfixes-devel-5.0.3-1.el7.i686.rpm
    libXfixes-devel-5.0.3-1.el7.x86_64.rpm
    libxshmfence-1.2-1.el7.i686.rpm
    libxshmfence-1.2-1.el7.x86_64.rpm
    libxshmfence-devel-1.2-1.el7.i686.rpm
    libxshmfence-devel-1.2-1.el7.x86_64.rpm
    libXxf86vm-1.1.4-1.el7.i686.rpm
    libXxf86vm-1.1.4-1.el7.x86_64.rpm
    libXxf86vm-devel-1.1.4-1.el7.i686.rpm
    libXxf86vm-devel-1.1.4-1.el7.x86_64.rpm
    mesa-libGL-18.0.5-3.el7.i686.rpm
    mesa-libglapi-18.0.5-3.el7.i686.rpm
    mesa-libglapi-18.0.5-3.el7.x86_64.rpm
    mesa-libGL-devel-17.2.3-8.20171019.el7.i686.rpm
    mesa-libGL-devel-17.2.3-8.20171019.el7.x86_64.rpm
    mesa-libGLU-9.0.0-4.el7.i686.rpm
    mesa-libGLU-9.0.0-4.el7.x86_64.rpm
    mesa-libGLU-devel-9.0.0-4.el7.i686.rpm
    mesa-libGLU-devel-9.0.0-4.el7.x86_64.rpm
    pcre2-10.23-2.el7.i686.rpm
    pcre2-10.23-2.el7.x86_64.rpm
    pcre2-devel-10.23-2.el7.i686.rpm
    pcre2-devel-10.23-2.el7.x86_64.rpm
    pcre2-utf16-10.23-2.el7.i686.rpm
    pcre2-utf16-10.23-2.el7.x86_64.rpm
    pcre2-utf32-10.23-2.el7.i686.rpm
    pcre2-utf32-10.23-2.el7.x86_64.rpm
    pcre-8.32-17.el7.i686.rpm
    pcre-8.32-17.el7.x86_64.rpm
    pcre-devel-8.32-17.el7.i686.rpm



don't warry all of these will be found in centos7.5 everything dvd.
then compile again and run . you will get running program.

error /usr/bin/ld: cannot find -lssl /usr/bin/ld: cannot find -lcrypto when installing mysql qt plugin.

when installing myql sqldriver plugin if you found following error :-

    /usr/bin/ld: cannot find -lssl
    /usr/bin/ld: cannot find -lcrypto
    collect2: error: ld returned 1 exit status
    make: *** [../../../../plugins/sqldrivers/libqsqlmysql.so] Error 1

install following rpms :-
(all will be found in centos75 everything)

    audit-libs-2.8.4-4.el7.i686.rpm
    bzlib-1.0.6-alt6.i586.rpm
    cracklib-2.9.0-11.el7.i686.rpm
    crypto-utils-2.4.1-42.el7.x86_64.rpm
    cryptsetup-libs-2.0.3-3.el7.x86_64.rpm
    cyrus-sasl-2.1.26-23.el7.i686.rpm
    cyrus-sasl-2.1.26-23.el7.x86_64.rpm
    cyrus-sasl-devel-2.1.26-23.el7.i686.rpm
    cyrus-sasl-devel-2.1.26-23.el7.x86_64.rpm
    cyrus-sasl-lib-2.1.26-23.el7.i686.rpm
    cyrus-sasl-lib-2.1.26-23.el7.x86_64.rpm
    daxctl-libs-62-1.el7.x86_64.rpm
    device-mapper-1.02.149-8.el7.x86_64.rpm
    device-mapper-libs-1.02.149-8.el7.i686.rpm
    elfutils-libelf-0.172-2.el7.i686.rpm
    elfutils-libs-0.172-2.el7.i686.rpm
    gamin-0.1.10-16.el7.x86_64.rpm
    glib2-2.56.1-2.el7.x86_64.rpm
    glib2-devel-2.56.1-2.el7.x86_64.rpm
    glibc-2.17-260.el7.i686.rpm
    glibc-common-2.17-260.el7.x86_64.rpm
    keyutils-libs-1.5.8-3.el7.i686.rpm
    keyutils-libs-devel-1.5.8-3.el7.x86_64.rpm
    krb5-devel-1.15.1-18.el7.i686.rpm
    krb5-devel-1.15.1-18.el7.x86_64.rpm
    krb5-devel-1.15.1-34.el7.x86_64.rpm
    krb5-libs-1.15.1-18.el7.i686.rpm
    krb5-libs-1.15.1-18.el7.x86_64.rpm
    krb5-libs-1.15.1-34.el7.x86_64.rpm
    krb5-libs-1.15.1-37.el7_6.x86_64.rpm
    libattr-2.4.46-13.el7.i686.rpm
    libblkid-2.23.2-59.el7.i686.rpm
    libcap-2.22-9.el7.i686.rpm
    libcap-ng-0.7.5-4.el7.i686.rpm
    libcom_err-1.42.9-11.el7.i686.rpm
    libcom_err-1.42.9-11.el7.x86_64.rpm
    libcom_err-1.42.9-13.el7.x86_64.rpm
    libcom_err-devel-1.42.9-11.el7.i686.rpm
    libcom_err-devel-1.42.9-11.el7.x86_64.rpm
    libcom_err-devel-1.42.9-13.el7.x86_64.rpm
    libdb-5.3.21-24.el7.i686.rpm
    libffi-3.0.13-18.el7.i686.rpm
    libgcc-4.8.5-36.el7.i686.rpm
    libgcrypt-1.5.3-14.el7.i686.rpm
    libgpg-error-1.12-3.el7.i686.rpm
    libitm-4.8.5-28.el7.i686.rpm
    libitm-4.8.5-28.el7.x86_64.rpm
    libitm-devel-4.8.5-28.el7.i686.rpm
    libitm-devel-4.8.5-28.el7.x86_64.rpm
    libitm-static-4.8.5-28.el7.i686.rpm
    libitm-static-4.8.5-28.el7.x86_64.rpm
    libkadm5-1.15.1-18.el7.i686.rpm
    libkadm5-1.15.1-18.el7.x86_64.rpm
    libkadm5-1.15.1-34.el7.x86_64.rpm
    libkadm5-1.15.1-37.el7_6.x86_64.rpm
    libmount-2.23.2-59.el7.i686.rpm
    libselinux-2.5-14.1.el7.x86_64.rpm
    libselinux-devel-2.5-14.1.el7.x86_64.rpm
    libsepol-2.5-10.el7.x86_64.rpm
    libsepol-devel-2.5-10.el7.x86_64.rpm
    libstdc++-4.8.5-36.el7.i686.rpm
    libuuid-2.23.2-59.el7.i686.rpm
    libverto-0.2.5-4.el7.i686.rpm
    libverto-devel-0.2.5-4.el7.x86_64.rpm
    lz4-1.7.5-2.el7.i686.rpm
    lz4-1.7.5-2.el7.x86_64.rpm
    lz4-devel-1.7.5-2.el7.x86_64.rpm
    ncurses-libs-5.9-14.20130511.el7_4.i686.rpm
    ndctl-libs-62-1.el7.x86_64.rpm
    nspr-4.17.0-1.el7.i686.rpm
    nspr-4.17.0-1.el7.x86_64.rpm
    nspr-4.19.0-1.el7_5.x86_64.rpm
    nspr-devel-4.17.0-1.el7.i686.rpm
    nspr-devel-4.17.0-1.el7.x86_64.rpm
    nss-3.34.0-4.el7.i686.rpm
    nss-3.34.0-4.el7.x86_64.rpm
    nss-devel-3.34.0-4.el7.i686.rpm
    nss-devel-3.34.0-4.el7.x86_64.rpm
    nss-pem-1.0.3-4.el7.i686.rpm
    nss-pem-1.0.3-4.el7.x86_64.rpm
    nss-softokn-3.34.0-2.el7.i686.rpm
    nss-softokn-devel-3.34.0-2.el7.i686.rpm
    nss-softokn-devel-3.34.0-2.el7.x86_64.rpm
    nss-softokn-freebl-3.34.0-2.el7.i686.rpm
    nss-softokn-freebl-3.34.0-2.el7.x86_64.rpm
    nss-softokn-freebl-3.36.0-5.el7_5.i686.rpm
    nss-softokn-freebl-devel-3.34.0-2.el7.i686.rpm
    nss-softokn-freebl-devel-3.34.0-2.el7.x86_64.rpm
    nss-tools-3.34.0-4.el7.x86_64.rpm
    nss-util-3.34.0-2.el7.i686.rpm
    nss-util-3.34.0-2.el7.x86_64.rpm
    nss-util-3.36.0-1.el7_5.x86_64.rpm
    nss-util-devel-3.34.0-2.el7.i686.rpm
    nss-util-devel-3.34.0-2.el7.x86_64.rpm
    opencryptoki-3.7.0-1.el7.i686.rpm
    opencryptoki-3.7.0-1.el7.x86_64.rpm
    opencryptoki-devel-3.7.0-1.el7.i686.rpm
    opencryptoki-devel-3.7.0-1.el7.x86_64.rpm
    opencryptoki-icsftok-3.7.0-1.el7.i686.rpm
    opencryptoki-icsftok-3.7.0-1.el7.x86_64.rpm
    opencryptoki-libs-3.7.0-1.el7.i686.rpm
    opencryptoki-libs-3.7.0-1.el7.x86_64.rpm
    openldap-2.4.44-13.el7.i686.rpm
    openldap-2.4.44-13.el7.x86_64.rpm
    openldap-clients-2.4.44-13.el7.x86_64.rpm
    openldap-devel-2.4.44-13.el7.i686.rpm
    openldap-devel-2.4.44-13.el7.x86_64.rpm
    openldap-servers-2.4.44-13.el7.x86_64.rpm
    openldap-servers-sql-2.4.44-13.el7.x86_64.rpm
    openssl-1.0.2k-12.el7.x86_64.rpm
    openssl-devel-1.0.2k-12.el7.i686.rpm
    openssl-devel-1.0.2k-12.el7.x86_64.rpm
    openssl-devel-1.0.2k-16.el7.x86_64.rpm
    openssl-libs-1.0.2k-12.el7.i686.rpm
    openssl-libs-1.0.2k-12.el7.x86_64.rpm
    openssl-libs-1.0.2k-16.el7.x86_64.rpm
    openssl-perl-1.0.2k-12.el7.x86_64.rpm
    openssl-static-1.0.2k-12.el7.i686.rpm
    openssl-static-1.0.2k-12.el7.x86_64.rpm
    pam-1.1.8-22.el7.i686.rpm
    parted-3.1-29.el7.i686.rpm
    pcre-8.32-17.el7.i686.rpm
    pcre-devel-8.32-17.el7.x86_64.rpm
    perl-Newt-1.08-36.el7.x86_64.rpm
    perl-WWW-Curl-4.15-13.el7.x86_64.rpm
    readline-6.2-10.el7.i686.rpm
    sqlite-3.7.17-8.el7.i686.rpm
    sqlite-3.7.17-8.el7.x86_64.rpm
    sqlite-devel-3.7.17-8.el7.i686.rpm
    sqlite-devel-3.7.17-8.el7.x86_64.rpm
    sslscan-1.10.2-3.el7.x86_64.rpm
    systemd-libs-219-62.el7.i686.rpm
    tlssled-1.3-4.el7.noarch.rpm
    xz-libs-5.2.2-1.el7.i686.rpm
    zlib-1.2.7-18.el7.x86_64.rpm
    zlib-devel-1.2.7-18.el7.x86_64.rpm

 then run following command :-

     # cd /opt/Qt/5.7/Src/qtbase/src/plugins/sqldrivers/mysql <--|
    # /opt/Qt/5.7/gcc_64/bin/qmake "INCLUDEPATH+=/usr/include/mysql" "LIBS+=-L/usr/lib64/mysql             -lmysqlclient_r -lrt -ldl" mysql.pro
    # make
    #make install

then run following program :-

    #include <QtWidgets>
    #include <QtSql>
    int main(int argc,char* argv[])
    {
        QApplication app(argc,argv);
        QTableView table;
        table.setWindowTitle("QT-Connect to MySQL Database");
        QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
        db.setHostName("localhost");
        db.setDatabaseName("collegedata");
        db.setUserName("rahul");
        db.setPassword("rahul");
        if (!db.open())
        {
            QMessageBox::critical(0, QObject::tr("Database Error"),
            db.lastError().text());  
        }
      
        QSqlQuery query;
        query.exec("select * from studentdata");
        QSqlQueryModel model;
        model.setQuery(query);
        table.setModel(&model);
        table.resizeColumnsToContents();
        table.resize(450,250);
        table.show();

        return app.exec();
    }


if this shows table then you have succesfully installed mysql sql plugin

SDL program - dispalying xy coordinates of mouse pointer in sdl window

 hi to all. i am giving here SDL2 program. In which we display images on mouse click, keystrokes and mouse motion. prerequisie : centos 7.5, codeblocks 17.12, SDL2 library and header files(install using rpm).

in C::B add following entries :
in project build options :-
tick on c++11 & targetx86_64 (64 bit) [-m64]

on linker settings :-

SDL2
SDL2_image
SDL2_ttf

in search directories:-
compiler:-
/usr/include/SDL2

in linker :-
/usr/lib64

now new project-> SDL2 project. Enter project name.-> next ->finish.

now open main.cpp and make it blank.
 then write following program:-

    #include <SDL.h>
    #include <SDL_image.h>
    #include <SDL_ttf.h>

    #include <iostream>
    #include <string>
    #include <cstring>

    using std::cout;
    using std::cin;
    using std::endl;
    using std::string;

    int main(int argc,char ** argv)
    {

        SDL_Surface *image1 = nullptr;
        SDL_Surface *image2 = nullptr;
        SDL_Surface *image3 = nullptr;
        SDL_Surface * currentSurface  = nullptr;
        SDL_Renderer *renderer = nullptr;
        SDL_Renderer *textRenderer = nullptr;
        SDL_Texture * winTexture = nullptr;

        string str = "";
        char *x, *y;
        x = new char[sizeof(int) + 10];
        y = new char[sizeof(int) + 10];

        char x1[sizeof(int) + 1];
        char y1[sizeof(int) + 1];

        if(SDL_Init(SDL_INIT_EVERYTHING) < 0)
        {
            cout << "Error in SDL_Init(SDL_INIT_EVERYTHING) ... " << SDL_GetError() << endl;
            exit(1);
        }

        SDL_Window *sdlwindow = SDL_CreateWindow("Game Engine", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1024, 768, SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL);
        if(sdlwindow == nullptr)
        {
            cout << "Error in SDL_CreateWindow(\"Game Engine ... \" " << SDL_GetError() << endl;
            exit(2);
        }

        SDL_Surface * windowSurface = SDL_GetWindowSurface(sdlwindow);
        if( windowSurface == nullptr)
        {
            cout << "Error in  SDL_GetWindowSurface(sdlwindow); " << SDL_GetError() <<endl;
            exit(8);
        }

        if( TTF_Init() < 0)
        {
            cout << "Error in    if( TTF_Init() < 0) " << TTF_GetError() << endl;
            exit(11);
        }

        image1 = SDL_LoadBMP("/opt/projects/sdl/images/bmp_file.bmp");

        if(image1 == nullptr)
        {
            cout << " Error in SDL_LoadBMP(\"bmp_file.bmp\"); " <<SDL_GetError() << endl;
            exit(3);
        }
        if((image2 = SDL_LoadBMP("/opt/projects/sdl/images/file1.BMP")) == nullptr)
        {
            cout << "Error in SDL_LoadBMP(\"/opt/projects/sdl/images/file1.BMP\")) " << SDL_GetError() << endl;
            exit(4);
        }

        if((image3 = SDL_LoadBMP("/opt/projects/sdl/images/file2.BMP")) == nullptr)
        {
            cout << "Error in SDL_LoadBMP(\"/opt/projects/sdl/images/file2.BMP\") " << SDL_GetError() << endl;
            exit(5);
        }
        renderer = SDL_CreateRenderer(sdlwindow,-1, SDL_RENDERER_ACCELERATED);

        SDL_Surface *surface = new SDL_Surface;
        SDL_Texture *texture = nullptr;

        SDL_Rect *rect = new SDL_Rect;
        rect->x = rect->y = 0;

        SDL_Rect trect;
        trect.x = 500;
        trect.y = 250;

        TTF_Font *font = TTF_OpenFont("/opt/projects/sdl/fonts/roboto/Roboto-Medium.ttf", 20);
        SDL_Color color = { 0, 255, 0, 255};

        SDL_Texture *text = nullptr;
        SDL_Surface *textSurface = nullptr;

        int imgflags = IMG_INIT_PNG | IMG_INIT_JPG;
        if(!(IMG_Init(imgflags) & imgflags))
        {
            cout << "Error in if(!(IMG_Init(imgflags) & imgflags)) " << IMG_GetError() << endl;
            exit(9);
        }

        bool isRunning = true;

        SDL_Event * ev = new SDL_Event;
        while(isRunning)
        {
             while(SDL_PollEvent(ev) != 0)
            {

                if(ev->type == SDL_QUIT)
                {
                    isRunning = false;
                }
                else if(ev->type == SDL_MOUSEBUTTONDOWN)
                {
                    if(ev->button.button == SDL_BUTTON_LEFT)
                    {
                        surface = IMG_Load("/opt/projects/sdl/images/road.bmp");
                    }
                    else if(ev->button.button == SDL_BUTTON_RIGHT)
                    {
                        surface = IMG_Load("/opt/projects/sdl/images/rose.bmp");
                    }
                    texture = SDL_CreateTextureFromSurface(renderer,surface);
                }

                else if(ev->type == SDL_KEYDOWN)
                {

                    switch (ev->key.keysym.sym)
                    {
                    case SDLK_1:
                        surface = IMG_Load("/opt/projects/sdl/images/bridge.jpg");
                        break;
                    case SDLK_2:
                        surface = IMG_Load("/opt/projects/sdl/images/tree.jpg");
                        break;
                    case SDLK_3:
                        surface = IMG_Load("/opt/projects/sdl/images/filepng.png");
                        break;
                    }
                    texture = SDL_CreateTextureFromSurface(renderer,surface);
                }

                else if(ev->type == SDL_MOUSEMOTION)
                {
                    snprintf(x, sizeof(x), "%d", ev->button.x );
                    snprintf(y, sizeof(y), "%d", ev->button.y);

                    str.append(" x axis : " );
                    str.append(x);
                    str.append("  y axis : " );
                    str.append(y);

                    textSurface = TTF_RenderText_Solid(font, str.c_str(), color);
                    if(textSurface == nullptr)
                    {
                        cout << "Error in  textSurface = TTF_RenderText_Solid(font, str.c_str(), color); " << SDL_GetError() << endl;
                        exit(10);
                    }
                    winTexture = SDL_CreateTextureFromSurface(renderer, textSurface);
                    if(winTexture == nullptr)
                    {
                        cout << "Error in  texture = SDL_CreateTextureFromSurface(renderer, textSurface); " << SDL_GetError() <<endl;
                        exit(12);
                    }
                    SDL_QueryTexture(winTexture, NULL, NULL, &trect.w, &trect.h);
                    str = "";
                }

            }

            SDL_RenderClear(renderer);
            SDL_RenderCopy(renderer, texture, NULL, NULL);//rect);
            SDL_RenderCopy(renderer, winTexture, NULL, &trect);
            SDL_RenderPresent(renderer);
        }

        SDL_FreeSurface(windowSurface);
        SDL_FreeSurface(currentSurface);
        SDL_DestroyWindow(sdlwindow);
        SDL_FreeSurface(image1);
        SDL_FreeSurface(image2);
        SDL_FreeSurface(image3);

        windowSurface = currentSurface = image1 = image2 = image3 = nullptr;
        sdlwindow = nullptr;

        IMG_Quit();
        TTF_Quit();
        SDL_Quit();

        return 0;
    }

now  download some image files used in this program. save these in /opt/projects/sdl/images







how to configure DNS server in centos 7.5.

first install bind in server.

bind-9.9.4-61.el7.x86_64.rpm
bind-chroot-9.9.4-61.el7.x86_64.rpm
bind-devel-9.9.4-61.el7.x86_64.rpm
bind-dyndb-ldap-11.1-4.el7.x86_64.rpm
bind-lite-devel-9.9.4-61.el7.x86_64.rpm
bind-pkcs11-9.9.4-61.el7.x86_64.rpm
bind-pkcs11-devel-9.9.4-61.el7.x86_64.rpm
bind-pkcs11-libs-9.9.4-61.el7.x86_64.rpm
bind-pkcs11-utils-9.9.4-61.el7.x86_64.rpm
bind-sdb-9.9.4-61.el7.x86_64.rpm
bind-sdb-chroot-9.9.4-61.el7.x86_64.rpm


then configure file "/etc/named.conf" as follows:-

    //
    // named.conf
    //
    // Provided by Red Hat bind package to configure the ISC BIND named(8) DNS
    // server as a caching only nameserver (as a localhost DNS resolver only).
    //
    // See /usr/share/doc/bind*/sample/ for example named configuration files.
    //
    // See the BIND Administrator's Reference Manual (ARM) for details about the
    // configuration located in /usr/share/doc/bind-{version}/Bv9ARM.html

    options {
        listen-on port 53 { 127.0.0.1; 192.168.60.1; };
    #    listen-on-v6 port 53 { ::1; };
        directory     "/var/named";
        dump-file     "/var/named/data/cache_dump.db";
        statistics-file "/var/named/data/named_stats.txt";
        memstatistics-file "/var/named/data/named_mem_stats.txt";
        allow-query     { localhost; 192.168.60.0/24; };

        /*
         - If you are building an AUTHORITATIVE DNS server, do NOT enable recursion.
         - If you are building a RECURSIVE (caching) DNS server, you need to enable
           recursion.
         - If your recursive DNS server has a public IP address, you MUST enable access
           control to limit queries to your legitimate users. Failing to do so will
           cause your server to become part of large scale DNS amplification
           attacks. Implementing BCP38 within your network would greatly
           reduce such attack surface
        */
        recursion yes;

        dnssec-enable yes;
        dnssec-validation yes;

        /* Path to ISC DLV key */
        bindkeys-file "/etc/named.iscdlv.key";

        managed-keys-directory "/var/named/dynamic";

        pid-file "/run/named/named.pid";
        session-keyfile "/run/named/session.key";
    };

    logging {
            channel default_debug {
                    file "data/named.run";
                    severity dynamic;
            };
    };

    zone "." IN {
        type hint;
        file "named.ca";
    };

    include "/etc/named.rfc1912.zones";
    include "/etc/named.root.key";

    zone "db.net" IN {

        type master;
        file "db.forward.zone";
        allow-update { none; };
    };

    zone "60.168.192.in-addr.arpa" IN {

        type master;
        file "db.reverse.zone";
        allow-update { none; };
    };


here "db.net" is mine domain name. Files "db.forward.zone" and "db.reverse.zone" are located in /var/named". zone "db.net" is forward zone i.e.file "db.forward.zone" will translate hostname to ipaddress. And "60.168.192.in-addr.arpa"  is reverse zone in this zone you have to write ip zone in reverse order ( it is mandatory ) but not last octat of your ipaddress ( in my case mine server's ipaddress is 192.168.60.1) . then wrtite following file  "/var/named/db.forward.zone" and "/var/named/db.reverse.zone". as follows :-

db.forward.zone is :-
---------------------

$TTL 1D
@    IN SOA    db.net. admin.db.net. (
                        2019112901; serial
                        1D    ; refresh
                        1H    ; retry
                        1W    ; expire
                        3H )    ; minimum

@        IN    NS    server75.db.net.
@        IN    A      192.168.60.1

    server75    IN    A    192.168.60.1
    serverora11gr2    IN    A    192.168.60.2
    centos6client    IN    A    192.168.60.3
    centos7client    IN    A    192.168.60.4

    server5        IN    A    192.168.60.5
    server6     IN    A    192.168.60.6


db.reverse.zone :-
------------------
$TTL 1D
@    IN SOA    db.net. admin.db.net. (
                        2019112901; serial
                        1D    ; refresh
                        1H    ; retry
                        1W    ; expire
                        3H )    ; minimum
@        IN    NS    server75.db.net.
@        IN    PTR    db.net.

    1        IN    PTR    server75.db.net.
    2        IN    PTR    serverora11gr2.db.net.
    3        IN    PTR     centos6client.db.net.
    4        IN    PTR    centos7client.db.net.

    5        IN    PTR    server5.db.net.
    6        IN    PTR    server6.db.net.

Note : be remember for spaces, there should not be any space before "@" in "db.forward.zone" and "db.reverse.zone". Those are strictly touched in editor's zeroth column. And if errors check for spaces as here in files, this is also true for "named.conf".
@ means this zone SOA:The SOA record stores information about the name of the server that supplied the data for the zone root.example.com. (don‘t forget period at the end) is mail address resposibile person for zone (although it dosen‘t seems as e-mail address),remeber @ means ― this  zone in this case 2019112901 is serial zone number.It’s purpose in DNS zone files is to provide a way for the server to verify that the contents of a zone file are up-to-date. If the serial number in a zone file hasn‘t changed since that zone was last loaded, named figures that it can ignore the file.I put datetime as number,followed with 01 at the end,you can put any number you like

Refresh: Indicates the time when the slave will try to refresh the zone from the master (if we have another DNS server which transfers zone files from master server)

Retry:Defines the time between retries if the slave (secondary) fails to contact the master when refresh (above) has expired

Expire:Indicates when the zone data are considered incorrect by slave server,then slave tries to get update from master server

Minimum: defines the duration in seconds that the record may be cached We don‘t have slave server so accept default values

then fire following command :-

    # firewall-cmd –zone=public –add-service=dns –permanent

    # firewall-cmd –reload


change group name and owner name :-


    # chown named:named -Rf /var/named/


to check configure of named run following command :-

    # named-checkconf /etc/named.conf

if this is not showing any output then everything is fine.
then

    # systemctl restart named


if this is not showing any output then everything is fine.

then run following command

    # named-checkzone db.forward.zone /var/named/db.forward.zone


this will show following output :-

    zone db.forward.zone/IN: loaded serial 2019112901
    OK


for reverse zone :-

    # named-checkzone db.reverse.zone /var/named/db.reverse.zone


this will show following output:-

    zone db.reverse.zone/IN: loaded serial 2019112901
    OK


then check dns by following  following command ( in server side ):-

    [root@server75 rahul]# dig @localhost server75.db.net

    ; <<>> DiG 9.9.4-RedHat-9.9.4-61.el7 <<>> @localhost server75.db.net
    ; (2 servers found)
    ;; global options: +cmd
    ;; Got answer:
    ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 7725
    ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 1

    ;; OPT PSEUDOSECTION:
    ; EDNS: version: 0, flags:; udp: 4096
    ;; QUESTION SECTION:
    ;server75.db.net.        IN    A

    ;; ANSWER SECTION:
    server75.db.net.    86400    IN    A    192.168.60.1

    ;; AUTHORITY SECTION:
    db.net.            86400    IN    NS    server75.db.net.

    ;; Query time: 1 msec
    ;; SERVER: 127.0.0.1#53(127.0.0.1)
    ;; WHEN: Tue Jan 14 17:04:47 IST 2020
    ;; MSG SIZE  rcvd: 74


resolv.conf will be :-
----------------------

    # cat /etc/resolv.conf

    # Generated by NetworkManager
    search db.net
    nameserver 202.56.224.153
    nameserver 59.144.127.17
    nameserver 192.168.60.1



on client side :-
-----------------

set following :-

in /etc/resove.conf :-

    search db.net
    nameserver 192.168.60.1
    nameserver 202.56.224.153
    nameserver 59.144.127.17


here last two nameservers are from ISP.

run following command ( in client side ):-
------------------------------------------

    # dig server75.db.net

    ; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.68.rc1.el6 <<>> server75.db.net
    ;; global options: +cmd
    ;; Got answer:
    ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 23182
    ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 0

    ;; QUESTION SECTION:
    ;server75.db.net.        IN    A

    ;; ANSWER SECTION:
    server75.db.net.    86400    IN    A    192.168.60.1

    ;; AUTHORITY SECTION:
    db.net.            86400    IN    NS    server75.db.net.

    ;; Query time: 2 msec
    ;; SERVER: 192.168.60.1#53(192.168.60.1)
    ;; WHEN: Tue Jan 14 17:12:25 2020
    ;; MSG SIZE  rcvd: 63


and also this command :-
------------------------

    # host server75
    server75.db.net has address 192.168.60.1


now try both commands ( dig  and  host ) from every client.

Note: if you first "ON" in server in VM  then clinet in VM, then do this :-

    # ping serverora11gr2.db.net
    # ping 192.168.60.2

  and wait for at least 10-15 seconds.
here mine serverora11gr2.db.net is one of client's host name and ip address listed in db.foward.zone" and in "db.reverse.zone".

Note : If your hosts are not pinging, then restart named in server and then ping to needed clients. As follows :-

# systemctl named restart 

# ping serverora11gr2.db.net

--- done.