Dark Bit Factory & Gravity

PROGRAMMING => C / C++ /C# => Topic started by: Clyde on March 10, 2009

Title: [C++] Running A Program Under VS Express 2008
Post by: Clyde on March 10, 2009
Three days of trying to run some code, so Im in need of a hand please folks.
There's far to many options to be worrying about in the VSExpress IDE. I like the simple things in life. ;p

A list of things that I am not at all sure of:

•I tried running a Pixel Toaster 4 example by Opening A File ( should it be project? ) and navigating me to the code I wanted to try out. It can up with a wizard to convert the entire PT4 library, which I did and telling it to keep the original files, which are now called nameetc.old

•Pressed F5 to build it; so many different compiling options, very baffling
It said there was a bit of code that had to be changed to deprecated and that it would be fixed in a later update.

•Then it asks me for a name for a name of the executable for the debugging ( this wont give the correct speed of the effects, if its anything like Blitz Debug mode - I want to see the thing in proper glory ). So I entered a name and it told me that it couldnt find it. Gave up on that after a few hundred attempts. ;)

•Am I right in thinking that to make a proper exe you have to use a tool of some kind?

Without any technical talk or jargon as I am starting out in this language, in plain simple English what is the correct procedure to get some code to run properly please?

Thankyou & Much appreciated,
Clyde.
Title: Re: [C++] Running A Program Under VS Express 2008
Post by: TinDragon on March 10, 2009
To compile an exe in Visual C++, you load the solution which will have all the source files, includes etc. then you select build solution or rebuild solution from the menus, this creates the .exe, depending on which "build" you have selected it will either create a debug build or a release build, both run fine, the debug build will be slower and contain debug info to help sort out crashes. There is no need for other external tools to create the exe's.

You can find the .exe in the project folder in either the debug or release folders once built. If it requires external media that needs to be in the correct location/path for the .exe as well but thats the same as in blitz/freebasic etc.

Title: Re: [C++] Running A Program Under VS Express 2008
Post by: Jim on March 14, 2009
Because it's building a library (a .lib), there won't be an exe produced, which is why you can't find one.  Normally you'd go to the Debug menu and select Start Debugging (Alt-D, S).

Jim
Title: Re: [C++] Running A Program Under VS Express 2008
Post by: Clyde on March 16, 2009
Do you have to always create new projects for every cpp code that you want to run. Just I have code that i've saved as a cpp file in an existing project's directory, but everytime I want to compile it, it's always compiling the 1st cpp code file that's in the directory, and not the code that I am wanting to run.

I've never had to deal with using a Project / projects before ( even though you can do this in FBIDE ), it's alittle alien to me, and a tad frustrating, as I've always compiled individual pieces of code; this comes from comming from a basic background.

Cheers for your assistance,
Clyde.
Title: Re: [C++] Running A Program Under VS Express 2008
Post by: Jim on March 16, 2009
Yes.  Each project (in your case) will be an exe - each demo you write will be a project.  You can have more than one cpp file in each project.  One day you will find this incredibly useful :)

You can pick which project is the one you are working on it by right clicking it and choosing 'Set as StartUp Project'.

The project name will appear in bold and when you select 'Debug->Start Debugging' this is the project that will run.

You will see under the 'Build' menu a 'Build Solution' option and a 'Build <whatever project is selected>' option.  If you pick the first one, it will build ALL of your projects, which isn't what you want - you want the other one :)

Jim
Title: Re: [C++] Running A Program Under VS Express 2008
Post by: Clyde on March 19, 2009
Well I am a lame ass, as I can't get it to work. Most people would be over this point by now.
Im guessing there are hidden compiler options somewhere, that makes this a sinch. I am also hoping that the help stuff given, is based on the Express Edition and not the full version of Visual Studio C++ 2008, as sometimes there could be vast differences.

If I want to save a cpp file that is in the project and save it as a different name, say for example v2, it doesnt use that code file, it always builds/compiles the first / original CPP file that was in this scenario, example v1.cpp

I know what your meaning with having more than one CPP file in the project, as thats how I like to work, have done since the Blitz years, with my own includes / reusing code in projects.

Over and out,
Clyde.
Title: Re: [C++] Running A Program Under VS Express 2008
Post by: Jim on March 19, 2009
:( Sorry to hear that.

There's almost no differences between Express and the full version, except that there is some web dev stuff missing and you only get one language at a time, instead of C++, C#, VB all in the same package.  The menus and settings are identical.

Can you either explain the project/cpp file layout you have, or zip it up and upload it here, and then explain exactly what you expect to happen?

I'm sorry but I don't understand what you are saying about your cpp files and different names.  If you have more than one cpp file, eg. file1.cpp, file2.cpp inside a project then it will always build all of them.  What exactly do you mean by 'it doesn't use  that file'?

Jim
Title: Re: [C++] Running A Program Under VS Express 2008
Post by: hellfire on March 19, 2009
Quote
If I want to save a cpp file that is in the project and save it as a different name, say for example v2, it doesnt use that code file, it always builds/compiles the first / original CPP file that was in this scenario, example v1.cpp
When you save an existing file (v1.cpp) with a different filename (v2.cpp), you have it stored on your harddisc but it's not yet part of your project.
So you simply add it to your project by right-clicking the source-folder in your project-tree, selecting "add->existing file" and picking "v2.cpp" from the file-dialog.
You probably want to remove the old file (v1.cpp), too.
Title: Re: [C++] Running A Program Under VS Express 2008
Post by: Jim on March 19, 2009
Ah, that make sense!  Clyde, if you're doing stuff in Windows Explorer or the Command window you need to stop doing that and do everything through the Solution Explorer inside VS2008.  You shouldn't need to look at the filesystem at all.

Jim
Title: Re: [C++] Running A Program Under VS Express 2008
Post by: Clyde on March 21, 2009
Thanks fellas :)
Im doing all this inside VS Express 2008.
Title: Re: [C++] Running A Program Under VS Express 2008
Post by: Clyde on August 12, 2009
I've finally got around to downloading and installing. Visual Studio C++ 2008 Express SP1.

And tried building the MSVC Tiny PTC Example, that rbz kindly converted and did.
In debug I get all of this:

Code: [Select]
------ Build started: Project: tinyptc_ext - Example, Configuration: Debug Win32 ------
Linking...
Main.obj : error LNK2019: unresolved external symbol _ptc_update referenced in function _main
Main.obj : error LNK2019: unresolved external symbol _ptc_open referenced in function _main
Main.obj : error LNK2019: unresolved external symbol _ptc_setdialog referenced in function _main
Main.obj : error LNK2019: unresolved external symbol _ptc_setflip referenced in function _main
Main.obj : error LNK2019: unresolved external symbol _ptc_allowclose referenced in function _main
LIBCMTD.lib(wincrt0.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
.\Debug/tinyptc_ext  - Example.exe : fatal error LNK1120: 6 unresolved externals
Build log was saved at "file://c:\Users\Mike\Documents\Programming Arena\CPP Arena\Libs\rbz\Tiny Ptc Ext\Debug\BuildLog.htm"
tinyptc_ext - Example - 7 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

When I choose Release, it succeeds.


I get this with other projects ive tried to compile via debug.
and, i was expecting it to be like FB / Blitz in that when you build afterwards it runs the program. In VS C++ does it only create a final exe, that you have to navigate to, to see what you've just coded?
Title: Re: [C++] Running A Program Under VS Express 2008
Post by: TinDragon on August 12, 2009
Since there linker errors that means that your debug config doesnt have the needed libs added to the linkers list, I suspect that rbz only added them to the release config if he supplied the .sln or .proj file with the code. You probably need to go to the properties/linker/input and add the additional dependencies to the debug config, you can look at the release one to see what you need. If there not shown there then they might be listed on the commandline part of the linkers config.

Blitz apart from bmax linked everything the language could do to the exe so you couldnt not have what you needed apart from your own media, bmax does unless you use framework then you have to tell it which modules to include and they contain the needed libs. freebasic they include the libs you tell it to when you include the .bi files from what i can tell, take rbz tinyptc_ext, it has lines like #inclib "mmx"  which tell fb's compiler that it needs to include the libmmx.a file when linking the final exe.
Title: Re: [C++] Running A Program Under VS Express 2008
Post by: hellfire on August 12, 2009
Quote
downloading and installing Visual Studio C++ 2008 Express
Good choice.

Quote
error LNK2019: unresolved external symbol _ptc_update referenced in function _main
Seems like you've got to add the lib in the debug-configuration.
Press Alt+F7, choose "Configuration Properties", "Linker", "Input" and add the filename of the library in "additional dependencies" (just compare with the settings in the release-configuration).

Quote
error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
Same procedure: Select "Configuration Properties", "Linker", "System" and set "Subsystem" to "Console".
This will open a console window along with your application. In development that's kinda handy for printing debug-output.
If you don't want the console just set "Subsystem" to "Windows" and replace
Code: [Select]
int main(int argc, char *argv[])by
Code: [Select]
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
Quote
when you build afterwards it runs the program
Just press Ctrl+F5.

Title: Re: [C++] Running A Program Under VS Express 2008
Post by: Jim on August 12, 2009
Quote
In VS C++ does it only create a final exe, that you have to navigate to, to see what you've just coded?
You can do both.  Press F5 to do a build and run - can't remember what the menu option is off hand.

Jim
Title: Re: [C++] Running A Program Under VS Express 2008
Post by: Clyde on August 12, 2009
thanks TinDragon And Jim :)

I did put in the Projects and solutions options, under VC++ Directories the location of the includes for tinyptc_ext found on my Hard Drive. I take it that, includes cover headers and object file Library's. ?

I was wondering if it was a Vista thing.
As I have tried the Dark GDK and that comes up with a link error for "dplayx.lib" on the projects ive tried.

I've downloaded the latest Direct X SDK ( March 09 ), and I opted not to install the stuff for web based stuff in the VS C++ setup.

Thanks again, I will now have a look in the release stuff, and try out f5.
Cheers, Clyde
Title: Re: [C++] Running A Program Under VS Express 2008
Post by: TinDragon on August 12, 2009
it's not a vista thing, i can compile in debug and release mode just fine, you just have to tell it what libs it needs and it will work. Since i dont have the tinypyc_ext files for c/c++ I dont know what it needs but rbz can let you know :)

Title: Re: [C++] Running A Program Under VS Express 2008
Post by: Jim on August 13, 2009
dplayx.lib is part of DirectX SDK.  You'd need to download that separately, then, following the help file that comes with that SDK, set the project folders in VS2008 'Tools, Options, Directories' appropriately.  (Mostly that means in the 'lib' section add an entry for the DirectX SDK lib folder, same for the include folder, then make sure they are first in the list by moving the entries to the top).

With the ptc stuff, put both the lib and the h file in the folder with the rest of your source.  It should easily find it then without setting up any paths, you just need to add the lib name to the 'Additional Dependencies' in the 'Linker' properties page.

Jim
Title: Re: [C++] Running A Program Under VS Express 2008
Post by: Clyde on August 13, 2009
Thanks Jim.

I allready have the direct x sdk, and it automatically set it into VS C++ 2008 Express SP1. It was dated March 2009. I'll look for the readme.

Havent found the Linker Options / Additional Dependencies.
I thought it was possible to treat the ptc stuff just like the SDKs / GDKs.
Title: Re: [C++] Running A Program Under VS Express 2008
Post by: hellfire on August 13, 2009
Quote
Havent found the Linker Options / Additional Dependencies.
See my post above.
Title: Re: [C++] Running A Program Under VS Express 2008
Post by: TinDragon on August 13, 2009
even tho the paths to the directx sdk includes and libs are set you still need to manually add the needed libs to the linker's inputs or it wont know what you want  ;)
Title: Re: [C++] Running A Program Under VS Express 2008
Post by: Clyde on August 13, 2009
Cheers hellfire and co.

I don't know what i am supposed to do once in the linker / dependancies, when I click onto the [...] it doesnt show paths or anything I recognize. Most readme's / tuts dont teach you this stuff, perhaps I need to buy a How To Use Visual Studio IDE For Dummies.
Title: Re: [C++] Running A Program Under VS Express 2008
Post by: hellfire on August 13, 2009
Don't click [...] and just enter the filename of the .lib in the line in front of it.
Title: Re: [C++] Running A Program Under VS Express 2008
Post by: Clyde on August 13, 2009
Thanks heaps dude, I doubt very much if I'd be making much progress without your help. Very much appreciated. Im so used to basic languages that do pretty much all of this for you.

Is the ALT+F7 linker-> input bits set globally for all projects? Meaning I need to change for each project so the exe doesnt include unwanted libs.

Thanks for your time and valuable help,
Clyde
Title: Re: [C++] Running A Program Under VS Express 2008
Post by: Jim on August 13, 2009
The project properties are specific to an individual project.  If you had more than one project in the solution, each of them could have its own settings.

Jim
Title: Re: [C++] Running A Program Under VS Express 2008
Post by: Clyde on August 13, 2009
this is bizarre i keep on getting can not find dplayx.lib and ive added it into the linker properties. I wonder if it's no longer present in the March 2009 version of the Direct X SDK.
This is with the DarkGDK, and i have followed the installation guide for setting the includes and libraries. which refers to the DX SDK for August 2007.
Title: Re: [C++] Running A Program Under VS Express 2008
Post by: hellfire on August 14, 2009
Seems to be a known problem (http://forum.thegamecreators.com/?m=forum_view&t=118764&b=22)...
Title: Re: [C++] Running A Program Under VS Express 2008
Post by: TinDragon on August 14, 2009
I never installed the darkgdk because it required the old dx sdk, that and because its more or less a wrapper of the darkbasic langauge which I hated the syntax for  :D
Title: Re: [C++] Running A Program Under VS Express 2008
Post by: Clyde on August 14, 2009
Im not bothering with the Dark GDK, as like you say it uses an out of date version of Direct X, plus even though I did find a download of dplayx.lib, lots more conflicts.