Visual C++ 2003 compiler (free)


#1

Hi,
I’m starting to learn C++ and this seemed a good compiler to start with (I’ve since then downloaded DevC++, but I wanted something that could compile plugins for maya)

But helloWorld doesn’t even work! Wtf?

(i’m doing this from memory, so excuse an syntax flaws. blame the book if anything)
#include <iostream.h>

void main() {
cout << "Hello World!.
";
}
On compiling, the compiler complains about not being able to find the iostream.h file. I imported the file from a student copy of codewarrior i have, but then it asked from x.h, then y.h then z.h …
I read somewhere that iostream was removed from the VC++ 2003, and this seems to be true. There is no iostream.h file, though there is an iostream file (no extension). How was it replaced?

Also, where can i get the windows sdk library? The links to that seem to have broken and it doesn’t seem to be available through searching the site.

Finally, using DevC++ any declaration of main() must have an int type or something of that nature. It throws an error compiling if void main() is used. Am I doing something wrong, or is this a “feature”?

Thanks


#2

to compile plug-ins for Maya 5.0 on WinXP you’ll need MS VC++ 6.0 - read the API documentation :

developper -> plug-in -> setting up a build area.

things may have changed for Maya 6.0, i don’t have it handy to check. to cut a long story short : you have to set the include paths as well as the library paths properly in your makefile (aka MS project file junk)


#3

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore/html/_core_differences_in_iostream_implementation.asp

Also, where can i get the windows sdk library?

The MSDN library? Same link as above.


#4

thx.

I’ll look into the makefile. That was also throwing an error in DevC++.

And yes, the compiler is updated for Maya 6. I’m not sure if I have the correct compiler though, because I haven’t gotten as far as Maya’s API docs yet.


#5

unless something radical happened at AW - you’ll need MS VC++. i don’t think there’s any other compiler out there that’s symbol compliant so i doubt you’ll be able to link against the API DLL’s with devC++ or gcc or icc. check the Maya docs where i pointed (they changed the layout for 6.0 so i don’t have a handy link for that either)


#6

iostream.h is not part of the C++ standard. It was something temporary being used as the standard was developed (both by microsoft and gcc). All the new standard C++ headers do not use any extension.
Thus, you would have to include <iostream> instead.
In the case of microsoft, with their change of libraries, they in generally broke backwards compatability in a number of areas, so you may have trouble compiling against older programs that use old headers while you are using the new libraries and viceversa.
The microsoft abi for linking dlls and similar, afaik, has remained compatible so far.
If keeping backwards compatability with other older programs is important to you, you might consider buying (ie. not free) Dinkumware libraries, from:
http://www.dinkumware.com/
Dinkumware is Microsoft’s provider of STL libraries and provide libraries that tend to work around these issues and are compatible across all of microsoft’s compilers and older code.

For the microsoft compiler, C++ standard headers and STL library, you can download them from:
http://msdn.microsoft.com/visualc/vctoolkit2003/
This will allow you to create programs that do not rely on any windows API calls.

For the windows API, you also need to download:
http://www.microsoft.com/msdownload/platformsdk/sdkupdate/

Note that downloading all that will still not give you all the features available in the commercial MSVC suite (mainly the whole visual IDE will be missing, so you will be mainly working from the command-line and I am not sure if the whole microsoft documentation is included, either). If you are developing something commercial, you may also want to read the licensing to see if they are any gotchas.

Yes, you are doing something wrong. The C and C++ standard REQUIRE main returns an int.
The microsoft compiler has been non-compliant with the standard for years and actually allows using “void main()” which has led to the proliferation of that idiom. If you are developing programs that work across platforms, you should stick to the standard and avoid things such as that. The DevC++ compiler is standard-compliant and as such, it should reject that construct.
In general the Microsoft documentation (at least that included in the commercial products) is pretty good in telling you what is and what isn’t part of what standard.

In terms of writing libraries for other programs that are not compiled with open source compilers, it usually gets tricky to do so. If you go down that path, be ready for a lot of gotchas. Check out the mingw (the compiler used in devc++) and gcc (the compiler mingw is based from) faqs/documentation for some approaches.


#7

Aside from the above mentioned remedies, you’re refrencing an object that doesn’t exist in the global namespace.

“cout”, and “cerr” (standard out, standard error) both require “std::” to be prefixed to them, unless you placed a “using namespace std;” above your main function.

So, to make a simple hello world programme, you would implement:


#include <iostream>

int main()
{
  std::cout << "Hello World!" << std::endl;
  return 0;
}

P.S. Newer standards of C (C99) discourage a non returning main function, but not all compilers are up to snuff in the standards department. ie ( http://www.eskimo.com/~scs/readings/voidmain.960823.html & http://experts.about.com/q/1040/3238045.htm)


#8
 #include <iostream>

int main()
{
  std::cout << "Hello World!" << std::endl;
  return 0;
} 

What he said. Half-assed, MS C++ doesn’t work anymore. Too bad it took them 5 years to get the STL implemented correctly. :stuck_out_tongue:

Start brushing up on your namespaces and data-structures guys, MSVC 6 is like the old man at the bar. Someday he’ll get the hint and stay away next Saturday night. :wink:


#9

Wow, thanks everyone. That’s a lot of great info.

I’ll have to chew through that.

And another question. I was looking through the Maya API docs last night, and one of the requirements for compiling is linking to the STL files, something that is apparently easy to do with the VC++ IDE, just drag and drop. But in the command line version of the compiler, no such option exists. Is there anyway to include these files, or am I just going to have to give up and spring the $$$ for VC++?


#10

Feh – And their parser is stupid as well. All of my templates look like:

std::pair< int, std::deque< const char * > > 

Notice the spacing between the last “>” characters? Dumb VisualStudios 6 thinks that you’re using the “>>” operator if you omit the spaces.

Oh, and check out this nice work-around that you have to use when using VS6 (from http://www.boost.org/libs/graph/example/dijkstra-example.cpp):

if defined(BOOST_MSVC) && BOOST_MSVC <= 1300
  // VC++ has trouble with the named parameters mechanism
  property_map<graph_t, vertex_index_t>::type indexmap = get(vertex_index, g);
  dijkstra_shortest_paths(g, s, &p[0], &d[0], weightmap, indexmap, 
                          std::less<int>(), closed_plus<int>(), 
                          std::numeric_limits<int>::max(), 0,
                          default_dijkstra_visitor());
#else
  dijkstra_shortest_paths(g, s, predecessor_map(&p[0]).distance_map(&d[0]));
#endif 

#11

not necessary, you just have to find a free implementation of the STL. Link to it’s headers and library files as options for the compiler and you should be all set.

-b


#12

I recommend the free STL implementation called STLport.

I don’t remember if the Maya API exposes anything that depends on STL. If it does, then you might get into trouble because you need to use the same STL libraries and headers they use. But I seem to remember the API uses mostly home-grown classes rather than STL. In that case you only need the STL stuff if you are using it in your own code.


#13

Doesn’t DevC++ come with the STL header files? The full install of DevC++ installs gcc 3.3.1 with all of the bells and whistles.


#14

You can use MSVC 7.1 to compile plugins for maya 5 - it’s just not supported. We decided to use 7.1 because it seemed that MS finally got the STL and templates right, and we do a lot of development on linux, so having a standards compliant compiler saves a lot of time in the long run.

There are 2 basic things to do to get around the iostream problems. The first is to define REQUIRE_IOSTREAM in the project file, which will let you use the new iostream instead of the old iostream.h. Alias says that this will only work for linux, and they’re mostly right, but with a little extra work you can get it going in windows as well.

The second thing to fix is that if you’re handed an iostream pointer, it’ll be an old (iostream.h) pointer, not a new (std::iostream) pointer. But your program will think it’s a new one, and will segfault when it tries to do anything with it. This only really happens when you’re saving something to a file or reading from a file, and the file handle is passed to you from maya. I’ve got a workaround for this, where the basic idea is to convert from old streams to new strings, and compile that as a library using a version of vc++ that has the old iostream.h. I’d post it now, but I don’t have it handy… let me know if you’re interested.


#15

I’d be very interested to see how you do this.


#16

For most of my plug-in work I’ve found that Visual C++ 6.0 seems to work the best. I write Director MX and After Effects plug-ins and have had few problems. I’ve dabbled with the Cinema 4D XL API as well.

All the extra “baggage” added in later versions of Visual Studio/C++ are geared more for internet apps and Microsoft’s somewhat biased vision.

Visual C++ 6.0 is the ticket IMHO


#17

Visual C++ 6.0 is the ticket IMHO

dont be silly, VC6 can’t compile maya6 plugins. vc6 is definately NOT the ticket. You could use the VC 2003 toolkit with the VC6 IDE, but, err… the vc6 IDE is nasty. I’m using the free VC2005 beta IDE, it’s a lot less bloaty than the full 2002 IDE, and with the 2003 compiler underneath it optimises things quite nicely…

Right then, to you lot who are moaning about STL being in-compatible with the maya API, you are all wrong (or doing something really wrong?). This occurs because you have compiled your plugin (or a lib it is using) with the single threaded runtime libs. Change all of them to multi-threaded and the linker problems go away. (do this in the project settings->C/C+±>Code Generation settings).

The older versions of maya used to use the old non-conformant <iostream.h> headers, but other than a few depreceated warnings this never caused me any problems (well, been using the API for 6 years and i’ve never had an STL problem? ).

you can use VisualC++ 2002, 2003 Toolkit, Visual C++ 2005 express beta, or codewarrior to compile maya plugins. The process is always the same, ensure they are compiled as a dll, change the output extension to mll, make sure you are using the multi-threaded libs, and ensure that you export the initializePlugin and uninitializePlugin methods (either put, __declspec(dllexport) infront of the funcs, or use the linker options /export:initializePlugin /export:uninitializePlugin.

Under linux, compile the plugins with the -shared flag, and output a .so file. that should be it…

Quote:
Originally Posted by Goon

And another question. I was looking through the Maya API docs last night, and one of the requirements for compiling is linking to the STL files, something that is apparently easy to do with the VC++ IDE, just drag and drop. But in the command line version of the compiler, no such option exists. Is there anyway to include these files, or am I just going to have to give up and spring the $$$ for VC++?

not necessary, you just have to find a free implementation of the STL. Link to it’s headers and library files as options for the compiler and you should be all set.

err? Visual C++ 2003 comes with the latest version of STL? I think your problem here has nothing to do with STL, what you basically seem to be asking is how to link and compile using the VC++ command line.

The answer is, not easily. Basically you have 2 options,

  1. install cygwin and use make to call cl.exe (compiler) to compile each source file, and then use link.exe to link the plugins. (nmake is not included in VC 2003 toolkit)

  2. Use visual C++ 2005 beta (free download) and download the microsoft Platform SDK, set the paths up to the VC++ compiler’s libs / includes and exe’s, and your away. Could even use the VC2005 compiler (it does the job - though you may still need the platform SDK for a few bits and bobs like OpenGL). I’m using the beta at the moment and it seems fine (one or two minor glitches in it, but they are only minor…)

The second thing to fix is that if you’re handed an iostream pointer, it’ll be an old (iostream.h) pointer, not a new (std::iostream) pointer. But your program will think it’s a new one, and will segfault when it tries to do anything with it. This only really happens when you’re saving something to a file or reading from a file, and the file handle is passed to you from maya. I’ve got a workaround for this, where the basic idea is to convert from old streams to new strings, and compile that as a library using a version of vc++ that has the old iostream.h. I’d post it now, but I don’t have it handy… let me know if you’re interested.

pardon? err, surely this can only occur if you do something like

using namespace std;

within your code to re-introduce the naming clashes that std:: was supposed to remove?. The answer might be, don’t remove the std:: ? I cannot honestly see any other reason why you are segmenting there? since the istream && std::istream classes are different, the compiler should prevent you doing this at compile time (well, it always has for me anyway…)


#18

ok. thx.

I’m not sure I know enough to do option 1, so I’ll give the VC++ 2005 beta a go.

And you said codewarrior can compile maya plugins as well. Does this need to be the newest version (4.0?) or could I use my old student version of 3.0?


#19

Okay, finally got around to attaching that io gateway library. Hopefully it’s useful to someone.

It looks like I can’t post attachments, so here’s the link.

To use:
Compile in MSVC 6. It’ll drop io_gateway.lib. Add that lib file, as well as MSVC 6’s LIBCI.lib and LIBCID.lib (for debug, if you want it) to the link of your MSVC 7.1 project.

Here’s an example of me using it in practice… TSplineData inherits from MPxData.


 MStatus TSplineData::readBinary( std::istream& in, unsigned length )
 {
 	std::istringstream readme;
 
 	char *buffer = new char[length];
 #ifdef USE_IO_GATEWAY
 	if (!oldStreamToBuffer( &in, buffer, length ))
 	{
 		return MS::kFailure;
 	}
 #else
 	in.read( buffer, length );
 	if( in.bad() )
 	{
 		return MS::kFailure;
 	}
 #endif
 	{   // This is just some scoping.
 		string allinput( buffer, length );
 		readme.str( allinput );
 	}
 	delete[] buffer;
 	 ...
 	  Actually read the data..
 	 ...
 }

The reason for the #define is so that I can use the same code for maya 5 and maya 6.

Let me know if you guys have any questions…


#20

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.