How can I force msvc to use x64 architecture?

Completed

Hi, 

I'm using clion 2023.2.1 and MSVC2017 as toolchain for building VTK example.

I set up my toolchain as amd64 architecture, c and c++ compilers as host x64 version.

 

In my cmake settings, I used VS2017 as generator for both debug and release

 

When I build the project, I get the warning 

Could not find a configuration file for package "VTK" that is compatible
 with requested version "".
 The following configuration files were considered but not accepted:
   D:/Development/Libraries/VTK9.1/lib/cmake/vtk-9.1/vtk-config.cmake, version: 9.1.0 (64bit)

This suggests that the vtk library is built under 64bit, but I'm trying to find the packages under a different architecture?(in this case, x86)

I tried to set the platform 

SET(CMAKE_GENERATOR_TOOLSET host=x64)

as suggested here https://cmake.org/cmake/help/v3.8/generator/Visual%20Studio%2015%202017.html

but it doesn't seem to resolve the issue. There are similar questions posted here and here

that suggested changing architecture to amd64 in toolchain setting. I've already done that and it didn't help.

 

My question is:

How can I make sure visual studio uses x64 architecture instead of x86 for build?

Thanks.

0
3 comments

Hello!

If “Architecture” is set to “amd64” in the toolchain settings and the corresponding compilers are used, the resulting executable will be x64. Here is an illustration of this on a default "Hello, World!" project (`File | New Project` > `C++ Executable` > `Create`) :

Also I'm not sure the warning is related to the architecture. Please add message("${VTK_DIR}") to your CMakeLists.txt, then do Tools | CMake | Reset Cache and Reload Project, and share the entire output from the CMake tool window.

0

Anna Falevskaya  Hi Anna,

Thanks for reply. I tried to create a template as you suggested, it doesn't even build successfully, not to mention running. Here's the log:

"C:\Program Files\JetBrains\CLion 2023.2.1\bin\cmake\win\x64\bin\cmake.exe" -DCMAKE_BUILD_TYPE=Debug "-DCMAKE_MAKE_PROGRAM=C:/Program Files/JetBrains/CLion 2023.2.1/bin/ninja/win/x64/ninja.exe" "-DCMAKE_C_COMPILER=C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x64/cl.exe" "-DCMAKE_CXX_COMPILER=C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x64/cl.exe" -G Ninja -S C:\Users\xxx\Downloads\test -B C:\Users\xxx\Downloads\test\cmake-build-debug
-- The C compiler identification is MSVC 19.16.27050.0
-- The CXX compiler identification is MSVC 19.16.27050.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done (2.1s)
-- Generating done (0.0s)
-- Build files have been written to: C:/Users/xxx/Downloads/test/cmake-build-debug
CMake File API: C:\Users\xxx\Downloads\test\cmake-build-debug: failed to load from 'C:\Users\xxx\Downloads\test\cmake-build-debug\.cmake\api\v1\reply\index-2023-09-01T05-05-18-0482.json'

[Failed to reload]

by default clion uses Ninja as generator, but even if I use VS2017 as generator, it's the same result.

Regards 

 

0

Finally I figured out what happened. The toolchain setup is correct, the error occured becaue the file 

C:\Users\xxx\Downloads\test\cmake-build-debug\.cmake\api\v1\reply\index-2023-09-01T05-05-18-0482.json

is being encrypted, thus causing read failure.

Thanks for your help.

0

Please sign in to leave a comment.