LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Linux Answers > Programming
User Name
Password

Notices


By tbodine88 at 2012-03-28 12:11
I was writing a script to install the new version of passmark Burn In. I needed to check
whether whatever version of QT was installed would support it, and if not install
the appropriate libraries.

I have searched and searched for such a Qt version checker. But found little that is helpful.

So I downloaded Qt SDK 4.8.0 and cobbled this program together:

here is the main.cpp:
PHP Code:
#include <QtCore/QCoreApplication>
/* A program to check the QT version against some desired version 
 by Thomas Bodine
*/
int main(int argcchar *argv[])
{
    
char version, * minor, * subver;
    
char dot1, *dot2;
    
version strdup(qVersion());
    
minor dot1 strchrversion,'.');
    
minor++;
    
dot2 strchrminor'.');
    
subver dot2;
    
subver++;
    *
dot1 0;
    *
dot2 0;
    if ( 
argc 4){
        
printf("usage:\n\t%s {major} {minor} {sub}\n%s%s%seg %s %s %s %s\n%s%s",
               
argv[0],
               
"\twhere \n",
               
"\tmajor is the major version number\n",
               
"\tminor is the minor version nuber\n"
               "\tsub is the subversion number\n"
argv[0],version,minor,subver,
               
"\nThis app will exit with error if the Qt version is not at least\n",
               
"what is specified\n");
        return 
1;
    }
    if( 
strcmpversionargv[1]) < )
        return 
1;
    if (
strcmp(versionargv[1]) > 0)
        return 
0;
    if ( 
strcmpminorargv[2]) < 0)
        return 
1;
    if ( 
strcmp(minor,argv[1]) > 0)
        return 
0;
    if ( 
strcmp(subver,argv[3]) <)
        return 
1;
    return 
0;//a.exec();
}/* end main*/ 
Here is the Makefile you'll need to change QTPATH for your installation
PHP Code:
QTPATH = /opt/QtSDK/Desktop/Qt/4.8.0/
QtVersionCheckmain.o
    g
++ -m32 -wl,-O1 -Wl,-rpath,$(QTPATH)/gcc/lib -o QtVersionCheck main.-L$(QTPATH)/gcc/lib -lQtCore -lpthread

main
.omain.cpp
    g
++ --m32 -pipe -O2 -Wall --D_REENTRANT -DQT_NO_DEBUG -DQT_CORE_LIB -I$(QTPATH)/gcc/mkspecs/linux-g++-32 -I. -I$(QTPATH)/gcc/include/QtCore -I$(QTPATH)/gcc/include -I. -o main.o main.cpp 

by wildwizard on Sat, 2013-11-02 18:53
The normal way to get the version number of an installed library is to use pkg-config

Code:
michael@indigo:~$ pkg-config --modversion QtCore
4.8.5


  



All times are GMT -5. The time now is 09:16 PM.

Main Menu
Advertisement
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration