"No Target Architecture" compilation error in Visual Studio using CMake - c++

I'm trying to compile my C++ CMake project in Visual Studio. However, I'm getting the following error message:
#error: "No Target Architecture" C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CMakeLists.txt C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um\winnt.h 154
I checked my code and I'm never including winnt.h but I'm including windows.h so this rules out the solution of never including winnt.h.
This is the winnt.h code snippet where it throws the error:
//
// TODO: WOWXX - Unblock ARM. Make all alignment checks DWORD for now.
//
#define PROBE_ALIGNMENT( _s ) TYPE_ALIGNMENT( DWORD )
#elif !defined(RC_INVOKED)
#error "No Target Architecture"
#endif
I've previously successfully compiled this project using MinGW and WSL (Windows Subsystem for Linux) outside of Visual Studio. How do I tell Visual Studio that my architecture is 64-bit and amd64 (?). What is necessary in addition to make it compile? The run configuration is set to x64-Debug. Including stdafx.h is not possible since the header file is not found. I'm also using Boost but that is resolved properly by adding the following line to my CMakeLists.txt:
set(BOOST_ROOT "C:/local/boost_1_69_0_b1_rc3")

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.

I think this should be fixed by -DCMAKE_GENERATOR_PLATFORM=x64

It is not specified if the error happens when the project is being configured or when the project has been configured and you are trying to build.
It could be an issue with your Visual Studio installation as it seems like you are not using cmake at the command line but using the cmake built into Visual Studio.
In both cases cmake will run to verify that a valid program can be built.
In Visual Studio create a new CMake project and it will create a generic c++ project with a CMakeLists.txt file. When you build this project it will run through the compiler detection phase, project configuration, and build. On my system this defaults for x86-Debug switch this to x64-Debug and it will go through the process again for x64 architecture.
Personally I think that the bundled CMake interface is very confusing and I don't use it. It is also using an older CMake and Ninja tools.
If this all works then it is something else that is going wrong and you need to include the full error message. The full error message will show the chain of include files and may pinpoint if you are using the wrong windows header file.

Related

FLTK on Visual Studio 2019 x64, "Cannot open include file: 'dirent.h': No such file or directory

I am using the FLTK library in Visual Studio Community 2019 and building my application for x86 works fine. Now, I would like to build it for x64. However, I am getting the error "Cannot open include file: 'dirent.h': No such file or directory.".
The error occurs in the file, named 'filename.H'. This header file comes with the FLTK library.
Has anyone an idea how I could fix this problem?
Update:
The dirent.h library is not recognized, because its an C POSIX library, as described in the link here below. However, the question still remains, namely, how can I fix this problem?
<dirent.h> in visual studio 2010 or 2008
The link above refers to a link with an alternative dirent.h file. I've tried to include this file in my project, however, now another errors occur. These errors occur in the file Fl_Native_File_Chooser.H. The type specifiers fl_OPENFILENAMEW and fl_BROWSEINFOW are unknown in this file.
On Windows, dirent.h should not be included in the FLTK code. Even though it is 64 bit, WIN32 must be defined when using the FLTK libraries (https://www.fltk.org/doc-1.3/preface.html). Your problem will probably be solved if you define WIN32 at the beginning of your code or if you add WIN32 in your Visual Studio project properties - C/C++ - Preprocessor - Preprocessor Definitions, in x64 platform.
The way I would create an x64 solution is
Open ide\VisualC2010\fltk.sln
If you are using another version of Visual Studio, let it convert.
Change the solution configuration to Debug (somehow Visual Studio always defaults to Debug Cairo)
Click on solution platforms and select Configuration Manager
When the Configuration Manager appears, under Active solution platforms select New
When the next dialog appears, under type or select new platforms select x64
Click on the OKs etc to close the windows
Now change the solution platform to x64 and start the build.
You shouldn't get any dirent.h errors.

error while building a Hello World wxwidgets app with visual studio 2019

I'm trying build wxwidgets Hello World sample program in visual studio and i'm using prebuilt wxwidgets instead download that and build it myself.
and after configuring visual studio project for wxwidgets i always facing with this error:
Error C1083 Cannot open include file: '../../../lib/vc142_x64_dll/mswud/wx/setup.h': No such file or directory wxwidgets_programming_cpp C:\wxwidgets\include\msvc\wx\setup.h 140
where is the problem. I think i configured visual studio project in a wrong way. can you help me how to configure visual studio project for a regular wxwidgets app?
You need to define wxMSVC_VERSION_ABI_COMPAT in the preprocessor definitions to use these binaries, which will result in using the correct vc14x prefix instead of vc142 used by default. This is already supposed to be done by wxwidgets.props, at least for the DLL configuration which you seem to use, so I am not sure why it doesn't work for you if you do use this file, but at any rate this symbol must be defined and it isn't in your case.

LLVM build fails on Visual Studio

I generated a Visual Studio 15 2017 project with CMake to compile LLVM and Clang myself. I've tried to build the ALL_BUILD project from Visual Studio (as the getting started page suggested).
But the build failed with a linking error due to (I assume) the linker did not have permission to open a file. This specific file was LLVM-C.def.
The error message:
Cannot Open File '<path_to_build_folder>/build/tools/llvm-shlib/LLVM-C.def
I've tried to give full permission to the user, also tried as admin but did not work.
edit:
The file did not get created because the gen-msvc-exports.py script fails to locate a libllvm-c.args file. It searches the Debug directory for this file but I found it in the $(Configuration) directory. Could this be some Visual Studio configuration/macro problem?
edit2:
Also is there any workaround to get the Clang Tooling library to work on Windows? The precompiled package doesn't contain any headers or static libraries to work with (but for some reason the Linux one does).

Visual C++: LINK : fatal error LNK1104: cannot open file 'libboost_system-vc120-mt-gd-1_55.lib' [duplicate]

This question already has answers here:
fatal error LNK1104: cannot open file 'libboost_system-vc110-mt-gd-1_51.lib'
(12 answers)
Closed 5 years ago.
I unzipped Boost library in
C:\boost
and ran
bootstrap.bat
b2.exe install
via Visual Studio 2017's Developer Command Prompt.
It created two folders for me:
C:\boost\include
C:\boost\lib
Which I added to
VC++ Directories > Include Directories
Linker > General > Additional Library Directories
Respectively.
Now, building the following code:
#define _WIN32_WINDOWS 0x0501
#define _WINSOCK_DEPRECATED_NO_WARNINGS
#include <boost/asio.hpp>
int main()
{
return 0;
}
Produces the following error:
1>main.cpp
1>Unknown compiler version - please run the configure tests and report the results
1>LINK : fatal error LNK1104: cannot open file 'libboost_system-vc120-mt-gd-1_55.lib'
It is surprising for me that VC++ looks for libboost_system-vc120-mt-gd-1_55.lib while the built lib files are:
libboost_system-vc-mt-1_55.lib
libboost_system-vc-mt-gd-1_55.lib
Which is missing a number. Is it related to the warnings poping up during building of Boost?
Unknown compiler version - please run the configure tests and report the results
Update:
Please do not link this question to here. The path is correct as I have run b2.exe with install switch. In addition, the option ( C++ → General → Additional Include Directories parameter) is related to old visual Studio IDE. I know it is very stupid to explain such basics. But unfortunately, I see a strong insist on such a linking.
Update:
It is a shame that a gang of users mark this question as a duplicate by linking to a wrong question while they know they are wrong. If you make a mistake, do not insist on it.
Yes most likely this is related. Boost build is unable to determine Visual Studio compiler version, so it is writing generalized lib names like libboost_system-vc-mt-1_55.lib. Header is trying to use last known version of Visual Studio, for the Boost 1.55 (which is VS2013 or vs120). Try using last version of the boost, it should support VS2017.

Compiling wxWidgets 2.8.12 and 2.9.3 under Visual Studio 11 Beta

I tried tried to compile wxWidgets and got errors pertaining to missing "wx/setup.h" header file.
wxMSW-2.8.12\include\wx/platform.h(196): fatal error C1083: Cannot open include file: 'wx/setup.h': No such file or directory
Are there simple configuration changes that I can make to allow me to compile the libraries?
Environment
Windows 7 64-bit
Visual C++ 11 Beta
fyi: I have successfully built wxWidgets on this machine using Visual C++ 9.
setup.h is actually in the "msvc" directory next to "wx" in "include". You need to include the msvc folder as well and it should work.
Compiling from command line should work, see http://wxwidgets.blogspot.com/2012/02/building-wxwidgets-with-microsoft.html (although I only tested this with 2.9, not 2.8). Notice that you should use a different COMPILER_PREFIX to avoid conflicts between your existing VC9 build and this one, e.g. nmake -f makefile.vc COMPILER_PREFIX=vc100.
If you use project files then you should check that importing VC9 versions worked correctly, perhaps something bad has happened during the import process.