Where can I get afx…h files? [duplicate]

2019-04-01 06:33发布

问题:

This question already has an answer here:

  • Is MFC only available with Visual Studio, and not Visual C++ Express? 2 answers

I'm developing with an API and the API requires the afxsock.h among other afx... headers. After searching online, it seems that my VS Express isn't enough, so I looked to purchase the product at microsoft. Unfortunately it's 700$ and as a beginning programmer, it makes no sense for me to drop that on 1 project which I am using to teach myself c++. (I.e. I still don't know if I want to program long term in C++ or another language).

In any case, I was wondering if there was some sort of work around to get the afx (or more appropriately the MFC) files?

Note that I have Windows 8, Visual Studio 2012, and I've downloaded the Windows Development Kit for Windows 8, but still can't compile because I'm getting missing afx errors.

回答1:

The AFX prefix stands for Application Framework Extensions, which was the original name for the MFC (Microsoft Foundation Classes) libraries. The file names were set in stone before the name was changed to MFC, and it was too late to change them.

So you need MFC in order to use those headers. Unfortunately, the Express versions of Visual Studio do not include MFC (or ATL). You can only develop MFC applications using the Standard, Professional, or higher editions of Visual Studio.

If you are a student, you have a couple of great options:

  • You can can join Microsoft's DreamSpark program, which is free to students and entitles you to some great free downloads, including VS 2012 Professional, VS 2010 Professional, and recent server versions of Windows.
  • Alternatively, you can join the IEEE for a very low cost. The IEEE student membership entitles you to download many Microsoft tools, including the Ultimate editions of Visual Studio. See this page for more information. (Although that page mention VS 2010, VS 2012 is actually available.)

Otherwise, you will have to either buy Visual Studio Standard/Professional outright, or join MSDN.

Alternatively, you could use the winsock2 API, which is part of the Windows SDK rather than MFC. Get started with the documentation here. The Windows SDK is what you're getting when you downloaded the "Windows Development Kit for Windows 8". It includes everything you need to link to native Win32 libraries, but it does not include the MFC framework.



回答2:

In addition to the IEEE "student membership" option that someone else linked to, you may want to consider Microsoft's BizSpark program which will give you access to more than just Visual Studio. I do not know if you qualify for it, but it's worth looking into.


With that said, it's time to step onto the soapbox and add some commentary: I understand the problem of API of choice having a dependency on MFC, but realistically speaking developing a trading program is neither particularly easy nor a good place for you to start. In addition, starting with MFC is probably not a good idea unless you want to specifically focus on becoming an MFC developer. If you are set on C++ you would be better served focusing your efforts on learning C++11. Or at least learning it first. Once you are comfortable with that, then you can focus on learning GUI programming using any of the many frameworks available.

Just my $0.02.



标签: c++ mfc