0
votes

I need help in building my Qt project with "nmake".
I am using Qt4.8, Windows 7 64Bit, VS2008 Command Prompt compiler, with "nmake".

Requirement is,
I have multiple pre-compiled static libs, which I would like to use in my Qt project.

All static libraries, named Type1, Type2, Type3 and Type4 are pre-compiled, and generated corresponding Type1.lib, Type2.lib, Type3.lib and Type4.lib library files.

I have to use, say Type1.lib and Type3.lib in my project,
I know conventional method, where, inside my Qt generated .PRO file I can put

LIBS+=C:\Proj\PRO1\Type1.lib \ 
      C:\Proj\PRO1\Type3.lib

and

HEADERS += C:\Proj\PRO1\Type1.h \
           C:\Proj\PRO1\Type3.h

And I have added corresponding .h files in my main.cpp to access apis from Type1 and Type3 libs. That compiles and works very fine.
But in my case, there are multiple projects where I am not suppose to do that each time.

I am not suppose to include header files one by one in my project; instead, There is a global header file GlobalHeader.h, having defined all other lib header file path information inside it, which looks something like this,

#ifndef GLOBALHEADER_H  
#define GLOBALHEADER_H 

#define TYPE1        "C:\Proj\PRO1\Type1.h" 
#define TYPE2        "C:\Proj\PRO2\Type2.h"  
#define TYPE3        "C:\Proj\PRO3\Type3.h"  
#define TYPE4        "C:\Proj\PRO4\Type4.h" 

#endif  

My main.cpp file looks some thing like this,

#include GLOBAL_HEAD    //this is my requirement
#include TYPE1          //I should be able to use like this
#include TYPE3          //... " ...
#include <QtCore>
#include <QtGui>
#include <QApplication>
#include <QTextEdit>
int main(int argv, char **args)
{
    QApplication app(argv, args);
    QTextEdit textEdit;
    textEdit.show();
    //Lib functions called from TYPE1
    //... some operations ...
    //... some more operations ...
    //Lib functions called from TYPE3
    //... some operation ...
    //... some more operations ...
    return app.exec();
}  

I gave qmake command to compile main.cpp,

qmake -project DEFINES+=GLOBAL_HEAD=C:\Proj\GlobalHeader.h LIBS+=C:\Proj\PRO1\Type1.lib LIBS+=C:\Proj\PRO1\Type3.lib  

and it generated .PRO file, below,

DEFINES += GLOBAL_HEAD=C:\Proj\GlobalHeader.h
LIBS += C:\Proj\PRO1\Type1.lib 
LIBS += C:\Proj\PRO1\Type3.lib
TEMPLATE = app
TARGET = 
DEPENDPATH += . 
INCLUDEPATH += .
HEADERS +=
SOURCES += main.cpp 

now, my step is to generate Makefile with corresponding test.pro file,
so I gave,

qmake test.pro

Makefile, Makefile.Debug and Makefile.Release are successfully generated.

Now, I have opened Visual Studio 2008 Command Prompt and navigated to directory where my project is, and gave compile command,

nmake all  

It generated errors...

.
.
main.cpp
C:\Proj\test\main.cpp(1) : error C2006: '#include' : expected a filename, found 'identifier'
C:\Proj\test\main.cpp(1) : fatal error C1083: Cannot open include file: '': No such file or directory
.
.

Can someone please tell me what's wrong with code? Or Did I miss any information in qmake command? How do I make this project compile?
Sorry, if I have not written it properly. Please let me know if you need any more details.
Thanks in advance for your help...

1

1 Answers

0
votes

Answering what is wrong. This happens because

#include GLOBAL_HEAD

converts to

#include C:\Proj\GlobalHeader.h

when it should be enclosed into either " or angle brackets

I tried adding to .pro file

DEFINES += GLOBAL_HEAD=<C:\\Proj\\GlobalHeader.h>

but it did not help.

I dont know how to make it compile correctly, so this is only half of an answer