Author Topic: [C++] Running A Program Under VS Express 2008  (Read 12054 times)

0 Members and 1 Guest are viewing this topic.

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
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.
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

Offline TinDragon

  • Pentium
  • *****
  • Posts: 644
  • Karma: 24
    • View Profile
    • J2K's blog
Re: [C++] Running A Program Under VS Express 2008
« Reply #1 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.


Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: [C++] Running A Program Under VS Express 2008
« Reply #2 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
Challenge Trophies Won:

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Re: [C++] Running A Program Under VS Express 2008
« Reply #3 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.
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: [C++] Running A Program Under VS Express 2008
« Reply #4 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
Challenge Trophies Won:

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Re: [C++] Running A Program Under VS Express 2008
« Reply #5 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.
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: [C++] Running A Program Under VS Express 2008
« Reply #6 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
Challenge Trophies Won:

Offline hellfire

  • Sponsor
  • Pentium
  • *******
  • Posts: 1294
  • Karma: 466
    • View Profile
    • my stuff
Re: [C++] Running A Program Under VS Express 2008
« Reply #7 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.
Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: [C++] Running A Program Under VS Express 2008
« Reply #8 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
Challenge Trophies Won:

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Re: [C++] Running A Program Under VS Express 2008
« Reply #9 on: March 21, 2009 »
Thanks fellas :)
Im doing all this inside VS Express 2008.
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Re: [C++] Running A Program Under VS Express 2008
« Reply #10 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?
« Last Edit: August 12, 2009 by Clyde »
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

Offline TinDragon

  • Pentium
  • *****
  • Posts: 644
  • Karma: 24
    • View Profile
    • J2K's blog
Re: [C++] Running A Program Under VS Express 2008
« Reply #11 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.
« Last Edit: August 12, 2009 by TinDragon »

Offline hellfire

  • Sponsor
  • Pentium
  • *******
  • Posts: 1294
  • Karma: 466
    • View Profile
    • my stuff
Re: [C++] Running A Program Under VS Express 2008
« Reply #12 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.

Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: [C++] Running A Program Under VS Express 2008
« Reply #13 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
Challenge Trophies Won:

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Re: [C++] Running A Program Under VS Express 2008
« Reply #14 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
« Last Edit: August 12, 2009 by Clyde »
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

Offline TinDragon

  • Pentium
  • *****
  • Posts: 644
  • Karma: 24
    • View Profile
    • J2K's blog
Re: [C++] Running A Program Under VS Express 2008
« Reply #15 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 :)


Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: [C++] Running A Program Under VS Express 2008
« Reply #16 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
Challenge Trophies Won:

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Re: [C++] Running A Program Under VS Express 2008
« Reply #17 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.
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

Offline hellfire

  • Sponsor
  • Pentium
  • *******
  • Posts: 1294
  • Karma: 466
    • View Profile
    • my stuff
Re: [C++] Running A Program Under VS Express 2008
« Reply #18 on: August 13, 2009 »
Quote
Havent found the Linker Options / Additional Dependencies.
See my post above.
Challenge Trophies Won:

Offline TinDragon

  • Pentium
  • *****
  • Posts: 644
  • Karma: 24
    • View Profile
    • J2K's blog
Re: [C++] Running A Program Under VS Express 2008
« Reply #19 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  ;)