How do I know if a project is MFC application - c++

My friend has given me a visual studio project , with lots of files.
I know for sure that it is C++ application.
But I want to verify that if it is an MFC application or not.
The issue is since this project has been developed on a higher version (VS 2013) than mine (VS 2010), it is not opening in VS 2010.
So I thought I will make a new project and then gradually add these files.
But When I try to make a new project , I have many options to choose , such as MFC, win32 etc.
I guess it is an MFC application. But to be sure I want to verify that this project is indeed an MFC application. How do I do this ? Especially by just looking at the project files!

Look into your source files and check if afx.h or afxwin.h is included any where.
Project Settings are secondary. Only if such a Header file is used in the Project the MFC libraries are included in the link phase.

You would probably be better off checking the source files, not the project file. For sure, the MFC library need to be present in the project file, but that option could have been left on accidentally.
You could search the source files for CWinApp, which is the class MFC applications need to be derived from. Also, you could try this page on MSDN, which will give you some idea about source and header files typically found in an MFC project.

VS2010 and VS2013 uses XML for .sln/.vcxproj files. Just create a minimal solution in VS2010. Then use a good text editor or even a file comparer to adjust settings inside the .vcxproj.
Great syntax changes occurred between VS2008 and VS2010. But since then most XML tags were kept unchanged between VS2010 and VS2013.

Related

Building C++ API of Third Party Library in Visual Studio C++ Project

I have been successfully testing an image processing library (https://github.com/libvips/libvips) in a C++ project in VS2017. I am new to C/C++ and I have been following the documentation here which describes the C way of using the library. There are features I would like to try in the C++ API, but the C++ API needs to be built with the same compiler as my project. According to the author:
It's slightly awkward to set up under Windows. The problem is that C++
does not have a ABI, so you must use exactly the same C++ compiler for
your whole project. This means the libvips C++ win binary (built with
g++) won't work with MSVC C++.
You need to copy the libvips C++ API source code into your own project
and build it with your own code. It's just a few files and pretty
simple to incorporate:
https://github.com/libvips/libvips/tree/master/cplusplus
I have made several attempts to build the minimal set of files but I have not had any success.
My steps so far:
Create a C++ console app in VS2017, set to Debug and x64
Extract the 'vips-dev-8.10' folder from vips-dev-w64-all-8.10.6.zip to where the project file is (this contains all the built .dll files, .lib files, .h files etc.)
Extract 'cplusplus' folder from 'libvips-master.zip' to where the project file is (this has all the project source files including the cplusplus folder which is the part I have to build per the above explanation)
Add the following folders to Project > Properties > C/C++->General > Additional Include Directories
C:\Projects\ConsoleApplicationVIPS3\ConsoleApplicationVIPS3\cplusplus\include\vips
C:\Projects\ConsoleApplicationVIPS3\ConsoleApplicationVIPS3\vips-dev-8.10\include
C:\Projects\ConsoleApplicationVIPS\ConsoleApplicationVIPS\vips-dev-8.10\lib\glib-2.0\include
C:\Projects\ConsoleApplicationVIPS\ConsoleApplicationVIPS\vips-dev-8.10\include\glib-2.0
Add the 5 .cpp files from the cplusplus folder into the project Source Files folder and Add them in the project tree.
Build the project.
As a result I get the following errors:
I haven't written any code yet. I thought I should just be able to point to the .h include files and compile the required C++ files. It's not clear to me what else I might need to add, but it definitely seems like I don't understand the correct procedure to build the project. I watched some videos on C++ compilation like this one but I cant see where I went wrong.
Any thoughts would be much appreciated.
EDITS 3-Jun-21
I have made some changes. I have instead extracted the exact version of the library according to the suggestion by #Frank, and I also discovered the usefulness of the compiler output window, thanks #Alan Birtles.
I am still getting errors, but I am not clear why. The first error is:
E0020 identifier "VImage" is undefined
Which is odd because I have added the folders to Project > Properties > C/C++->General > Additional Include Directories, and one of them is ..\cplusplus\include\vips which contains VImage8.h
And the Output window shows
Any further advice would be appreciated!

Create MS Visual C++ DLL project out of existing sources

My goal is to compile existing C++ classes (legacy code, stored in a set of *.h files) into a DLL so that it can be further integrated into a C# application.
For that purpose, it seems best to use MS Visual Studio. I have no experience with this environment, so I tried the naive approach found on MSDN and other SO answers:
File | New | Project from existing code
selected Visual C++
selected file location that is base for include references used in those .h files
specified a project name
let the wizard find and add all C++ files below the directory
selected "Use Visual Studio" for build, with project type "Dynamically Linked Library (DLL) project"
checked none of the checkboxes below (ATL, MFC, CLR)
specified . dir in the "Include search paths (/I)" in Debug settings
checked "Same as Debug configuration" in "Release settings"
clicked Finish button
This creates couple of VS files in the directory:
mylibrary.sln
mylibrary.vcxproj
mylibrary.vcxproj.filters
mylibrary.vcxproj.user
With a project created this way, I press F6 or select Build | Rebuild solution from the menu.
Then I expect the build to produce the .dll file somewhere, but it does not appear. Only these files appear:
.vs/mylibrary/v15/.suo
.vs/mylibrary/v15/Browse.VC.db
.vs/mylibrary/v15/Browse.VC.opendb
.vs/mylibrary/v15/ipch/AutoPCH/efad7c74cd39331b/EXAMPLE.ipch
Debug/mylibrary.log
Debug/mylibrary.tlog/mylibrary.lastbuildstate
Next, I decided to try creating a fresh new library project, just to observe the differences to get some hints, but that did not help - there were too many differences, even in the file structure...
My questions are:
is my choice of MS Visual C++ a good one for given purpose?
if so, what am I doing wrong here?
I think your steps are probably correct and I think that the right approach to use the code from a C# application. You definitely can call a C++ library from C# by importing the methods.
You missed only to export the methods that you want to use from your library. try using __declspec(dllexport) with these methods. please check this link:
https://msdn.microsoft.com/en-us/library/a90k134d.aspx.
Also, the output should be at the build folder, not the source code folder
Compiling .h files into libraries is ok, the compiler does not care - however, the UI does.
Still, you can tweak this by directly editing the .vcxproj file.
While doing so, make sure that the <ClCompile> sections contain:
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
Note that you can use commandline for building the DLL project:
"%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\MSBuild.exe" -target:Clean,Build
(this assumes that your current directory is the one with your .vcxproj)

How to prevent Visual C++ from creating stdafx.h?

I'm using Visual Studio 2015. I always uncheck "Precompiled header" whenever I create a new project, but Visual Studio still creates the file and adds it to my project. I've tried just creating an empty project, but that also gets rid of the external dependencies, which I need for my projects.
I've tried searching the internet but couldn't find anything about this. Is there a way to prevent Visual Studio from generating stdafx.h but keep the rest of the core libraries at project creation?
Haven't used VS since 2010 but from what I recall you cant get rid of stdafx.h as thats the standard way VS makes a non-empty project for you (it might be just winapp projects, console projects did not have it in VS2010). It wants you to place all your includes into there. Your best bet is to create an empty project and manage the dependencies yourself. Its not too bad.
Just create an Empty Project.
The External Dependencies "folder" in the Solution Explorer will populate itself as you start including external dependencies.
When you create a Win32 Console Application, the External Dependencies will be prepopulated with a handful of headers at first; this is because the Win32 Console Application project includes a few source files that include external headers. When you create an Empty Project, the External Dependencies will be empty at first because there are no external dependencies yet.
Try creating an empty project and place your important libraries manually. I don't think you can start VS non-empty project without a header file.

How to compile a cpp to a dll in visual studio 2010 express

I have a cpp which depends on couple of headers in the same folder. I need to compile this cpp to a dll. How do I do it in visual studio 2010 expresS?
I found few articles on web for visual studio 2008 but I could not use it in 2010. Any pointers would be highly appreciated. Btw, I am a java programmer. CPP is all new to me, I am compiling some one else's cpp to dll.
Thanks,
Abi
Right-click on your project in the Solution Explorer, and select Properties.... Under Configuration Properties -> General there's an option called Configuration Type. If you change it to Dynamic Library (.dll), your project will generate a DLL when it is built.
As a start point, you can use "Create New Project from Existing Code" as described here - specify that you want a DLL project when prompted.
Once you have a project in place that encapsulates your CPP code file, you can find other info on specific project settings in MSDN, or post new questions as you need to.

Using a DLL with unmanaged code in Visual Studio 2010?

I'm fairly new to C++ and an trying to figure out to use the TagLib library for a project I am working on. I'm working with unmanaged C++ in Visual Studio 2010 on Windows 7 64bit. I've never used an external library before so I'm very confused on how to go about this.
From this blog entry I got the libtaglib.a and taglib.dll files. I ran across this SO question on how to use TagLib, but it deals with QT Creator, not Visual Studio and I'm not knowledgeable enough about the subject to understand what is being said to translate it into what needs done for Visual Studio.
So, some questions:
Is it even possible to do this with unmanaged code?
What exactly is the function of a .a file?
Most importantly, how do I go about using the taglib.dll in my program??
I've been all over Google looking for a way to do this, but my major problem is that everything I run across is over my head. Please let me know if more info is required. Any help is very much appreciated! Thanks!
I seem to have gotten it working successfully. Here's a rough outline of what I did:
1.) I used CMake to generate the Visual Studio solution.
2.) I attempted to build the tag project in the VS solution, but it failed.
3.) I made the corrections to a few source files as outlined here: http://old.nabble.com/taglib-fails-to-compile-with-MS-VC%2B%2B-2010-td29185593.html
4.) I built the tag project again in release mode. This time it was successful.
5.) I copied the resulting dll, def, and lib files to the same directory as the source files for my project.
6.) I copied the header files from the taglib source to a subdirectory in my project (not sure if this entirely good practice)
7.) In my project settings, I set the subdirectory with the header files as an additional include directory.
8.) I added the dll, exp, and lib files to my project by just going to Add>Existing Item.
9.) I added some code from the taglib examples and built it. Everything worked so I think I got it.
One caveat I ran into, since the DLL was built in release mode, my project had to be run in release mode or it would crash. I'm guessing that if I replaced the DLL with one built in debug mode I could run my program in debug mode, but I have not tried this.
You cannot use libraries specific to GCC (you can tell because they have .a extensions) with Visual Studio. You will have to build the library from source in order to use it with MSVC. Once you have done that it's a simple matter of adding the .lib generated from the build process to your project and things should work out of the box. (Note that it's a .lib you need whether you're compiling for dynamic linking or not -- doesn't matter in msvc land)
EDIT -- after looking at TagLib itself --
In order to compile TagLib you'll need to get the CMake build system, and TagLib itself, and have CMake build you a visual studio solution. Using that solution you'll be able to build the .libs and .dlls you need. Note that because TagLib is a KDE library, you'll probably need to also build some QT bits in order for everything work work successfully. However, I don't have specific experience with the library so I'm not going to be all that helpful here.
Yo do not have to recompile the source (to create the .lib file) if you have the .dll file. With dumpbin /exports and lib (both came with Visual Studio) yo can create a lib that you can link with your application. In this link you can see a nice explanation: http://www.coderetard.com/2009/01/21/generate-a-lib-from-a-dll-with-visual-studio/
But as Billy Said, probably you would need other parts of QT to use this library.