PDA

View Full Version : qmake problem with application icon in windows



dashesy
10th March 2010, 01:03
I want to add icon to my application in windows XP,

I am using QT4.6.2 and mingwin that comes with it.
I have a folder called "res" in the same folder that .pro file exists. there is a .res file with icon info
IDI_ICON1 ICON DISCARDABLE "NM.ico"
NM.ico is also placed in "res" along with qrc file

when I add RC_FILE = res/nm.rc or RC_FILE = $${PWD}/res/nm.rc or even if I type the full path qmake adds this line to the generated "Makefile"
windres -i res\nm.rc -o debug\nm_res.o --include-dir=./res

note that ${PWD} is somehow changed from full path (which documents says it should be) to a simple "."
This causes problem because "windres" does not know how to locate the icon and crashes, while if it was the full path there was no problem.
I can run windres with full path but needs me to change the makefile every time that I change the pro file!

Is there any workarounds?

arpspatel
10th March 2010, 04:22
try adding line to your project file with full path and remove the RC_FILE line



QMAKE_PRE_LINK = "windres -i C:\fullpath\res\nm.rc -o C:\fullpath\debug\nm_res.o --include-dir=./res"

dashesy
10th March 2010, 21:39
Thanks for the answer but I still get this message:
"windres.exe has encountered a problem and needs to close. We are sorry for the inconvenience."

But I realized that it is Eclipse specific! having set "RC_FILE = res/nm.rc" if I run the following in a normal command prompt the build runs smoothly

path = C:/Qt/2010.02/qt/bin;C:/Qt/2010.02/mingw/bin
mingw32-make debug

I guess I will make a batch file for that and have Eclipse call it!
somehow the "build environment variable" of Eclipse does not work for windres (although g++ does not have problem !), maybe it is a weird bug in binutils!


Any thoughts on this is appreciated

dashesy
10th March 2010, 22:01
Ok that is how I solved this,

I created a file called "make.bat" and placed it in the project path (where .pro is located)

the content of make.bat is this:
path = C:/Qt/2010.02/qt/bin;C:/Qt/2010.02/mingw/bin
mingw32-make %1

then to have eclipse use your batch file from Project/Properties/"C/C++ Make Project" enter "make.bat" in the "Build command" section. Now you can build for debug release and clean as usual :)

marcelognunez
12th June 2017, 06:33
Test if you have a space in some folder in your path to the project.
Example: D:\Lab\QtProjects\MyNotepad 1.0

This make that cannot recognize "windres"

Do the follow:
-Delete the pro.user file in your project root directory
-rename without spaces (Ex: D:\Lab\QtProjects\MyNotepad-1.0)
-in Qt Creator -> Open Project -> mynotepad.pro (following the example)
Compile and Voilé.... All ok!!

Try...