Solved Adding build date to linux project
-
I found this online:
https://www.qtcentre.org/threads/5192-show-build-date-in-about-box
In my .pro file I added:
DEFINES += "BUILDDATE=system(date +'%d-%m-%y %T')"
However this results in an error:
[main.o] Error 2
Not terribly helpful, but that's all it shows, if I comment out the DEFINES and rebuild it will build without the error.
How do I solve this?
-
@SPlatten From the link:
"Didn't you forget the $$? I can't test it for linux right now but to make it work for winxp as well it should be:
Qt Code:
Switch viewwin32:DEFINES += BUILDDATE=$$system(date /t)"
-
$$system()
notsystem()
.Here is a working example: https://github.com/milosolutions/mwizardtemplate/blob/master/version.pri
-
Thank you, I couldn't find an example for linux, will try your suggestion now.
-
My entry now reads:
DEFINES += "BUILDDATE=$$system(date +\"%d-%m-%y %T\")"
Now I get:
No such file or directory File not found: arm-argo-linux-gnueabi-g++: 0906
Also keep in mind, I'm developing on Linux not Windows.
[Edit] Solved, changed line to:
DEFINES += BUILDDATE=$$system(date +"%d-%m-%y %T")
[Edit 2] Actually, not completely solved, although the application now compiles, I still get no build date:
QString strBldDate(BUILDDATE);
Its empty.
-
@SPlatten
Hi,
maybe it isn’t what you want, if you don’t need in your PRO but in your source I use:char* data_ver = (char*)__DATE__;
char* time_ver = (char*)__TIME__;ui->buildValue->setText(QString("%1 %2").arg(data_ver).arg(time_ver));
-
Thank you, but won't that only give the date and time of the source file that its implemented in, I want the system date and time at the time of build.
-
Is there any good source of information or tutorial on how to use definitions in the .pro file?
I've been told I can use message() in a .pro file and I have to view:
message($$system(date +\"\\\"%d-%m-%y %T\\\"\")
And this works well, I can see in the General Messages pane when I build something like:
Project MESSAGE: "26-06-19 10:55:11"
How can I use this to review the content of a definition? I've tried:
message(BUILDDATE)
Just results in:
Project MESSAGE: BUILDDATE
I also tried:
message($$BUILDDATE)
The result is:
Project MESSAGE:
So if the last one is correct, nothing is being assigned to BUILDDATE, how do I fix this?
-
You can print whole DEFINES like this:
message($$DEFINES)
-
@SPlatten said in Adding build date to linux project:
but won't that only give the date and time of the source file that its implemented in
https://www.cprogramming.com/reference/preprocessor/__DATE__.html
"__DATE__ is a preprocessor macro that expands to current date (at compile time)" -
Thank you the output is:
Project MESSAGE: QT_QWS_CLIENTBLIT BUILDDATE=26-06-19 11:20:37
-
I will be abandoning the exploration of creating a definition from the system date and instead use DATE and TIME.
How do I prevent the editor from changing the text on the date and time fields?