?
Solved

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

Posted on 2009-05-20
4
Medium Priority
?
1,011 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 40

Accepted Solution

by:
evilrix earned 750 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

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
Suggested Courses

771 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