Visual Studio is stupid

Associate
Joined
10 Oct 2008
Posts
353
Location
Dundee
Visual studio is annoying me SO much.
I am behind on programming coursework for uni and there are about 30 trillion errors when I try to compile anything even remotely relating to opengl with dev c++ (yes I sorted the linkers and followed all possible reasons as to why it won't work). So, I try to use the same program as the uni = visual studio 2008. I get a free license with dreamspark, install...
simply past:
Code:
#include <windows.h>

int WINAPI WinMain (HINSTANCE hInstance, 
				HINSTANCE hPrevInstance, 
				PSTR szCmdLine, 
				int CmdShow)
{
	MessageBox (NULL, "Hello World",  "HelloMsg", MB_OK);
	return 0 ;
}
into a new file in visual c++ and try to compile it... Oh wait, there is no compile button. WHAT.
So, I do all the usual junk by making a "project" then put my "solution" inside it. Then I make a "new cpp file"... ok, now it adds about 40 thousand header files, precompiled libraries and all sorts. So I delete all that and start again and specify for a "win32 c++ project" (because apparently everything else needs loads of junk in it).

Now I am asked if I want a Windows application, Console application, DLL or Static Library. Well, I guess it's a windows application (thought I want to start from scratch) because once I have tested that code above I am going to make a windows class (in code, no RAD junk that VS seems to insist upon). Please, just make an empty project. I did certainly tick the box - (though precompiled header is forced on).

OK, empty project,
file>new>file...
.cpp, open...
paste in the code above^
build>build test2.

Then low and behold:
1>------ Build started: Project: test2, Configuration: Debug Win32 ------
1>Embedding manifest...
1>.\Debug\test2.exe.intermediate.manifest : general error c1010070: Failed to load and parse the manifest. The system cannot find the file specified.
1>Build log was saved at "file://c:\Users\Administrator\Documents\Visual Studio 2008\Projects\test2\test2\Debug\BuildLog.htm"
1>test2 - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

What is this manifest junk? Even devc++ got this far without any issues at all.
The only things I have even come close to actually compiling in vs are console applications, with great difficulty.

What is this manifest mumbo jumbo? I just want to compile a plaintext file containing some c++, why is that so difficult? Is there any way to get this piece of rubbish application to actually just work for some basic test programming, or a very simple - 1 file - program.

And what are these stupid files it makes in the "solution" and "project"
test2.ncb
test2.sln
test2.suo
test2.cpp
test 2>
--test2.vcproj
--test2.vcproj.Cupid.Administrator.user
--debug>
----BuildLog.htm
----test2.exe.embed.manifest
----vc90.idb
----vc90.pdb

So, I get a little farther - remembering to rename my source file to test2.cpp because VS compiles the solution not the source file (which you can't just have on its own)
I get this stupid error now:
c:\users\administrator\documents\visual studio 2008\projects\test2\test2.cpp(8) : error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [12]' to 'LPCWSTR'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
No, simply no.
There is not an error there, any real compiler would be ok with that. What the hell are Microsoft doing? Can somebody slap them for me?

Is there any actual way to do some simple, single source file, programming in VS08? Nothing ever works in the piece of junk. They always think you are trying to make a massive industrial suite of programs - simply NO.

/rant
 
In short, no. VS is not really designed for single source file compiling. It is aimed at larger projects with loads of files, different build types etc.

As for 'const char [12]' not being the same as 'LPCWSTR', it is right. Wide Character strings are 16bit not 8bit.
 
Hi Bozedo, sadly there is an error in your code.

When you create a new project in VC++ it automatically defaults to unicode so the function MessageBox is redirected to MessageBoxW via a define. The string you are trying pass in is an ANSI string when the compiler is expecting a wide string so you either need to preappend an L or wrap it in the _T() marco. So this should work just fine:

PHP:
#include <windows.h>

int WINAPI WinMain (HINSTANCE hInstance, 
				HINSTANCE hPrevInstance, 
				PSTR szCmdLine, 
				int CmdShow)
{
	MessageBox (NULL, _T("Hello World"),  _T("HelloMsg"), MB_OK);
	return 0 ;
}

VC++ can be confusing, especially with the whole string thing but lots of people struggle with it.
 
Hi Bozedo, sadly there is an error in your code.

When you create a new project in VC++ it automatically defaults to unicode so the function MessageBox is redirected to MessageBoxW via a define. The string you are trying pass in is an ANSI string when the compiler is expecting a wide string so you either need to preappend an L or wrap it in the _T() marco. So this should work just fine:

PHP:
#include <windows.h>

int WINAPI WinMain (HINSTANCE hInstance, 
				HINSTANCE hPrevInstance, 
				PSTR szCmdLine, 
				int CmdShow)
{
	MessageBox (NULL, _T("Hello World"),  _T("HelloMsg"), MB_OK);
	return 0 ;
}

VC++ can be confusing, especially with the whole string thing but lots of people struggle with it.

thanks mate thats fixed it.

I still HATE visual studio though :D it is very bloaty.

is there a way to use the compiler directly, from the command line say?
 
There is a way, when you install VS it even provides a command prompt link to the VS directory. I think the command is 'cl' but I don't have anything to hand with which to test.
 
As has been said, VS is intended as a large, collaborative dev environment. It is not really intended for people who are just doing Hello World.

You will probably find lots of code examples on the web or indeed full libraries, won't compile under MSVC directly either, normally I find it is because of some odd allowances that GCC makes, meaning any code made for Unix and GCC compiles fine for the author, but under MSVC requires some fettling to make it more compliant.

Once you start making bigger projects using MSVC, you will come to really appreciate its complexity i think, but while you are still just starting out, theres no doubt it can be frustrating to use at times.

Tip for the future as it's likely you will come across this, if your intellisense ever stops working. Close VS, go to your projects folder, delete the large ".ncb" file and re-open the project. This will re-build the database. I only mention this as for some reason VS does like to occasionally corrupt its own intellisense database and it can be quite annoying ;)

What you're *really* going to love is debugging OpenGL code! It has its own error catching mechanism, but many people dont use it properly. As far as C++ errors go, the majority of bugs caused by the OpenGl library will be returned to you quite simply as a memory allocation error or hard crash (unless you have handled and caught it correctly in your OpenGL code.) Still it's very satisfying when you suddenly get this complex 3D thing popping up for the first time :)
 
thanks mate thats fixed it.

I still HATE visual studio though :D it is very bloaty.

is there a way to use the compiler directly, from the command line say?

Sorry I got your name wrong, new here and that's not a good start :P

You can build VC++ from the VS cmd prompt but it's a ball ache tbh. You have to then link it yourself and the VC++ project files contains lots of settings and switches that you need for Windows stuff, which you would have to manually enter as parameters to the compiler and the linker.

If you're building a full Windows app and ATL then may be it's worth learning. You can start a new project for a Win32 console app and in the wizard turn all the options off, this will give a nice easy to build project. As mentioned above really try NetBeans/Eclipse with GCC, most of the books I've read have samples that are easier to get to work under GCC.

VS is a bit of beasty, although I'm led to believe the express versions do reduce some the clutter and make more beginner friendly.
 
Still it's very satisfying when you suddenly get this complex 3D thing popping up for the first time :)

Reminds me when I dabbled with programming in Uni. We had to write an online booking system for a car rental place. Easy stuff for most of the folks on here. Also, if you couldn't find that car you wanted, it had to have a search function to see if the car is available from your other 6 branches. So basically a UI built ontop of a SQL database. I must've wrestled with that for 3 weeks. I kept building in silly little things like reviews of the cars, search strings, etc. When it finally compiled right (after 6 hours of debugging) it was like my child being born. The most amazing feeling. :D
 
IMO VS is the best IDE going but i haven't really dabbled with VC++. I personally use Notepad++ at work for ANSI C programming as although it lacks a lot of the intellisense like features you get in VS and other IDE's it is faster and just as helpful for layout and organisation of your code. Plus if you really want to learn to code staying away from helpful IDE's is a good way to start as it makes you more aware of silly little errors you make which some may fix for you.
 
If you've got a Visual Studio project file to hand, you can build it from the command-line using vcbuild and/or msbuild (depends on a few factors including which version you've got). Otherwise, cl will do the trick (but can be a ballache if you're compiling anything more than single-source with no libraries).

Visual Studio is rather bloated for a single source tool, but it will do the job just fine. And for a newcomer should be quicker than trying to DIY it with a text editor.

PS - don't worry about the manifest stuff. Mostly Visual Studio just does it right. The fun starts when you want to roll your own custom manifests (which I've done).
 
I have been using C++ for over a year. It's just I was always sticking to standard libraries and using dev c++, mostly I made cli programs and dabbled in SDL a bit to learn. It's just that the example code provided by the uni only works in VS, and apparently it should just compile :/ but it only works the way they have it set up in the uni and that means getting up every morning at 7:30 and waiting for a bus in the cold/ran/snow :D

If I could get it running here i'd have powered through the whole module by now.

I may try to find a specific opengl tutorial written for devc++. Or set up a dual boot with linux and do it through that - though I can never get my gpu drivers working on linux. (old computer will do perhaps)

edit: no sratch that then I have to figure out a way to do it without the windows api like I'm being taught.
 
Last edited:
I'm not 100% sure how their setup can be any different from yours.

Looking at the code you posted, you are doing very simple Visual C++ OpenGL stuff. This is where the Windows dependancy comes in of course (but you know that), however the code itself will work on any Windows based MSVC compiler. The only thing that could be setup any differently at your uni is the location of the OpenGL libraries. However, in that "hello world" app you posted, you arn't even linking any of those, quite literally just "windows.h" which is an entirely standard library available in any MSVC installation.

As has been said, the only difference may be the default encoding has been altered on your uni installations. However, given changing that on your install literally means clicking two or three buttons and pressing "apply", it shouldnt be too hard to mirror their setup on your projects.

TBH, dependng on the intended learning outcomes of the module, it may well be that you are expected to become familiar with the windows API, as lets face it, much 3D work is done in a Windows environment. Code produced to work in Linux will be different to the expected norm for your course in that the GUI API you use will supply the same information differently. The GL code will be the same of course.

Personally I'd get things working at home, you're going too want to do some of your course outside of the uni at some point. MSVC really isn't the monster you are making it to be. Try using something like JBuilder then come and tell me MSVC is bad ;) At least, unlike Eclipse, MSVC isn't written in Java so it doesn't make your brand new quad core machine feel like it is woefully underpowered...

Similarly, when you have 10+ classes or are required to outline your code as UML or present class diagrams, come and tell me that using a simple command line interface is sufficient :) Theres a reason all large dev companies (and small ones) use good dev environments rather than just compiling at the command line and it has to be said, many use MSVC. Better to get used to it now while still doing simple programming excercises.
 
Pretty much agree with all the above. There's not much that can go wrong with VS 2005/2008 installations (so long as you select everything you need in the installation). 6.0 was a whole different problem, but if you're using something that old, you aren't at Uni. :)

It's possible they are using an SDK on top of Visual Studio. These will probably show up in the Windows Start Menu or Visual Studio About Box. If they are, it's a matter of downloading and installing.
 
Back
Top Bottom