[Qt-interest] QTCreator + Addign static Windows Libraries
Parameshwari
paramr at tataelxsi.co.in
Thu Apr 9 13:10:42 CEST 2009
Hi ,
Thanks for your inputs.
Let me explain clearly , so that i can get the clarification
about this issue.
For Creating External Api:
1) I have Visual Studio 6.0 and
created a static library called "Test.lib" using "Windows Static Library"
with precompiled header .
My code snipet for the above is :
stdafx.cpp contains :
-------------------------------
// stdafx.cpp : source file that includes just the standard includes
// Test.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
#include<iostream.h>
void Test()
{
cout<<"Test Api";
}
stdafx.h contains :
---------------------------
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#if !defined(AFX_STDAFX_H__36299355_4C9F_49A6_9D6E_9E8046E74AC9__INCLUDED_)
#define AFX_STDAFX_H__36299355_4C9F_49A6_9D6E_9E8046E74AC9__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows
headers
// TODO: reference additional headers your program requires here
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately
before the previous line.
#endif //
!defined(AFX_STDAFX_H__36299355_4C9F_49A6_9D6E_9E8046E74AC9__INCLUDED_)
here, stdafx created deafult code and after building of the same , go the
"Test.lib" code.
-----------------
Now In Qt ,
i added in qt.pro file :
I copied the "Test.lib" to Qt directoy itself.
my .pro file contains the below :
TARGET = try
TEMPLATE = app
LIBS += -l Test.lib
# CONFIG += qtestlib
SOURCES += main.cpp \
myframe.cpp
HEADERS += myframe.h
FORMS += myframe.ui
RESOURCES += pics.qrc
In my Qt "main.cpp" file :
#include <QtGui/QApplication>
#include "myframe.h"
#ifdef BUILD_LIB
#define DLLAPI __declspec(dllexport)
#else
#define DLLAPI __declspec(dllimport)
#endif
DLLAPI void Test();
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
myFrame w;
//yourFrame w1;
w.show();
Test();
//w1.show();
return a.exec();
}
but , right now , i am getting the below error. i just want this program to
be compiled and run succesffully :(.......... badly...
Right now , we are getting
mingw32-make: Leaving directory `C:/Qt/2009.01/bin/try'
c:\Qt\2009.01\mingw\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\mingw32\bin\ld.
exe: cannot find -lTest.lib
collect2: ld returned 1 exit status
mingw32-make[1]: *** [debug\try.exe] Error 1
mingw32-make: *** [debug] Error 2
Exited with code 2.
Error while building project try
When executing build step 'Make'
thanks in advance ..............
Regards
Param
-----Original Message-----
From: Benjamin Sonnemann [mailto:b.sonnemann at gmail.com]
Sent: Thursday, April 09, 2009 3:59 PM
To: paramr at tataelxsi.co.in
Cc: Denton Vis; qt-interest at trolltech.com
Subject: Re: [Qt-interest] QTCreator + Addign static Windows Libraries
Did you declare the protoype for building with
__declspec(dllexport) ?
like this:
test.h
#ifdef BUILD_LIB
#define DLLAPI __declspec(dllexport)
#else
#define DLLAPI __declspec(dllimport)
#endif
DLLAPI void Test();
And is both compiled as C++?
Benjamin Sonnemann
On Thu, Apr 9, 2009 at 12:13 PM, Parameshwari <paramr at tataelxsi.co.in>
wrote:
Hi Denton,
I have included the header file and in the .pro file i have
included
the .lib file like the below
LIBS+= -lTest.lib in the QT project
And some where in the forum i found that we have to add
__declspec(dllimport) void Test(); outside of main. So I added that also
And
the error it is shoeing is below.
error:" undefined reference to `_imp___Z9Testv'"
Regards
Param
-----Original Message-----
From: qt-interest-bounces at trolltech.com
[mailto:qt-interest-bounces at trolltech.com]On Behalf Of Denton Vis
Sent: Thursday, April 09, 2009 2:55 PM
To: qt-interest at trolltech.com
Subject: Re: [Qt-interest] QTCreator + Addign static Windows Libraries
You have not told us what kind of error message you are getting. Without
that, we cannot help you much.
By the way, have you included the header which contains the definitions
for
the functions in the library, e.g. test.h?
"Parameshwari" <paramr at tataelxsi.co.in> wrote in message
news:019201c9b8f2$af348160$8519320a at telxsi.com...
> Hi All,
> I wanted to add the static Library to the Qt creator.
> For example:
>
> I have static Library named as "Test.lib" and it has a function
definition
> of "Test()".
> Now , i want to invoke this function in Qt. how can i do this?.Please
help
> me out!!!!
>
> Thanks in advance.
>
>
> Regards
> param
>
>
>
> The information contained in this electronic message and any
attachments
> to this message are intended for the exclusive
> use of the addressee(s) and may contain proprietary, confidential or
> privileged information. If you are not the intended
> recipient, you should not disseminate, distribute or copy this e-mail.
> Please notify the sender immediately and destroy
> all copies of this message and any attachments contained in it.
>
_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest
The information contained in this electronic message and any attachments
to this message are intended for the exclusive
use of the addressee(s) and may contain proprietary, confidential or
privileged information. If you are not the intended
recipient, you should not disseminate, distribute or copy this e-mail.
Please notify the sender immediately and destroy
all copies of this message and any attachments contained in it.
_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest
The information contained in this electronic message and any attachments to this message are intended for the exclusive
use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended
recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy
all copies of this message and any attachments contained in it.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090409/1e0f1127/attachment.html
More information about the Qt-interest-old
mailing list