[C++] playing game on other pcs?

Started by
8 comments, last by BuffaloJ 13 years, 2 months ago
Hi,

I wonder what it takes to make an application, especially a game written with C++ and DirectX 9, run on any other machine than the one I created it? I need the app to run even on a basic pc with nothing more than normal directx9 on it and without administartor privileges (so it shouldn't require installing stuff).

So far I changed the built to release, changed to multithreaded (no dll). But still, it won't run. What else do I have to do to make my game run on any pc?
Advertisement
Each version of D3D9 (e.g. June 2010) comes with a new D3DX dll. It's those dlls which will cause most of your problems. You have three options:

1. Install the DirectX Redistributable from your installer. This is by far the best option.

2. Completely avoid using D3DX. Depending on what you use it for this may not be too hard.

3. Use a very old version of the SDK which lets you statically link D3DX. Because it's so old there may well be bugs in the SDK which cause you problems.

Why is running on PCs where the user doesn't have access to admin rights important?
Each version of D3D9 (e.g. June 2010) comes with a new D3DX dll. It's those dlls which will cause most of your problems. You have three options:[/quote]

Well if the D3DX-dll is used for stuff like D3DXCreateSprite then I can't use the second option. Using an old sdk isn't really an option, I would like to stay up-to-date as far as possible and have as less bugs as possible.

The first option isn't that satisfactory.. as my game is currently only 5 mb size and needs no registry-stuff or so I wouldn't want to use any installer. I would like to keep it portable as long as I can, too. Well probably I could add the Web-Installer of DirectX Redistr. to the folder of my game..

But aren't there some other things I need to do? I've heard something about some Microsoft SDK which I would need to include, but I couldn't find any more information about that.

Why is running on PCs where the user doesn't have access to admin rights important?
[/quote]

Well as my game was a project for school and I'll get a grade for my final certificate, I need to present it on the schools pcs, which happen to not only be totally shitty, but also out-to-date. To make it perfect I won't be allowed to install anything on any single computer even for my presentation. I don't own a laptop, but even if I did it was a better option if I could just make my game useable on any pc without requiring any addition installations.
The other option is to use LoadLibrary and GetProcAddress on your D3DX DLLs instead of linking to d3dx9.lib.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

The D3DX DLLs change name by version, so if you want to dynamically load them, your best bet is probably to decide which version is the oldest that works and try to load that one and exit with an error if it's not available. For example my system32 folder contains d3dx9_24.dll as the oldest, so try to use that one and if there's no problem hope that your school PC at least has that installed.
You mentioned you can't get the app to run on any machine but yours(been there many times myself). Are you getting any errors or is it just crashing instantly?

Have you tried vcredist.exe? This is needed for C++ apps built with Visual Studio...




The best solution is to include the redistributable that came with the version of DirectX you're using. You can also instruct your users to install using the Web Installer version (http://www.microsoft...&displaylang=en) and that seems to install all the D3DX libraries that are missing. Whenever I end up with a missing D3DX library for something I'm using, the web installer has fixed it for me.

Also make sure you're distributing the Visual C++ runtime for your version of Visual C++ if you're using Visual Studio.
If you don't link against D3DX at all and only use the core D3D interfaces, you can just have windows version checks in the code (ideally in installer) instead:

dx9.0c: WinXP SP2, Vista, Win7
dx10.0: Vista, Win7
dx10.1: VistaSP1, Win7
dx11: VistaSP2, Win7


The other most common thing to have to deal with are the visual C and C++ runtime DLL's.

Microsoft has conveniently named them vcredist_x64.exe, and vcredist_x86.exe.
And by conveniently, I mean its a huge mistake since there are about 20 versions of them, and tracking down all the hotfixed versions can be a bit tedious.

VC8, VC9, VC10
* x64, x86
* possible hotfixed versions (which should only be installed after the preceding versions)


It is possible for your program to need multiple versions of the runtime, if another DLL you are using is linked against an older version of the runtime. The easiest way to check for this is to get depends.exe (Dependency Walker) and look look at all the dlls the app is loading, which works 99% of the time (the 1% it can't handle are libraries manually loaded with LoadLibrary code)


Anything more advanced usually requires dealing with merge modules.
http://www.gearboxsoftware.com/
The other option is to use LoadLibrary and GetProcAddress on your D3DX DLLs instead of linking to d3dx9.lib. [/quote]

Ok but how do I use this? Are there any guids or so? Haven't really used DLLs so far and didn't find much usefull information.. only some tutorials that require defining each and every function I want to use of that Dll. But thats not how I'm supposed to do it, am I?

You mentioned you can't get the app to run on any machine but yours(been there many times myself). Are you getting any errors or is it just crashing instantly?

Have you tried vcredist.exe? This is needed for C++ apps built with Visual Studio... [/quote]

I'm getting that annoying "Application.exe has encountered a problem and needs to be closed" - message, then its closing. I didn't try vcredist.. as I said, I wanted to make it 100% portable without needing any external applications to beeing installed, and the only PCs I tried it had an old version of DirectX.

If you don't link against D3DX at all and only use the core D3D interfaces, you can just have windows version checks in the code (ideally in installer) instead:
[/quote]

That would be nice but as I use D3DXSprites I can't do that..

It is possible for your program to need multiple versions of the runtime, if another DLL you are using is linked against an older version of the runtime. The easiest way to check for this is to get depends.exe (Dependency Walker) and look look at all the dlls the app is loading, which works 99% of the time (the 1% it can't handle are libraries manually loaded with LoadLibrary code)[/quote]

I don't think that is happening as I don't use many DLLs except for DirectX, but I'll try out the application you suggested..

Well from what I hear from you there are not many ways I can get away from the need of having newest DirectX and vcredist. Fortunately, I just asked and got allowed to include both DirectX and vcredist to the CD I'll have to hand in my project, and for the presentation I'm just using a laptop.
Its still kinda unsatisfactory as I'd really want to make my game run on any PC with DirectX9...
vcredist.exe is an install file MS provides that allows native C++ apps created in Visual Studio to run on a machine other than your dev machine. The files it installs come with Visual Studio so you wouldn't have noticed that you needed them. That been said, the error you usually see when vcredist.exe needs to be run is 'Side by Side Configuration Error', not just a crash at start

The dependency walker should help alot. Even though you may not be using many DLL's, there are probably a bunch that are getting loaded since 1 dll can use another and that one uses another and so on. You will probably see a couple of DLLs flagged as not loadable or not working that don't look like they apply. They probably don't. The ones you need should stand out...






This topic is closed to new replies.

Advertisement