程序从IDE运行时找不到图像目录,但从文件夹运行时CAN? [英] Program cannot find image directory when run from IDE, but CAN when run from folder?

查看:193
本文介绍了程序从IDE运行时找不到图像目录,但从文件夹运行时CAN?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我构建,它成功没有错误。但是,当我从IDE运行时,我得到一个错误(我的映像无法加载,因为它找不到目录)。



但是,如果我进入文件夹并运行程序(.exe),它找到完美的图像目录。

  mTextures.Load(Textures :: Background, ./GFX/Background.png); 

^给出目录的代码行。



我在Windows上使用Code :: Blocks。

我假设这是一个设置的问题,我没有在编译器中正确输入。 >

解决方案

您的调试器的当前目录(即从代码块中执行应用程序时使用的当前目录)可能不正确。检查您的项目设置,并将当前目录修复到目标目录(包含可执行文件本身的目录)。



具体说明是此处


When I build, it succeeds with no errors. However, when I run from the IDE, I get an error (my image fails to load because it cannot find the directory).

However, if I go into the folder and run the program(.exe) it finds the image directory perfectly.

mTextures.Load(Textures::Background, "../GFX/Background.png");

^the line of code giving the directory.

I assume this is a problem with a setting I didn't enter correctly in my compiler?

I am using Code::Blocks on Windows.

解决方案

Your debugger's current directory (i.e. the current directory used when you execute the application from within codeblock) is probably incorrect. Check your project settings, and fix the current directory to your target directory (the one which contains the executable itself).

Specific instructions are here.

这篇关于程序从IDE运行时找不到图像目录,但从文件夹运行时CAN?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆