Solved

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

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
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 …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.

910 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

20 Experts available now in Live!

Get 1:1 Help Now