LNK1113: invalid machine type 0x1C0 - c++

While building the project in VS2012, I'm getting the linking error as
LNK1113: invalid machine type 0x1C0
I'm not sure where to check and what would be the error. Any help would be appreciated.
Thanks

two minutes google for 'how to set module machine type in visual studio'
resulted in the following info, found at:
<http://stackoverflow.com/questions/3563756/fatal-error-lnk1112-module-machine-type-x64-conflicts-with-target-machine-typ>
Check your properties options in your linker settings at:
Properties > Configuration Properties > Linker > Advanced > Target Machine.
Select MachineX64 if you are targeting a 64 bit build,
or MachineX86 if you are making a 32 bit build.
Select Build > Configuration Manager
from the main menu in visual studio.
Make sure your project has the correct platform specified.
It is possible for the IDE to be set to build x64
but an individual project in the solution can be set to target win32.
So yeah, visual studio leaves a lot of rope to hang yourself,
but that's life.
Check your library files
that they really are of the type of platform are targeting.
This can be used by using dumpbin.exe
which is in your visual studio VC\bin directory.
use the -headers option to dump all your functions.
Look for the machine entry for each function.
it should include x64 if it's a 64 bit build.
In visual studio, select
Tools > Options from the main menu.
select Projects and Solutions > VC++ Directories.
Select x64 from the Platform dropdown.
Make sure that the first entry is:
$(VCInstallDir)\bin\x86_amd64
followed by $(VCInstallDir)\bin.
Once I did step 4 everything worked again for me.
The thing was I was encountering this problem on all my projects
where I wanted to compile towards a 64 bit target.

Related

Can't Build PortAudio - "LNK1104: cannot open file 'ksguid.lib'"

I'm a beginner in C/C++, so please bear with me.
I'm trying to build the PortAudio library so I can use it in one of my project. I'm using VS 2013, the preset project-file for builds had to be converted to my version. I've been able to fix all the many problems that occurred on my long way here, except one:
LINK : fatal error LNK1104: cannot open file 'ksguid.lib'
I've seen this and this site. All of them address exactly this problem, yet non of them has been able to solve it. Here are the solutions these sites suggest:
Add WASAPI - symbol to portaudio.def,
Add PA_WDMKS_NO_KSGUID_LIB - definition to the preprocessor
You can get the ksguid.lib-file from the Windows 7 SDK. It might even already be installed on your computer. It's best to use the explorer to find it (probably C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Lib\x64).
When you found it, go back to Visual Studio and go to Project > Properties > Configuration-Properties > Linker > Input, then click on the little arrow on the right of Additional Dependencies and choose edit:
Enter the absolute filepath to ksguid.lib. Make sure that you surrounded it with "-s and that you put a ; at the end. (Throws an error without a usable description otherwise - Microsoft as we know it.)
Source: Bitbucket, stackoverflow
ksguid.lib is included in the Windows 7, 8, 8.1, and windows 10 sdk. The answer provided by #Nearoo is perfectly valid. This alternative answer involves modifying what directories the portaudio Visual Studio project looks for library files.
For reference, I'm using Visual Studio 2013 on a Windows 8.1 PC.
Navigate to: Project -> Properties -> VC++ Directories
At the top of the window,
change Configuration to "All Configurations".
change Platform to "All Platforms"
In the "Library Directories" portion, add the following path:
$(WindowsSdkDir)\Lib\winv6.3\km\$(PlatformTarget)\
This nice thing is that this one path uses macros so it will work with Debug, Release, 32 bit and 64 bit builds of portaudio.

Profile a c++ win32 console application with Visual Studio 2012

I have a simple (not so simple) win32 console application in c++. I would like to profile this application, but when I try to:
DEBUG > Start Performance Analysis
An error occurs: "No launchable projects are available for profiling".
Please note that the project compiles and runs normally. It's jus the profling that is not working.
How can I solve? I am on Windows 8 with Visual Studio Ultimate 2012
Note that I choose for this project a simple:
File > New Project > Win32 > Win32 Console Application (C++)
I would like to obtain something like xcode does.
A simple list for each functions or methods the cumulative time of usage.
This is the error when I try "Start performance analysis"
Note
I have tried both release mode and debug mode with both x64 and or Win32
Note2
In this project I have created two custom property sheet (to include the right opencv libraries)
- OpenCV-Release
- OpenCV-Debug
Note3
Open the projects properties.> Configration Manager > Active Solution Platform > select New > and follow my screen shot. Your perfomance analysis will run after this.
The project is not being recognised, as you have it configured with x64. (As evidenced by your first screenshot under Note)
Win32
As your project is created in the 64bit os, you need to manually link the project with the win32 sys, so the profiler will recognize the project as a win32 project.
http://en.wikipedia.org/wiki/Windows_API
I will leave this here, as it may be useful for some users.
Saving projects in Visual Studio, must be done methodically and consistently.
If a project is created and saved in a folder (for example) Folder A within the C drive and then later the folders are rearranged and the project is then in Folder A, but folder A has been moved to the D drive (or any variation of changes). Visual Studio, will not be able to find the project.
Be sure to check that all your files for this project are in the correct folders. You need to open the sub folder and make sure that all the files for your project are present.
Please see my screen shots. It doesn't matter why my folders are arranged, as they are, suffice to say, I have found it easier to keep them with the program files in the C drive.
Please note the file in the first screen shot extension vspx, is a visual studio performance report.
Visual Studio Project Folder
Visual Studio Sub Folder
This may or may not answer your question. Please advise if you need more assistance.
The short cut-
VS Release
The long steps - which give you more options
VS Debug menu
VS Configuraion Manager
Please try this (it is the same answer on both links):
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
http://social.msdn.microsoft.com/Forums/en-US/vsdebug/thread/56dcdb2a-5e30-4015-bc14-244f99f07b8b
Profiling with CMake, C++, and Visual Studio 2012
And this link as well.
Add the files to a directory outside of the project and then reference those directories in the "Additional Include Directories" in Properties -> Configuration Properties -> C/C++ -> General.
VC++ Visual Studio added .hpp files in subdirectory but get "Error: cannot open source file ..."
You can launch the performance wizard, under the Analyze tab.
This is a known bug in VS.
Without seeing your computer, it is hard to know what else, I can suggest. I do know that it's important to go through all the suggested steps to trouble shoot. If I can find anything else, I'll let you know.
Please note my project is a downloaded sample.

Visual Studio 2012 32bit compilation on 64bit system

I have recently wanted to build a dll plugin for a program. Problem is, the program is 32bit, but by default my Visual Studio 2012's C++ compiler creates 64bit binaries, and I don't know how to change it - I've found the Configuration Manager and tried to create a new platform but there's only x64 as an option.
Am I trying to set the target architecture in the wrong place or what? Is there an update or something I can download so that I can create my dll? Is there a compiler switch that I can set somewhere?
Hope this screen helps:
To build for 32 bit architecture, you have to open project properties window, and then Linker options.
Set the value of Target Machine option to MachineX86.
Check the Build Configuration (Build -> Configuration Manager), and ensure that your DLL project for 32-bit is selected.
Check the linker settings, and ensure correct path is given.
After build, check that .DLL is produced at correct path, and is 32-bit (should be!).
You can use Dependency Walker to check if DLL is 32-bit or 64-bit.
You also didn't mention if /clr option is used with this DLL or not. With /CLR, managed binary is produced. Though this option wouldn't alter bit-ness of the binary, you can just check if this is the case.

Converting VC++ Solution and Project files from 32 to 64 bit

Does devenv through any switch or any tool allow to convert a Visual Studio Project and Solution from x86 to X64/AMD64? I was particularly thrilled with the switch /Upgrade in devenv which automatically upgrades a solution/project from previous version to the current version and was looking forward for something similar to do a bitness conversion.
I have a set of vcxproj that I want to port from 32 bit and 64 bit. The process I understand should be straight forward as it only have to create a new configuration for x64, copy the settings for both Win32 Debug/Release and then do a blind replace of all the CRT/MFC libraries/dlls and toggle few switches to make it a 64 bit build.
Hacking through the vcxproj and sln files may be an option but I do not want to invest time and reinvent the wheel if one already exist.
Note If it matter's, currently my focus is only for Visual Studio 2010.
You don't need to "upgrade" your Project files from Win32 to x64. Just go into configuration manager for your solution and add an x64 platform for the project configurations that need it.
I wrote a python script to do it manually, kinda hacky but it seems to work :)
Pretty straight forward since both the solution and project files are plain text. At first I did it via configuration manager, then I diffed the files and did the same procedure in python.
In my case (protobuf 2) it was only a few 'replace all's.
in both sln and project replace Win32 with x64
in project replace
<TargetMachine>MachineX86</TargetMachine>
with
<TargetMachine>MachineX64</TargetMachine>
and
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
with
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
and finally change the OutDir so my cmake Find scripts pickup the build
Full source https://github.com/madeso/ride/blob/f7d7234972aeaa0ddb89cda030ecfe651678078d/scripts/windows.py#L163

Visual Studio will not give me the platform option of 64 bit in configuration manager..?

I am currently trying to build a project for a 64 bit computer, but the configuration manager doesn't list 64 bit as an option. It gives me Win32, but no x64 (under "Platform"). I am using Visual Studio 2010 C++ Express.
It works on my other computer, but not this one. Most everything I have read has been saying to go up to the "Active Solution platform" drop down, and add 'x64' to it. I have tried that, but it still only lists Win32.
Select the Configuration Manager as given by the following picture.
The Select "New" from the menu as given by the following picture.
After that you will populate with following dialog box.
Once the process is completed, you will get the "x64" platform settings.
Now you can select the Platform via Configuration Manager.