User forums > Help
Exectution Directory and Debbuger Working Directory
le Pape:
Hi,
I'm sorry if this question has been asked a thousand times already, but googling and search on the forum and on the wiki didn't gave result (maybe I didn't searched the right way ?)
My problem : I made a small program accessing files by relative path. When I run debug or release target from Code::Blocks, it works, files are found and parsed. The same when I directly run the .exe. But when I debug (Debug->Start) the very same program, the files aren't found.
My configuration : Windows using Codeblocks with Mingw/gcc compiler. The exe files are output in "ProjectName/bin" directory. There is no space in path.
What I tried :
- I tried changing the Execution Directory, with no change in behaviour.
- Adding the file that is not found while using the debugger some other place. When I put it in "ProjectName" directory, it is still not found, but if I place it in the parent directory of "ProjectName", it works (though it is not even in the workspace).
- When I launch my exe file through the "cmd" tool, the path from where I launch it doesn't matter : it always works.
Any help would be appreciated ! :)
(even pointing the good keywords to find the solution)
Thanks !
†
ollydbg:
--- Quote from: le Pape on February 27, 2012, 01:43:49 am ---My configuration : Windows using Codeblocks with Mingw/gcc compiler. The exe files are output in "ProjectName/bin" directory. There is no space in path.
What I tried :
- I tried changing the Execution Directory, with no change in behaviour.
- Adding the file that is not found while using the debugger some other place. When I put it in "ProjectName" directory, it is still not found, but if I place it in the parent directory of "ProjectName", it works (though it is not even in the workspace).
- When I launch my exe file through the "cmd" tool, the path from where I launch it doesn't matter : it always works.
--- End quote ---
Change you "execution working dir" to "ProjectName/bin" should solve your problem, because this will have the same working dir as you launch your exe in the command shell (suppose you first cd to "ProjectName/bin", and type the app name to run it). Both the debugger and the console runner use the same "execution working dir".
If it still does not works, more details should be told about your project. (like the log message you "Run" your app, and the log message you "Debug" your app)
le Pape:
Hi Ollydbg,
Thanks for your answer :)
By "execution working dir", Do you mean "Project settings">"Execution directory" ?
If yes, then it does not solve the problem. :(
If using the console, I "cd" to "ProjectName/.." and then "ProjectName/bin/ProjectName.exe", the program runs without error. If I cd to "ProjectName/bin/" and then "ProejctName.exe", it works as well. Though, I don't know if windows makes a difference in this case. Maybe both ways he runs the program in its own directory (with an implicit cd ?).
When running my app, I don't have any special log. Files are found and processed. No error.
When launching it by "Debug">"Start", the error is "no such file or directory".
I'm using Code::Blocks 10.05 (installed with MinGW, but I switched to a newer version of minGW since then). It is a console application.
My program runs on orx engine and it is the configuration file loading that fails (only when debbuging and if I don't place the config file in the parent directory of my project "ProjectName/..").
I thought it might be a directory separator problem, like using "/" unix style instead of "\\" windows style, but the fact it works when run and it doesn't when debbuged puzzles me.
I'll give more information in a few hours when I'm home (Build logs, project configuration file, if you see anything else that could be helpfull...).
Thanks ! :)
p2rkw:
Check process working directory while running with and without debugger, for example with 'system("cd");'. Are both of these absolute paths are same?
le Pape:
Hello p2rkw,
Thanks for your tip !
I tried it and the result is interesting but kinda puzzling for me :
I placed a system("cd"); at the beginning of the main function and another at the end.
In both case (run or debugging), the first gives the correct result : Parent/ProjectName/bin
But the second system("cd");, run at the end, gives "Parent/ProjectName/bin" when I run the program but "Parent" when I debug it.
In other words, when I run it, everything is ok, but when I debug it, the first is ok, the second is wrong.
Maybe it is a problem in the code I use, though, I can't see how the behavior can differ from runing with debugging. I though it was the very same assembly ?
Here is the build log :
--- Code: ----------------- Build: Debug in ProjectName ---------------
Compiling: src\ProjectTest.cpp
lib\orx-1.3rc0\include/utils/orxString.h:276:41: warning: 'orxU32 orxString_PrintUTF8Character(orxCHAR*, orxU32, orxU32)' defined but not used [-Wunused-function]
lib\orx-1.3rc0\include/display/orxDisplay.h:391:35: warning: 'orxCOLOR* orxColor_FromRGBToHSL(orxCOLOR*, const orxCOLOR*)' defined but not used [-Wunused-function]
lib\orx-1.3rc0\include/display/orxDisplay.h:468:35: warning: 'orxCOLOR* orxColor_FromHSLToRGB(orxCOLOR*, const orxCOLOR*)' defined but not used [-Wunused-function]
lib\orx-1.3rc0\include/display/orxDisplay.h:562:35: warning: 'orxCOLOR* orxColor_FromRGBToHSV(orxCOLOR*, const orxCOLOR*)' defined but not used [-Wunused-function]
lib\orx-1.3rc0\include/display/orxDisplay.h:637:35: warning: 'orxCOLOR* orxColor_FromHSVToRGB(orxCOLOR*, const orxCOLOR*)' defined but not used [-Wunused-function]
Compiling: main.cpp
lib\orx-1.3rc0\include/utils/orxString.h:276:41: warning: 'orxU32 orxString_PrintUTF8Character(orxCHAR*, orxU32, orxU32)' defined but not used [-Wunused-function]
lib\orx-1.3rc0\include/display/orxDisplay.h:391:35: warning: 'orxCOLOR* orxColor_FromRGBToHSL(orxCOLOR*, const orxCOLOR*)' defined but not used [-Wunused-function]
lib\orx-1.3rc0\include/display/orxDisplay.h:468:35: warning: 'orxCOLOR* orxColor_FromHSLToRGB(orxCOLOR*, const orxCOLOR*)' defined but not used [-Wunused-function]
lib\orx-1.3rc0\include/display/orxDisplay.h:562:35: warning: 'orxCOLOR* orxColor_FromRGBToHSV(orxCOLOR*, const orxCOLOR*)' defined but not used [-Wunused-function]
lib\orx-1.3rc0\include/display/orxDisplay.h:637:35: warning: 'orxCOLOR* orxColor_FromHSVToRGB(orxCOLOR*, const orxCOLOR*)' defined but not used [-Wunused-function]
Linking console executable: bin\ProjectNameD.exe
Output size is 5.24 MB
Process terminated with status 0 (0 minutes, 7 seconds)
0 errors, 10 warnings
--- End code ---
Well, my path kinda look like people waving both arms \o/ and the compiler seems to be a little too careful regarding libraries (yes, some functions are declared but not used, easy compiler, easy, it's gonna be okay), but nothing too bad I think.
The project config file :
--- Code: ---<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>
<Option title="ProjectName" />
<Option pch_mode="2" />
<Option compiler="gcc" />
<Build>
<Target title="Debug">
<Option output="bin\ProjectNameD" prefix_auto="1" extension_auto="1" />
<Option working_dir="bin" />
<Option object_output="obj\Debug\" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-g" />
<Add option="-D__orxDEBUG__" />
</Compiler>
<Linker>
<Add library="lib\orx-1.3rc0\lib\static\liborxed.a" />
<Add library="lib\extern\SOIL\lib\mingw\libSOIL.a" />
<Add library="lib\extern\openal-soft\lib\mingw\libopenal32.a" />
<Add library="lib\extern\freetype-2.4.1\lib\mingw\libfreetype.a" />
<Add library="lib\extern\libsndfile-1.0.22\lib\mingw\libsndfile.a" />
<Add library="lib\extern\SDL-1.2.14\lib\mingw\libSDL.a" />
<Add library="lib\extern\Box2D_2.1.3\lib\mingw\libbox2dd.a" />
<Add library="lib\extern\glfw-2.7\lib\win32\libglfw.a" />
<Add library="lib\extern\SFML-1.5\lib\mingw\libsfml-system-d.a" />
<Add library="lib\extern\SFML-1.5\lib\mingw\libsfml-audio-d.a" />
<Add library="lib\extern\SFML-1.5\lib\mingw\libsfml-graphics-d.a" />
<Add library="lib\extern\SFML-1.5\lib\mingw\libsfml-network-d.a" />
<Add library="lib\extern\SFML-1.5\lib\mingw\libsfml-window-d.a" />
<Add library="OpenGL32" />
</Linker>
</Target>
<Target title="Release">
<Option output="bin\ProjectName" prefix_auto="1" extension_auto="1" />
<Option working_dir="bin" />
<Option object_output="obj\Release\" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-O2" />
</Compiler>
<Linker>
<Add option="-s" />
<Add library="lib\orx-1.3rc0\lib\static\liborxe.a" />
<Add library="lib\extern\SOIL\lib\mingw\libSOIL.a" />
<Add library="lib\extern\openal-soft\lib\mingw\libopenal32.a" />
<Add library="lib\extern\freetype-2.4.1\lib\mingw\libfreetype.a" />
<Add library="lib\extern\libsndfile-1.0.22\lib\mingw\libsndfile.a" />
<Add library="lib\extern\SDL-1.2.14\lib\mingw\libSDL.a" />
<Add library="lib\extern\Box2D_2.1.3\lib\mingw\libbox2d.a" />
<Add library="lib\extern\glfw-2.7\lib\win32\libglfw.a" />
<Add library="lib\extern\SFML-1.5\lib\mingw\libsfml-system.a" />
<Add library="lib\extern\SFML-1.5\lib\mingw\libsfml-audio.a" />
<Add library="lib\extern\SFML-1.5\lib\mingw\libsfml-graphics.a" />
<Add library="lib\extern\SFML-1.5\lib\mingw\libsfml-network.a" />
<Add library="lib\extern\SFML-1.5\lib\mingw\libsfml-window.a" />
<Add library="OpenGL32" />
</Linker>
</Target>
</Build>
<Compiler>
<Add option="-Wall" />
<Add option="-fexceptions" />
<Add option="-static-libgcc" />
<Add option="-D__orxSTATIC__" />
<Add directory="include" />
<Add directory="lib\orx-1.3rc0\include" />
</Compiler>
<Linker>
<Add directory="lib\orx-1.3rc0\dev-mingw\bin" />
</Linker>
<Unit filename="include\ProjectTest.h" />
<Unit filename="main.cpp" />
<Unit filename="src\ProjectTest.cpp" />
<Extensions>
<code_completion />
<debugger />
</Extensions>
</Project>
</CodeBlocks_project_file>
--- End code ---
Navigation
[0] Message Index
[#] Next page
Go to full version