Solved

Unable to build simple 64-bit C++ app in VS2008

Posted on 2009-05-20
4
987 Views
Last Modified: 2013-12-14
I'm trying to build a trivial "hello world" type program using the Windows console app template with precompiled headers, on an x64 platform targetting an x64 platform.  I get the following error:

.\x64\Debug\stdafx.obj : fatal error LNK1112: module machine type 'X86' conflicts with target machine type 'x64'

this happens despite there being no mention of x86 in my project properties.  It appears that the stdafx.cpp is being compiled for x86 regardless of what I specify.
// Test64c.cpp : Defines the entry point for the console application.

#include "stdafx.h"

int _tmain(int argc, _TCHAR* argv[])

{

    return 0;

}
 

// stdafx.h : include file for standard system include files,

// or project specific include files that are used frequently, but

// are changed infrequently

#pragma once

#include "targetver.h"

#include <tchar.h>

Open in new window

0
Comment
Question by:JustinFisher
  • 3
4 Comments
 
LVL 40

Accepted Solution

by:
evilrix earned 250 total points
ID: 24439120
One the libraries or object files you are trying to link to you 64 bit program has been compiled using the X86 machine type, meaning it is a 32 bit and not 64 bit library. You'll need to make sure all your static libraries are build using the X64 and not the X86 flag.http://msdn.microsoft.com/en-us/library/21ksa10x.aspx
0
 

Author Comment

by:JustinFisher
ID: 24440734
Thanks, I'll check into that idea.  The error message led me to think that the stdafx.obj was the problem, and that just wasn't making sense.
0
 

Author Comment

by:JustinFisher
ID: 24442107
In the course of looking at the lib paths, I discovered problems with the x64 command scripts that were causing the environment to not initialize correctly.  it appears that the C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC path isn't handled very well (the "(x86)" seems to cause some commands to get lost).
0
 

Author Closing Comment

by:JustinFisher
ID: 31583686
Although it turned out not to be the libs that were the problem, the suggestion pointed me in the right direction.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Using MS Code on my Mac 6 47
Library to convert HTML to PDF. 8 46
Expando 4 36
Achieve json result 2 35
This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now