PDA

View Full Version : Linker error with QtGui module, method doesn't exist in CE?



Willybood
27th October 2010, 21:49
I wasn't sure whether this problem should go in the Qt for embedded sub forum, but I'm at least pretty sure this is a more general issue. If anyone tells me differently, I'll move the thread.

I'm working on an application, based on the Hello GL ES example (http://doc.trolltech.com/4.4/opengl-hellogl-es.html) for windows CE. After some pain stacking work and debugging, I have the application working brilliantly on my windows desktop, but when I try compiling in visual studio for deployment, I get the following linker error.


Error 1 error LNK2019: unresolved external symbol getenv referenced in function jinit_memory_mgr QtGui.lib PlotPlanPlayerV3

"getenv()" is a function which isn't defined for windows CE (and is apparently, outdated). Is there some alternative to this I can use? Can I just place in an empty class to satisfy the extern, or will that upset the systems operation?

For reference, this is Qt 4.7.0, with a static build using the following options (in case this is relevant in the slightest!)


configure -platform win32-msvc2008 -xplatform wince50standard-armv4i-msvc2008 -nomake examples -nomake demos -no-qt3support -no-declarative -no-webkit -no-phonon -no-phonon-backend -opengl-es-cm -opensource -release -graphicssystem opengl -static

Thanks in advance, any help is really appreciated!

wysota
27th October 2010, 21:59
getenv() is a standard C function for retrieving environment variables so it should exist for any platform supporting ANSI C (and it's not outdated). You might try qgetenv() instead but it probably calls getenv() anyway.

Willybood
28th October 2010, 00:49
From looking through the windows CE documentation, it isn't available for that platform. Sorry for calling it outdated, thats just the impression I got from a quick google search.

The problem is, this isn't a problem caused by my code. It looks like the QtGui object has a call to something not compatable with windows CE, and I don't want to change the Qt code unless completely necessary.

I'm trying to put through an alternative (hopefully) compatable implementation using registry values to satisfy the linker error in the mean time, but if there is something else I should be doing, I'll be happy to do it.

wysota
28th October 2010, 01:08
What is "PlotPlanPlayer" anyway? It's not part of Qt.

Willybood
28th October 2010, 07:56
Its the name of the application I'm making.

tbscope
28th October 2010, 08:10
Qt should solve this for you.

Where do you call getenv()?

wysota
28th October 2010, 10:23
Its the name of the application I'm making.

So replace your call to getenv() with a call to qgetenv() and you should be fine.

Willybood
28th October 2010, 13:54
So replace your call to getenv() with a call to qgetenv() and you should be fine.

Where do you call getenv()?

Thats the thing, theres no call to getenv() in any of the code I've written. Judging by the error, it must be in some third party piece of code, and considering how the error references "QtGui.lib", possibly in Qt!

It's more likely I haven't set something up correctly, I'm just not sure what. If I get time tonight, I'll try to do the same operation with the original openGL ES example, see if that works. If not, I'll experiment with creating a new shadow build with some altered configuration settings.
Is there any chance I could be using something which isn't compatable with windows CE?

Thanks for the help by the way, If theres anything you need to know about my setup, let me know!

wysota
28th October 2010, 14:01
Thats the thing, theres no call to getenv() in any of the code I've written. Judging by the error, it must be in some third party piece of code, and considering how the error references "QtGui.lib", possibly in Qt!
No, it's not in Qt. Qt builds fine on WinCE, many people use it.


Is there any chance I could be using something which isn't compatable with windows CE?
If some library uses getenv() then yes. But you can always redefine getenv as qgetenv().

char *getenv(const char *name) {
static QByteArray ba;
ba = qgetenv(name);
return ba.data();
}

Willybood
28th October 2010, 23:42
That looks like a good solution!

I am having some problems implementing it though, but the problem is more with my C++ skills. I've placed the method in as a global function, but I'm still getting the "unresolved external" error. Is there something that I'm missing to get this recognised by an external library?

In the mean time, I'm experimenting with a new build of Qt, and early next week when I get some time, I'll do a dry run with the hello es example.

Thanks for all your help so far!

Audio
29th October 2010, 18:02
Hi,

currently I'm facing the same problem. The unresolved external symbol message appears even while trying to compile this program, that doing nothing:


#include <QtGui/QApplication>

int main(int argc, char *argv[])
{
QApplication a(argc, argv);
return a.exec();
}


I must say, that the problem appears only in the static build. Before this, I used the standard version of Qt WinCE and there was no problem with linking. Now when I try to compile my app, about 8 unresolved externals are displayed (see the log (http://pastebin.com/raw.php?i=QmvvEiqW)). Unfortunately non-static version is unacceptable for me because of huge size of DLLs.

Qt was configured with these params:


configure -static -release -platform win32-msvc2008 -xplatform wincewm65professional-msvc2008 -nomake examples -nomake demos -no-qt3support -no-phonon -no-phonon-backend -opensource

Willybood
1st November 2010, 00:28
Hey Audio, glad to hear its not just me!

I just tried with only the original hello GL-ES example, and I'm getting the same issue.

For me though, I don't necessarily need a static build. I'll recompile it later with a dynamic build, see if I have any more luck.

Sorry I cant help you, but thanks for helping me!

Audio
1st November 2010, 16:44
Hi Willybood,

you're welcome. A few minutes ago I've recompiled Qt with the same parameters I noticed in my first post except the static parameter, and it's working fine.

Also, I maybe found the solution how to change the size of libraries - qconfig tool (http://doc.qt.nokia.com/main-snapshot/fine-tuning-features.html). I'll test it when I finish my app, because at this time I don't know exactly what libraries the application will require. Anyway, it's step forward :) and I hope I won't need to use static libs.

Willybood
4th November 2010, 23:34
Final update to this issue, it turns out it was a problem with the file 'jmemmgr.c'. There was a preprocessor #ifdef in there, which when 'NO_GETENV' is defined stops getenv() being referenced in the function. And for whatever reason, the Qt installer didn't set it.

After modifying the source to add it, it ran fine. I've placed a report on the Qt bug tracker, hopefully in the next version it will be fine.