Cannot add Static Lib (C++) as a Reference due to targeting different platforms - c++

I'm experienced w/C# and C, but not with C++. I need to interface to an API in C / C++, so I'm off to learn C++ with Visual Studio 2015 Pro.
I built a very simple example to test the library of classes (as a static library) being used in a console application for testing.
I cannot add my library as a reference because VS 2015 claims that they target different platforms. However, the properties indicate the same platform.
What is this error telling me that I don't understand?

I'm using Visual Studio 2015 and doing something similar.
I had the same problem and I think what happened was maybe I chose the "static library" project and "executable" project from different submenus in the Visual Studio project creation wizard.
I went back through the project creation wizard and made sure I selected an executable type from the same category as my static library (in my case, "Universal Windows"). That platform setting is shown in parentheses after the Project name and seems to be different than the SDK settings the error seems to refer to.
I was looking for a way to "convert" my project from "Visual Studio 2010" (its original setting somehow) to "Universal Windows" but I haven't found one yet. I tried using Solution Explorer's "Retarget solution" option (in the right click context menu for the solution) but all it did was get me off Visual Studio 2010 and onto something that didn't have a reference at all. So I made a new project and copied the files over into it.

Related

Using legacy toolset from VS2005 in VS2019

I ran into the rare situation that I have to use static libraries in a project which were compiled with Visual Studio 2005.
As I do not want to get into trouble at runtime as mentioned in this post or here,
I think it's reasonable to use the original toolset.
As far as I have seen, using toolsets down to VS2008 is straightforward. For VS2005 this seems to be more challenging, only Daffodil might be an option.
Is there any chance to get the toolset v80 (VS2005) into the dropdown menu of VS2019 ?
After playing around, I don't know exactly understand how daffodil works or how a feasible approach looks like.
Maybe one could create wrapper-DLLs with a plain C-API and the help of VS2005. Using one IDE with various toolsets feels advantageously to me.
Daffodil works only in earlier versions of Visual Studio 2012/2013/2015.
For using daffodils, check out the related thread: How to move old VC6 project to VS2010 using Daffodil.
To build your project in VS 2010:
Make sure the VC 6 build tools are installed and working. Make sure VS
2010 and Daffodil are installed and working. Open your VS 6 workspace
in VS 2010. A. In Explorer, right-click on your VS 6 workspace (*.dsw)
file. B. Choose Open With -> Microsoft Visual Studio 2010. C. Perform
the migration when prompted. Change the Platform Toolset to v60. A.
Right click on the project(s) and select Properties. B. On the General
page, set Platform Toolset to v60. Build.

Installing a library in Visual Studio 2019 C++

I am trying to install this library in Visual Studio 2019
https://github.com/alex-87/HyperGraphLib
The instructions only show how to do so for linux/unix I was curious how I would do this for windows. I can download the .zip but where would I extract this and how do I get Visual Studio to install the library.
Visual Studio can directly open a CMake project (CMakelists.txt indicates that).
That said, very often projects are in theory "cross platform" but in practise they don't work in Windows because no one has bothered to test them there (mostly because an alternative would already exist or the actual developers do not care much). Projects that have better chances to work with Windows usually come also with a .vcxproj/.sln.
click on project, properties, link editors , input and add the dependencies (with keyboards only )

General usage of c++ in visual studio

Is it possible to write a c++ code in Visual Studio without using c++.net?
I'm learning c++ at the moment - Using a book.
But I like the Visual Studio IDE but I don't know if it supports c++ or just c++.net.
I usually create a new (empty) directory and copy the source file(s) into that directory, then when creating the Visual Studio project using the name of the directory. To create a standard C++ console program, choose "... console application", then click on next, clear the check boxes below "empty project", and check "empty project". Once you're into the project, click on project, and "add existing item" to add the source file name(s).
If you want 64 bit mode, you'll need to right click on the project name, then properties, then configuration manager, then new, and select x64. It doesn't matter if you do this for debug or release build, it will set x64 mode for both build modes.
Yes, you can. Visual studio supports two types of C++ applications:
C++/CLI (also called managed C++) - Under Visual Studio project wizard, these kind of projects are grouped under CLR
Native C++ - Under Visual Studio project wizard, these are the projects grouped under Win32, MFC, ATL
Note, however, that you can always turn a project from native to managed and vice versa by going into the project properties and switching on/off the Common Language Runtime Support (/clr), so make sure this option is turned off (No CLR).
Also, be aware that different C++ compilers not always support the same C++ features (even if they are part of the standard), and some C++ compilers implement their own extensions to the language. In the case of Visual Studio, it defines Microsoft Extensions to C and C++ that can be turned off (Za) to be more ANSI compliant.
Visual Studio is actually notoriously late when it comes to supporting the C++ standard. Even now, some C++11 features are not part of the latest Visual Studio so keep this in mind when wondering why something you read in a book does not work in Visual C++.
One last note. Avoid using ATL and MFC if you try to be cross-platform compatible. Even if you don't want to be cross-platform compatible, ATL and MFC are only supported by Visual C++ and using them will lock you to using Visual Studio. Now with the Community Edition, both ATL/MFC are available for free if you are an independent developer or a small company, while historically, ATL/MFC were paid-version only as they are not part of Visual Studio Express editions.
It depends on which variant of Visual Studio you're using. If Express edition you want "for Desktop" in order to do ordinary standard C++. With full Visual Studio there's no problem.

Missing MFC71.DLL for new empty VC++ Console Project

I am trying to get an slightly older project running again. I used the code last summer just fine. Unfortunately I did not keep the VC++ project files, just the code. As such I created a new VC++ console project and selected the "empty project" option in the process. Upon adding the code and pointing the compiler and linker to the appropriate folder I compile successfully. From there I attempt to debug and receive the message
The program can't start because MFC71.DLL is missing from your
computer. Try reinstalling the program to fix this problem.
From what I see this DLL is in the Visual Studio .NET 2003 which as far as I can tell my project should have no dependency on. I am using a robotics simulation library called callisto which I suppose could depend on it. However that project seems to be gone so I can't confirm as much from the project website. How does one go about using MS development tools to determine as much? In the event that it does not, what other possible reasons would a new project depend on such an old DLL?
Note that if you are using that library in form of DLL (already compiled code that internally depends on redists of VS 2003), you can verify this by using the Dependency Walker (it is a simple .exe file that you can download here: http://www.dependencywalker.com/ and just drag-n-drop this DLL on it).
Also note that you don't need to install whole Visual Studio. Redistributable package for VS 2003 will do.
EDIT: "The Visual C++ 2003 runtime was not available as a seperate download" ~ check Where to download Microsoft Visual c++ 2003 redistributable

Native C++ programs in Visual Studio

I'm confused in my understanding of the relationship between Visual Studio and .NET. I want to write a C++ application, but not a ".NET C++" application. By this, I mean that my understanding is that everything built in .NET land gets compiled to a CLI-compatible intermediary code (just like "JVM" languages like Java and Groovy compile to the same bytecode).
But I don't want my app compiled to an intermediary bytecode...I want it compiled down to raw binary!
Does Visual Studio do this? Or is .NET forced down my throat the minute I choose VS as my C++ IDE? If so, whats a "raw C++" alternative to VS?
Thanks in advance!
Visual Studio is an IDE, which is orthogonal to any specific language or compiler.
Visual C++ is a compiler that supports the C, C++, and C++/CLI languages.
In Visual Studio, create a Visual C++ project from one of the 'Win32' (as opposed to 'CLR') project templates and your program won't have any .NET dependency.
there is that /clr compiler switch when compiling a c++ app. Without it, you will get a pure native binary and cannot use any. NET specific features within your code.
By selecting a project template or by setting the corresponding project property, VS will automatically choose if the switch is on or off.
Visual Studio still supports 100% native C++ applications as will as managed applications. When creating a new app just choose the "Win32 Console Application" to create a native application. For existing applications you can change / verify by doing the following
Right Click on the project and select "Properties"
Navigate to Configuration Properties -> C/C++
Make sure that "Common Language Runtime Support" is set to "No Common Language Runtime Support"