Solved

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

Posted on 2009-05-20
4
1,006 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 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

Is Your Team Achieving Their Full Potential?

74% of employees feel they are not achieving their full potential. With Linux Academy, not only will you strengthen your team's core competencies but also their knowledge of of the newest IT topics.

With new material every week, we'll make sure that you stay ahead of the game.

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…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

691 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