windows - Difference in relative file path: debug mode and release mode of Qt Creator -
qfile file("test.txt"); if (file.open(qiodevice::readonly)) { qdebug()<<"you got me."; }
i using:
- qt 4.8.6 msvc 2010
- qt creator 3.1.1
- windows 7 (32 bit)
from above code, if .pro
file has not been changed, corresponding build directory
for debug mode:
d:\...\build-main-msvc2010-debug
and .exe
of debug mode located in
d:\...\build-main-msvc2010-debug\debug
for release mode:
d:\...\build-main-msvc2010-release
and .exe
of release mode located in
d:\...\build-main-msvc2010-release\release
[question]
if want release program read "test.txt" file, put file in folder
d:\...\build-main-msvc2010-release\release
which makes sense.
but if want debug program read "test.txt" file, have put file in folder
d:\...\build-main-msvc2010-debug\
rather than
d:\...\build-main-msvc2010-debug\debug
i wondering why relative file path worked differently in debug & release mode, has been bothering me long time.
[edit]
thanks @paul , @lpapp. here screenshot of working directory:
debug:
release:
[very important edit]
for @paul , @lpapp:
i used copy required .dll
release folder test runtime, , found if execute release program through qt creator, working directory work said. if directly click .exe in release folder, situation said in question. think there might differences between running program qt creator , directly executing program.
this depends on current working directory of program. can change in project->run settings->run->working directory.
if execute release program through qt creator, working directory work said. if directly click .exe in release folder, situation said in question.
this because when click .exe in release foder, folder working directory program. when run program qt creator, qt creator sets working directory explicitly. may override working directory directory .exe file created it'll no difference whether run program qt creator or click .exe in explorer.
Comments
Post a Comment