Solved

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

Posted on 2009-05-20
4
999 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
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…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

829 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