Sign in to follow this  

Exporting Projects from VC++ EE

This topic is 4102 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Could someone explain to me how I am supposed to get my project out of VC++ EE? I have tried builing it into another directory, copying the files, and so forth, but my project depends on two text files to run properly. The Release version won't run at all, and the debug version will not recongise that I have the files in it's directory! Here's the thing: They both run perfectly when ran from VC++ EE's ide. My project consists of 3 files: WinTrans.exe splash.txt splashc.txt I have tried everything, including emulating the file hierarchy of the project, but nothing seems to work. They just refuse to reconginise the files. I assume that this error is because of it not being able to find the text files, but when I run the debug version I also get out of range errors (release version just crashes) that I don't get in EITHER version when run from inside VC++. Anyway, thanks!

Share this post


Link to post
Share on other sites
VC++ runs the program from inside the IDE in a different working directory. This means that when the .exes need files from a relative path, that relative path starts at a different place than the .exe's location. By default, VC++ runs them from the project's folder, not where the .exes are. If you want to have your .exe run, all files that use relative paths will have to be in relation to the folder of the .exe, not of the project file. Instead of:

-YourProject
--YourProject.vcproj
--splash.txt
--splashc.txt
--Debug
---YourProject.exe
--Release
---YourProject.exe

You'll want:

-YourProject
--YOurProject.vcproj
--Debug
---YourProject.exe
---splash.txt
---splashc.txt
--Release
---YourProject.exe
---splash.txt
---splashc.txt

And, you can change theworking directory in the settings for your project somewhere. Can't remember where.

Share this post


Link to post
Share on other sites
Do you mean running your project on its own, without the IDE?

If so, just put the exe from the release folder in a directory with the text files in the same directory. Simple as that.

When you run in the IDE, it runs the exe from the Release or Debug folder but the program thinks it is being run from the same folder that all your .cpp and .h files are in.

When run outside the IDE, the exe really is run in the folder it is in, so you just put any dependent files or folders in there.

Share this post


Link to post
Share on other sites
Yep, tried that. You mean like
-Folder
-Release
-exe
-text files

right? Did that, and did

-Folder
-Textfiles
-Release
-exe

as well. I just can't figure out why it won't read them. Is it anything to do with that dumb dll problem in visual C++ ee, where the program needs a special dll to run?

I am really confused. I'm going to post the code just in case:


bool ScreenBuffer::Map(char *fname)
{
std::ifstream fobj;
fobj.open(fname);
if(fobj.fail() || !fobj.is_open())
return false;
std::string hold;

char hold2;
for(int y = 0; y < 32; ++y)
{
if(fobj.eof())
return false;

std::getline(fobj, hold);


for(int x = 0; x < 80; ++x)
{
hold2 = hold[x];
buffer[x+(80*y)].Char.AsciiChar = hold2;
}

}
return true;
}




and here are the calls:

color map basically does the same thing, only with a color translation:
a.Map("splash.txt");
a.ColorMap("splashc.txt");



Share this post


Link to post
Share on other sites
Any of the VS DLLs that your program needs to run will be in your Windows system folders if VS is installed on the PC so that is certainly not the problem.

I just tried this to be double sure:

Create a project in C:\Projects called X.

main.cpp in C:\Projects\X\X


#include <iostream>
#include <fstream>
#include <string>

int main()
{
std::ifstream is("test.txt"); if(!is.is_open()) return 0;

std::string s;

std::getline(is,s);

std::cout << s << std::endl;

std::cin.get();

return 0;
}



test.txt in C:\Projects\X\X


This is the test text file.


Compiled in Release mode. Runs from the IDE, prints the line from the text file and waits for a character to exit.

I then created a folder on my desktop called X. In this folder I put the x.exe from C:\Projects\X\Release and the test.txt from the above location.

So %Desktop%\X contains x.exe and test.txt.

I can then run x.exe from that location, with the IDE closed and even having deleted the project, and it opens the file and prints the line as expected.

So whatever the problem is, it is something else and not the way you are structuring your directory. What exactly is the problem? Are you sure that the problem is that it can't find the text files? What exactly does happen when you run the program?

Share this post


Link to post
Share on other sites
I created the "x" project and everything and it works fine...

I am about 80% positive that it is the not-finding the text file, or a problem with my mapping function. If I add some error catching code to the mapper, it shows that it does in fact fail. It might be the method of mapping that I am using.

If I put the txt files in the directory in a configuration that should work, I occasionally get the odd "subscript out of range error". That occurs when I access stuff that is out of the range of the array, but I don't know where that it. This only happens SOME of the time.

When I run the RELEASE version
It just crashes. Generic windows "This program has encountered an error" send report dialog

When I run the DEBUG version
I either get a failed load message (from my error catcher), or I get a debug "subscript out of range" message, or it runs without mapping the file. Eitherway, the problem is somewhere with my mapping functions/files.

[edit] - Did some debugging, found that line 29 in the text file may be the problem, when I manually set y = 29 in the debugger, this problem doesn't arise, but it also doesn't increment the getline post.
I get the same error with the color map, so it is either a getline issue, or the text-file is problem atic

[Edited by - Plasmarobo on September 17, 2006 12:54:32 PM]

Share this post


Link to post
Share on other sites
Looking at your code, I'd say the subscript out of range error is caused by the line:


hold2=hold[x];


since you are terminating the loop on the constant '80' rather than the length of the string. I'm assuming your buffer is definately 32*80 big.

First thing I'd do would be investigate whether somehow strings are being read from the file that are too short, although it is a bit strange that this is only happening sometimes. I belive that subscript checking is on by default in VS 2005 so if a string is too short for your for loop, the debug build at least should be throwing an error up every time.

Share this post


Link to post
Share on other sites
Yeah, my screen/buffer is 80*32 chars.

It is moving from 0-79 which is 80...
I have never had this problem before, when I used different text files. this surfaced with use of new textfiles. I have noticed that when line 29 is hit the hold string looks like this: (aproximation)
"=============================================="
when in the text file it is actually
"= ="
How do I test for shortness? just hold.length() ?
and how do I fix the shortness? In my text file I made sure that lines terminate at 80, and there is no newline at end of file... should there be?

Share this post


Link to post
Share on other sites

This topic is 4102 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this