Using actor framework in Visual Studio

126 views Asked by At

This is my first time working with actor framework in windows. I am having success building the examples using CMake however when I open the generated project using Visual Studio I am seeing many errors. It is strange because I can build and run the project in VS even though it reports hundreds of syntax errors.

I have tried two different approaches, both with similar results:

Approach I: Conan

  1. Create new directory then add hello_world.cpp and this conanfile.txt
[requires]
caf/0.18.5

[generators]
cmake
  1. Create build directory and from there run conan install ..
  2. Added the following CMakeLists.txt in the working directory:
cmake_minimum_required(VERSION 2.8.12) 
project(CafHelloWorld)
    
set(CMAKE_CXX_STANDARD 17) 
set(CMAKE_CXX_STANDARD_REQUIRED True)
    
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) 
conan_basic_setup()
    
add_executable(hello_world hello_world.cpp) 
target_link_libraries(hello_world ${CONAN_LIBS})
  1. run cmake .. G "Visual Studio 16"
  2. run cmake --build . --config Release

The exe runs great but when I open the project in VS, it reports hundreds of syntax errors (mostly in the caf header files). I can build and run the project from VS though.

Approach II: Source

  1. Download source from github and add build directory
  2. Open CMake GUI and point to source and build directories
  3. Press "Configure" and select "Visual Studio 16 2019"
  4. CMake complains about OpenSSL. I disable the OpenSSL Module(don't think I will use it) then hit configure again. Error goes away.
  5. Hit "Generate" then "Open Project"

The result is similar. hello_world.cpp has a handful of errors and Visual Studio reports hundreds more from the caf header files. The project builds though. Am I missing something obvious?

1

There are 1 answers

0
man.ysato On

I had a similar situation, but I solved it with the following

Right click on the project name in the solution explorer of visual studio, open the properties and change the "Platform Toolset" in the general tab from "Vsual Studio 2022 (v144)" to "Visual Studio 2019 (v142)".

As a side note, when I asked Microsoft Copilot, they also told me to check the following

Check that the include directory settings are correct

Delete the hidden .vs folder in the solution directory, then start Visual Studio again and re-build the intellisence file (I am not an English speaker, so I am using a translator to answer this question.)

Translated with DeepL.com (free version)