Sunday, July 6th 2008, 3:41pm UTC+1

You are not logged in.

  • Login
  • Register

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains how this page works. You must be registered before you can use all the page's features. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

ajonesfl

Beginner

Posts: 7

Location: Florida

Occupation: developer

1

Monday, March 17th 2008, 2:34am

QStringList Compile Problem

I get a compile error when using QStringList. I have a very simple program:

#include "QApplication.h"
#include "QStringList.h"

int main(int argc, char* argv[])
{
QApplication app(argc, argv);
QStringList strList;
strList << "one" << "two" << "Three";

return app.exec();
}

I do the qmake -project, then qmake testproj.pro, then make. I am using mingw and QT 4.3.2.

I get the following error:
C:\Users\ajonesfl\Cpp Projects\Examples\testproj>make
mingw32-make -f Makefile.Release
mingw32-make[1]: Entering directory `C:/Users/ajonesfl/Cpp Projects/Examples/testproj'
g++ -mthreads -Wl,-enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -Wl,-s -Wl,-s -Wl,-subsystem,windows -o "release\test
proj.exe" release\testproj.o -L"c:\Qt\4.2.3\lib" -lmingw32 -lqtmain -lQtGui4 -lQtCore4
release\testproj.o(.text$_ZN5QListI7QStringE13detach_helperEv[QList<QString>::detach_helper()]+0x4c):testproj.cpp: undefined reference to `_imp___ZN9Q
ListData7detach2Ev'
collect2: ld returned 1 exit status
mingw32-make[1]: *** [release\testproj.exe] Error 1
mingw32-make[1]: Leaving directory `C:/Users/ajonesfl/Cpp Projects/Examples/testproj'
mingw32-make: *** [release] Error 2

When I comment out the line: strList << "one" << "two" << "Three";

The program compiles..... Any help would be appreciated on this. Thanks
Adam Jones
  • Go to the top of the page

2

Monday, March 17th 2008, 3:09am

hi
I compile your code and it run without Problem
note:
if you will not create any GUI object replace
return app.exec();
with
return 0;

because the program still run in memory in the first case
  • Go to the top of the page

ajonesfl

Beginner

Posts: 7

Location: Florida

Occupation: developer

3

Thursday, March 20th 2008, 12:56pm

QStringList Compile Problem

Thanks for your reply, but it was not helpful. What the problem turned out to be was that I did not have the correct libraries that match the header files that I had. So if any one gets this type of error in the future, make sure your headers files versions are in sync with the libraries versions.

I believe my files got out of sync when I upgraded to a newer version of QT.
Adam Jones
  • Go to the top of the page

Rate this thread