5

I'm trying to build a library and link it to an app. Library build is fine, but linking to the app throws these errors:

clipper.lib(clipper.obj) : error LNK2001: unresolved external symbol __CxxFrameHandler4

clipper.lib(clipper.obj) : error LNK2001: unresolved external symbol __GSHandlerCheck_EH4

Cause

According to this and that, the errors might be due to building the lib with VS 2019 toolset, but the app is using VS 2017 toolset.


Tried

I'm building the library with these commands:

cd lib/src/clipper
mkdir build
cd build/
cmake ..
cmake --build . --config Debug
cmake --build . --config Release

Even on VS 2017 Command Prompt, CMake builds the lib for VS 2019:

CMake log screenshot

Question

What is the easiest/fastest way to force CMake to build for VS 2017 rather than 2019?

Megidd
  • 7,089
  • 6
  • 65
  • 142
  • 2
    Just pass proper [CMake generator](https://cmake.org/cmake/help/latest/manual/cmake-generators.7.html) to cmake: `-G"Visual Studio 15 2017"`. – Tsyvarev Feb 11 '21 at 08:29
  • @Tsyvarev Your suggestion resolved the errors by replacing `cmake ..` with `cmake -G "Visual Studio 15 2017 Win64" ..` – Megidd Feb 11 '21 at 08:45

1 Answers1

1

As commented by @Tsyvarev , the errors got resolved by replacing

cmake .. 

with:

cmake  -G "Visual Studio 15 2017 Win64" ..
Megidd
  • 7,089
  • 6
  • 65
  • 142
  • 1
    Pardon my ignorance but where do I add -G "Visual Studio 15 2017 Win64" in the project settings? I am not calling cmake directly but Visual Studio is when I build a project or solution. So, I have not been able to successfully find a way to pass this parameter. – David Bowser May 04 '22 at 17:43
  • @DavidBowser I'm not sure :( I just use `cmake` command. I didn't use the Visual Studio. But I think you ask a new question about it :) – Megidd May 06 '22 at 07:57