Where can I get the Active Template Library? - atl

I've never worked with COM before, and I've been tasked with writing an application that uses some third party COM objects. If anyone could point me to some good tutorials on how to use them it would be much appreciated. More immediately, it appears that I don't have the Active Template Library installed. I've searched online but can't figure out how to get it.

As Dan pointed out, these are distributed with Visual Studio.
If you don't have Visual Studio, you can get the ATL libraries from one of the Microsoft Visual C++ Redistributable packages:
2005 SP1 (32-bit)
2005 SP1 (64-bit)
2005 (Itanium)
2008 SP1 (32-bit)
2008 SP1 (64-bit)
2008 SP1 (Itanium)
Note: The ones marked 2005 are version 8 (atl80.dll), the ones marked 2008 are version 9 (atl90.dll).

It's part of Microsoft Visual Studio (but not the Express Edition.)

I think you have to own a copy of Visual Studio 2005 or 2008 (not Express) to get ATL. If you have one of those installed, but you don't have ATL then go to "Control Panel:Add/Remove Programs" and do a "Modify" install (with the program CD or DVD in the drive) and make sure the box for ATL is checked.

As for tutorials:
I haven't found a really good one online. There are a few OK pages on using ATL/COM:
The Active Template Library Makes
Building Compact COM Objects a
Joy by Don Box (veteran guru of
COM). This article starts: "I love
COM. COM is good. Like a fine pilsner
or ale, COM never disappoints. In
fact, the more I look at COM, the
more I like it. Unfortunately, I work
in C++, and C++ does not share my
appreciation for the finer things in
life." Despite the Grand Master's
proselytizing, and the fact that it's
12 years old now, it's a pretty good
article...
Mike Dunn's excellent tutorial on
COM on CodeProject.
DevGuy's C++ COM Tips -- kind of a hodgepodge of links and suggestions.
The COM Programmer's Cookbook -- this ancient (1995) article isn't bad, despite its age and the fact that it describes implementing COM objects in C rather than C++ (explicit vtables!)
I'm a little rusty myself w/ COM and ATL, but if I remember right, the classes you're going to want to learn that you'll use the most (especially if you are using someone else's COM objects rather than implementing your own) are CComBSTR, CComPtr, and CComVariant. Also the #import statement in Visual C++ makes using external COM objects much easier, it generates a smart pointer class for you from an external DLL or EXE.
If you're going to be implementing COM objects, I would strongly recommend getting a copy of ATL Internals (there's a newer edition out now covering ATL v8). Yes it does go into some gory detail in sections, but even as an intro book it's fairly well written.
If you've never used COM before, the "classic" books Essential COM and Effective COM are very good and you can probably get them inexpensively from your favorite sources of used books. You're also going to want to be very familiar with the RAII idiom, if you aren't already.
The newsgroup microsoft.public.vc.atl is very good for asking particular questions. (they tend to be more gruff there than on StackOverflow, though)
Beware: There are lots of little gotchas with COM, although ATL does help it become a lot easier & without a lot of bloat. The "simulated dynamic binding" techniques aka CRTP are useful in the C++ world, not just in the context of ATL/COM but especially if you are developing a library of reusable classes that you want to subclass or mixin in situations where only one instance is present at a time (e.g. a class CSpiffyFramework that provides mixin functionality that you want to reuse a lot, and you have a derived class that you want to include that functionality, and it's not part of a virtual object model so you don't really need a vtable).
Good luck!

I installed this: http://www.microsoft.com/en-us/download/details.aspx?id=3138 and got the C++ compiler and all stuff on my buildserver, but no ATLMFC libraries.
The redist packages linked above is just that, redistributables, not the headers and includefiles needed..
After lots of searching, I ended up installing vs2008 on the server, crap.

here is how to use atl with vs express:
you need WDK 7.1.0:
https://www.microsoft.com/en-us/download/details.aspx?id=11800
Download Visual Studio Express Edition
Get VS Express C++ free from Microsoft
Download the freely available Windows Driver Kit (7.1 or later) from Microsoft
Get WDK 7.1.0 free from Microsoft
You can mount the ISO file with Virtual Clone Drive or extract it with 7-zip.
Install the WDK and select the "Build Environments" option
This will install the ATL and MFC header and lib files. ATL is a requirement for FireBreath on windows. Make sure to install this in the default location so that FireBreath can find it
For VS Express 2010
If you are using an older version of FireBreath, this post by scjohn may be useful for you. Note that FireBreath 1.4 beta 1 and later these steps are no longer needed!
http://www.firebreath.org/display/documentation/Building+with+Visual+Studio+Express
[vs2010 express include path]
C:\WinDDK\7600.16385.1\inc\atl71
[vs2010 express lib path]
C:\WinDDK\7600.16385.1\lib\ATL\i386

Related

Best alternative for Visual C++? VS11 Express can't be used to write desktop apps

Some of you might already know that Microsoft is trying to kill desktop development in favor of Metro style apps. The express editions of the new Visual Studio 11 will only support writing Metro style apps. They also won't give you the new compilers as part of the new Windows SDK. The only way to get the compilers is to buy Visual Studio Professional or higher.
Now it's time to find an alternative (alternative compilers for the Windows platform). Any suggestions?
Some links that are related to this issue:
http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/2645679-visual-studio-11-express-on-windows-7-and-the-abil
http://blogs.msdn.com/b/visualstudio/archive/2012/05/18/a-look-ahead-at-the-visual-studio-11-product-lineup-and-platform-support.aspx
http://www.microsoft.com/visualstudio/11/en-us/products/express
Gcc/G++ of course. In my opinion it is superior to VC++. In addition, you can use Eclipse CDT as IDE, it is quite usable at the moment (compared to older versions). I work like that on Windows. In addition, you can also work on Linux or MacOS without having to switch to another tool.
1) The Metro and WinRT features are accessible from C++/CX which in turn is built on top of COM, so according to this detailed discussion (SO question on WinRT and C) you can use the latest "Microsoft-only" features with any decent C compiler. Of couse this will require some code generation or just a lot of typing to get the access to basic facilities. I believe there would be a transition period and then the open-source community comes up with some automated solution to consume the WinRT APIs.
2) A quick list of available options right now.
Dev tools: MinGW or Cygwin (GCC toolchain + unix-like tools), Clang maybe, OpenWatcom as a thing from the past
GUI Libraries: FLTK, Qt, wxWidgets, Fox GUI toolkit, librocket (if you are into the OpenGL world)
IDEs: Code::Blocks, Eclipse+CDT, QtCreator
3) There's also a non-C++ way:
The FreePascal+Lazarus to allow Delphi-like RAD
Mono/SharpDevelop
Both options can use C++ code with some bindings.
4) Conclusions
These are the alternatives which give similar results but not always the similar level of comfort.
Yet another possibility would be Qt Creator, which comes with a full toolset targeting Windows (as well as MacOS, Linux, and Symbian). It is definitely somewhat different from VS, so it takes some getting used to, but overall I'd rate it as pretty decent. Qt (the library) generates somewhat mixed feelings -- some dislike its oddities (E.g., MOC), but quite a few consider it the best designed GUI toolkit available.
Don't forget the Netbeans GUI which is also available for windoze. It works great, just install mingw and choose this mingw/bin directory for the compiler tools and mysys/bin/make.exe as the make program
to download
https://netbeans.org/downloads/index.html
they have this plugin for vc++
http://plugins.netbeans.org/plugin/42519/vcc4n-visual-c-compiler-for-netbeans
some install info
https://netbeans.org/community/magazine/html/03/c++/
Another IDE that I havent used but looks good is
http://www.codeblocks.org/

Learning C++, What's next? Also what's a recommended compiler?

I've been spending my "inbetween" time at the office looking into C++. I'm primarily a flash & web developer, also working on a bunch of flash games, but I thought it was time to have a look at some non-web-based languages and see if I could get some real games going.
I've got the hang of how typing works, arrays, outputting using cout, structs, classes and so on and so on.
I seem to have found myself stuck in terms of what I can do next. Outputting to a DOS window obviously isn't that exciting - how do I get started on doing something graphical? A square moving around on the screen, even. Simple is better in this case.
As for the compiler - I've been using devcpp by Bloodshed; is this adequate or am I missing a more common compiler somehow?
Graphics can be done using DirectX in Windows, or OpenGL on every platform. It's a whole different discussion upon which to choose.
In addition to trying to work with graphics, you could try your hand at developing GUIs. I'd give Qt a shot. Be warned though, Qt is being sold by Nokia, but it's overall a very well known and heavily used framework. Or try direct Win32 (not necessarily something I'd suggest unless you're interested). Or try WinForms (requires .NET experience, and steals from the true C++; C++/CLR is NOT the same C++ you are learning--it adds to it). If you do go the .NET route, avoid "Managed C++" examples, as they that was the first iteration of C++/CLR, and they simply redid it and vastly improved it.
Two most common compilers: gcc (Linux, Mac and Windows) and Visual Studio's for development on Windows', I always use Visual Studio (there is a free version called Visual Studio Express that is a solid product) for Windows development simply because I love the IDE.
For a compiler, my school uses g++, an excellent, free C++ compiler that is compatible with many IDEs for unix-based C++ development. If you're running a windows machine, you'll have to download cygwin (which emulates a linux shell) - you'll have to select which executables you want to download with the cygwin shell, figuring out what items you need may take a little time (basically, download useful looking things for the type of development that you want to do; g++/gcc are very important).
http://cygwin.com/install.html
When you have this, you can easily configure netbeans or eclipse (I've had better experience with netbeans) to compile and run your C++ code through cygwin.
Also, my favorite resource for learning C++ has been cplusplus.com - it has detailed tutorials of all of C/C++'s standard functions.
Hope this helps a little!
Have a look at graphics and windowing libraries. For windowing, as you seem to be on Windows, there's builtin stuff. For more general applicability I suggest having a look at Qt or Gtk.
For graphics, the fancy stuff is usually done in either DirectX (basically Windows only) or OpenGL (more portable).
Compilers: GCC is commonly used in the Unix/Linux world and also available on Windows through Cygwin. In the Windows world you'll also find Microsoft's MSVCC as it comes with their development tools. Btw., there are free dev tools from Microsoft as well, see their Visual Studio Express Editions.
Some tips:
Work through one or more good books. I recommend "Accelerated C++" and "Effective C++". These books will teach you real C++ programming.
If you're on Windows then I think you're better off using Visual Studio. The learning curve for C++ is steep enough already. If you simultaneously need to learn how to work with gcc and makefiles then you are likely to become overwhelmed.
Windows specific: for simple graphics I find WinAPI and GDI+ useful. They are relatively easy to learn and they are immediately available.

Visual C++ 2010 and Native executable file

Native exe!
that means my program can run easily without any requirement?
even if I use .net classes?
You know I want to write a program that is so light and I don't like to use C# or any other .net programing language because all of them need .net-framework 4.5.
Just think a 2.5 MB programm needs a +250 MB .netframework.
New Update - 12/01/2016:
It's almost 4 years ago when I asked this question. As you know Dotnet Native is announced. It's an interesting feature which compile IL into native code.
Compiling Apps with .NET Native
.NET Native is a precompilation technology for building and deploying
Windows apps that is included with Visual Studio 2015. It
automatically compiles the release version of apps that are written in
managed code (C# or Visual Basic) and that target the .NET Framework
and Windows 10 to native code. Typically, apps that target the .NET
Framework are compiled to intermediate language (IL). At run time, the
just-in-time (JIT) compiler translates the IL to native code. In
contrast, .NET Native compiles Windows apps directly to native code.
For developers, this means:
Your apps will provide the superior performance of native code.
You can continue to program in C# or Visual Basic.
You can continue to take advantage of the resources provided by the .NET Framework, including its class library, automatic memory
management and garbage collection, and exception handling.
Last I checked none of the .NET frameworks were 250+ MB! Yes, the offline installer for .NET Framework 3.5 SP1 is 231MB but it contains x86 and x64 versions of .NET 2, 3 and 3.5 sp1.
You should read this http://www.smallestdotnet.com for details on sizes of various versions of the installers.
Now on to your question:
Yes, It is a little annoying to have your clients install a big framework, even 20-40MB does get annoying. With .NET, the advantage is the ease of programming (In my opionion) compared to other Native options.
Your native options are:
MFC - You need only the VS runtimes installed, which is 1-2MB and is usually installed on newer pcs. Also, you can ship your application with the MFC libraries packaged into a dll which is again <2MB
The trade of here is you need to program in C++, the libraries overall are a very thin layer over the native libraries. and people have had harsh opinions about MFC. I've barely just tried it.
Win32 API - This is going all bare bones, and quite difficult, you could use C or C++ but you'd really have to know a lot about the Win32 API and how windows itself works (Stuff like windows messages, hwnds etc) Its not fun, believe me. But during deployment you would not need any external libraries.
There are tons more options, see here:
Native Windows Application Development Options
https://stackoverflow.com/questions/2711599/what-programming-language-should-i-use-to-create-small-native-windows-applicatio
Here are some links on MFC that might help:
Want to learn Windows Programming,some suggestions?
How do I decide whether to use ATL, MFC, Win32 or CLR for a new C++ project?
C++ MFC vs .NET?
https://stackoverflow.com/questions/557114/stick-with-mfc-or-go-to-net
you are able to create native exe by using c++ Win 32 projects.
Alas, nearly everything requires a download runtime library and even if you have one installed, you'll need to download updates for them almost continually. Even Microsoft C++ apps nowadays come with security updates that have to be installed if you've compiled your app with them.
But.. there is a solution of sorts. If you use C++, it has a feature where only the things you use are compiled into the final app. Normally, this would require linking with all the library dlls, but if you statically link with the library, you will end up with a single .exe that is as small as can be, and you will not need any dlls (as all the code contained in the library will be compiled into the .exe).
The benefits are debatable compared to dlls, but as MS has pretty much broken the idea of shared dlls in .NET (ie, you practically have to put all the shared dlls in the same directory as your running app, giving you a nightmare in maintenance if you have these shared dlls spread around all your apps) then there's not much of a difference anymore. Static linking is getting a little bit of a comeback and sounds like its what you want.
For modern C++ development, you'll probably want to take a look at Qt instead of MFC. Its a lot nicer to use and is cross-platform so you can run Qt apps on your Android or Linux platforms as well as Windows.

Does MinGW support MFC?

I have developed WinAPI applications using MinGW without problems. Now, can I do the same with MFC?
I'm just guessing here but I think you would need to buy a copy of Visual Studio to get a license to use MFC. MFC is not well known for its portable use of C++ either. If you are familiar with MFC, you might find the learning curve for Qt to be reasonable (which I use with MinGW). The MFC/MinGW route sounds very painful :)
You cannot. MFC stand for Microsoft Foundation Classes and Microsoft isn't good at supporting any other products than theirs.
You may try to compile MFC under MinGW if you have the source but the result is uncertain.

Challenge working with Visual Studio and VC++?

I have started working with C++ recently and am not comfortable with Visual Studio Development Environment and also I do not have proper understanding of MFC, Win32, ATL, COM Terminologies.
From example point of view, I had taken a simple C++ program to see how it works with Visual Studio Environment and I was having some issues to get that code up and running.
I would like to request if someone could point me to some online resources/books where I can get more understanding about Visual Studio Development Environment from C++ perspective and get some knowledge about MFC, Win32, ATL, COM Terminologies than it would be really very helpful to me.
Note: I have checked MSDN library and some related Microsoft sites but when I see HOW DO I kind of video tutorials they are more from .Net/C#/ASP.Net perspective but I am looking for some online resource for C++/VC++ perspective.
www.stackoverflow.com of course will have plenty of resources around if you look # the right tags
https://stackoverflow.com/questions/tagged/mfc
https://stackoverflow.com/questions/tagged/com
etc.
The Code Project is also a good resource for windows / C++ programming, here are a couple areas to start looking #:
http://www.codeproject.com/KB/MFC/
http://www.codeproject.com/KB/atl/
http://www.codeproject.com/KB/COM/comintro.aspx (via Andy in comments)
The classic book about Win32 is presumably Petzold's. Petzold's book is I think (I've never read it) mostly about GUI programming; whereas the other classic/recommended Win32 book, which is Richter's, is about 'system' (non-GUI) programming.
For learning COM, perhaps Essential COM? Some reviewers praise it, but some others reviews say things like "not for beginners"; but it's how I learned COM, and I found it thorough, low-level, and detailed. It assumes you know C++ (not COM) already.
IMO you don't need books about MFC if you already know C++ and the Win32 API, in which case the reference libraries are sufficient. Alternatively, some people recommend an MFC book like Prosise's.
I learned using Visual Studio IDE and MFC using the Scribble Tutorial. It was a step-by-step tutorial creating a simple MFC application. Unfortunately the tutorial was written for Visual Studio 6.0, and in the meantime almost all wizards and menus changed, so it's not applicable anymore.
The tutorial can be found in MSDN, here, though:
http://msdn.microsoft.com/en-us/library/aa716528(VS.60).aspx
The scribble sample source for Visual Studio 2008 can be found here:
http://msdn.microsoft.com/en-us/library/f35t8fts.aspx
Don't bother learning ATL, WTL, MFC or COM for now (or at all, really). Just use standard C++ for starters. If you want to write GUI programs, I recommend Qt, it is much easier and fun to use than any of the former APIs.
If you have trouble compiling Qt for Visual C++ you can download the entire Qt SDK and it comes with a C++ IDE called Qt Creator. It uses MinGW as a backend.