How to link to a .so library in Visual Studio? - visual-studio-2012

What I am trying to do is to link my project to a .so library that I have. Is it enough to add it in the Project Properties -> Linker, as I am doing with every static library (.lib), or is it another way to do it??
My project is an Win32 Console C++ Application.

You can't use Visual Studio to link to a .so file, because that's a Unix kind of shared library (and it will also be compiled for some Unix operating system). Visual Studio can only link for the Windows operating system. In this case, recompile your library to a windows .dll file.
http://en.wikipedia.org/wiki/Library_(computing)#File_naming

Related

Configure Visual C++ project to use the 64-bit tool set when building 32-bit executable

I am trying to enable link-time codegen (LTCG) and whole program optimization (WPO) for the build of a large Windows C++ application built with Visual Studio 2017. The 64-bit product builds fine but the codegen step of our 32-bit build runs out of memory.
So, I need to switch the 32-bit builds to use the 64-bit link.exe as described here: How to: Enable a 64-Bit, x64 hosted Visual C++ toolset on the command line
Specifically:
The 32-bit and 64-bit tools generate identical code, but the 64-bit tools support more memory for precompiled header symbols and the Whole Program Optimization (/GL and /LTCG) options. If you run into memory limits when you use the 32-bit tools, try the 64-bit tools.
It describes doing this from a command line build but I need it within the devenv environment. I have searched unsuccessfully for a Solution or Project setting to control using the 64-bit tool set for a 32-bit build.
I suspect I'll need to edit the .vcxproj file directly but am not sure what to add. Can anyone tell me how to setup my 32-bit build this way?
An alternative answer is to use PreferredToolArchitecture in the project.
Using Visual Studio 2019 (v16.1) this can be done in the properties dialog of the project under "Configuration Properties\Advanced\Prefered Build Tool Architecture". Specify x64.
For older versions of Visual Studio, editing the vcxproj is required. This is documented in Walkthrough: Using MSBuild to Create a Visual C++ Project
<PropertyGroup>
<PreferredToolArchitecture>x64</PreferredToolArchitecture>
</PropertyGroup>
Found my own answer... You do need to hand-edit the .vcxproj file and add this to the PropertyGoup
<UseNativeEnvironment>true</UseNativeEnvironment>
So mine now looks like this:
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<UseDebugLibraries>false</UseDebugLibraries>
<UseOfMfc>Dynamic</UseOfMfc>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<UseNativeEnvironment>true</UseNativeEnvironment>
</PropertyGroup>

FreeRTOS - Creating Project MinGW or MSVC, undefined reference to "xTaskCreate"

I'm newbie with FreeRTOS and i'm trying to compile a simply example application.
If i open the demo application with Microsoft Visual Studio, it works greatly, but once i remove all .c leave only main.c with some simply instatements like xTaskCreate(), cause this errors:
undefined reference to: xTaskCreate();
I've tried also to create a new project with include all header, but the result it's the same.
Toolchain tried: Codeblock and Eclipse Luna with MinGW header and Microsoft Visual Studio with header MSVC
I've seen that in the source file, there aren't .lib or .dll but only .h.
Thanks in advance :)
This was the solution posted on the FreeRTOS support forum:
"Don't delete any files from the "FreeRTOS Source" directory in the MSVC
project. They implement the FreeRTOS kernel, so without them your
application will not link."

How do I make Microsoft Visual C++ 2010 Express executable files independent of c++

Whenever I try to build a windows executable file in Microsoft Visual C++ 2010 Express and use the created program, Microsoft Visual C++ always boots up, I want to create an executable file, just like any other windows program without having to go through Microsoft Visual C++. Any information on this would be GREATLY appreciated, Thank You
When you have build you program you have to copy the executable to the destination PC. When your C++ program is in the file hello.cpp compiled in the project moin.vcproj yoi have to copy the moin.exe to the target. There you start the moin.exe. The executable can be placed in any folder.
The C++ compiled program requires that the C++ run-time library is installed. Very often it's already there. But you have problems to run the executable you need to install the correct redistributable package.
Depending on the target CPU you used you need the x86 or the x64 distributable:
Edit: If you don't want to deploy your program you just use the Windows Explorer, browse to the folder where Visual Studio has created the moin.exe, and double start it with a double click. The right mouse key can offer you more possibilities like creating a shorcut.
The search function of the Explorer might help here. If you didn't change the output directory you will find the .exe somehwere below the place where your .vcproj is located.

Use Clang with MSVC 2010

First of all, I want to ask if Clang compiler is better than MSVC's default compiler? And how can I use Clang with MSVC? For example, I write code in MSVC then when I hit Build, it call Clang to build the project.
https://github.com/ishani/ClangVSx
AddIn for Visual Studio 2010 that allows use of the Clang C/C++ compiler in place of MSVC++. Translates VC project and build settings into gcc-friendly command line arguments, along with existing platform tools (MSVC Linker, Librarian, RC) to complete the build chain.
Using clang compiler on Windows is still considered to be in experimental state. However, some progress has been made recently. As I answered similar question:
LLVM provides Windows snapshot builds - a clang toolset for Visual Studio as Windows installer. Currently it should integrate with Visual Studio 2010, 2012 and 2013. More information can be found on LLVM's blog post A path forward for an LLVM toolchain on Windows.
You can use a "makefile project" to have Visual Studio invoke a makefile (or any command-line process) when you tell it to build.
I've done this before to get MSVC's nice source navigation for non-Windows embedded projects.
The drawback is that you have to manually keep the makefile in sync with the files in the project (or vice-versa depending on how you want to look at it) - generally not a huge problem.

porting MSVS proj files to makefiles?

Does anyone know if/how to automatically generate makefiles from a .sln/.vcproj files of a C++ application in MSVS to be used to compile and build this application on Linux ?
Thanks, --Yariv
You can create a makefile from within Visual Studio. It's not exactly the same thing as in Linux, but the numner of required modifications is not too big.
MSDN: Creating a Makefile Project

Resources