Fatal Error: "No Target Architecture" in Visual Studio

Fatal error: No Target Architecture in Visual Studio

Use #include <windows.h> instead of #include <windef.h>.

From the windows.h wikipedia page:

There are a number of child header files that are automatically included with windows.h. Many of these files cannot simply be included by themselves (they are not self-contained), because of dependencies.

windef.h is one of the files automatically included with windows.h.

No Target Architecture compilation error in Visual Studio using CMake

Since the error message mentioned a file of mine (e.g. file_operations.h) I decided to define the architecture inside it using the following macro:

#define _AMD64_ 1

This fixed the problem but I believe that a "better" solution exists by configuring the CMakeLists.txt or Visual Studio.

Visual Studio Professional 2013, Update 5, No Target Architecture

In the end I found that removing the headers:

    profileapi.h
sys/types.h

Resolved the issue and the project now builds without warning or error.

Thank you Dai, the better solution:

    #include "targetver.h"
#include <Windows.h>

#include <stdio.h>
#include <tchar.h>
#include <iostream>
#include <chrono>
#include <ctime>
#include <time.h>
#include <fstream>
#include <profileapi.h>
#include <sys/stat.h>
#include <sys/types.h>

how to solve #error : Must define a target architecture in wince mfc application?

Presumably, the error is because you're trying to build the application against the (desktop) Windows SDK. The easiest thing to do is to create a new "Win32 Smart Device" project and add your code to it.

Alternatively, check the "Compile for architecture" setting under project properties -> C/C++ and ensure that it is set for the appropriate architecture.

Include winnt.h in my project

check Compiler->Enable Microsoft extensions in Project options or use -Ze flag if you're compiling from the command line.



Related Topics



Leave a reply



Submit