Linking Error Building Opennurbs, VS 2022 with V142 toolset installed

Per Building opennurbs_public with VisualStudio2022 results in compiler error - openNURBS - McNeel Forum, opennurbs should compile properly using VS 2022.

It doesn’t seem to compile out of the box and I tried a few things unsuccessfully.

Steps:
I have VS2022 and tthe 2019 build toolset installed and screenshotted as described in
Rhino 7 C++ SDK requires Visual Studio 2019 - Rhino Developer - McNeel Forum
Win 11 Pro.

Rhino 7 and 8 WIP installed:
rhino_en-us_7.32.23221.10241
rhino_en-us_8.0.23227.12305

I don’t have the Rhino SDK installed yet because of
https://mcneel.myjetbrains.com/youtrack/issue/RH-76312
(marked closed but it apparently hasn’t made public reelase yet, downloading from newest)- the opennurbs instructions don’t ask for this to be installed so I hope it’s unrelated.

Clone mcneel/opennurbs: OpenNURBS libraries allow anyone to read and write the 3DM file format without the need for Rhino. (github.com)
Open it in VS.
It will offer to update things to current libraries. Decline, both prompts.

Build zlib. (this works)
Build the dynamic opennurbs library.
Each line item compile succeeds, but the link fails with:
1>Linking with zlib.lib in “C:/dev/3rdprty/opennurbs/bin/x64/Debug”
1>opennurbs_zlib_memory.cpp
1>Generating Code…
1>opennurbs.rc(10): fatal error RC1015: cannot open include file ‘afxres.h’.

If I update the Windows SDK but not the (V142) toolset:

I get the same result:
“1>opennurbs.rc(10): fatal error RC1015: cannot open include file ‘afxres.h’.”

And, finally, if I update both to the latest versions as Studio recommends (which the aforementioned thread said not to but I’m just being thorough)…
I get a good number of compile errors similar to:
“1>C:\dev\3rdprty\delme5\opennurbs_font.cpp(1681,14): error C2220: the following warning is treated as an error
1>C:\dev\3rdprty\delme5\opennurbs_font.cpp(1681,14): warning C4189: ‘bKeepDWriteFont’: local variable is initialized but not referenced”

There are a lot of hits for this problem on google,
https://www.google.com/search?q=afxres.h

I do have the tools for MFC V142 installed:

Hi @Nathan_Bossett,

I have Visual Studio 2022 (Version 17.6.5) installed, along with the V142 Platform Toolset.

After cloning openNURBS:

git clone https://github.com/mcneel/opennurbs.git

I launch VS2022 and open the opennurbs_public.sln solution.

When prompted to Retarget Projects, I click ‘No’.

image

I then press F7 to build the solution.

========== Build: 9 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

OpenNURBS projects targets the Windows SDK version 10.0.

<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>

So you’ll want to make sure this is installed via the Visual Studio Installer.

– Dale

WIP SDK’s should be available weekly, just like the WIP. You just don’t seen any announcements.

https://www.rhino3d.com/download/rhino-sdk/8/wip

– Dale

Ok, I installed the Win SDK 10: I don’t remember that being mentioned as a dependency.

I tried compiling the project in two ways (fresh copy of the repo for each):
When prompted to retarget, choose no to both.
When prompted to retarget, accept the default (latest) for the Win 10 SDK and no for the VS toolset.

Both still result in:
opennurbs.rc(10): fatal error RC1015: cannot open include file ‘afxres.h’.

Taking that one step further regarding this header file, I do have one copy of it:

With the version I downloaded shortly before making that post, it still refused to install. I just (6PM PST I think, 23 Aug) downloaded a newer version.

It installs, thank you.

It doesn’t clear up this build/link problem, though.

Hi @Nathan_Bossett,

If you haven’t installed the ATL and MFC libraries for the x86/x64 for the the toolsets you’ve installed, then do so.

Attached is what I have installed currently. The VS Installer exported this.

vs2022.txt (5.1 KB)

– Dale

I have installed MFC for the V142 toolset as instructed. I don’t see V142 versions of the ATL tools available in the VS 2022 installer.

Here are screenshots from the installer.

(and scrolling down to the end- you can see the second to last item from the first list in the second)

Screenshot (153)

Hi @Nathan_Bossett,

Look under SDK’s, libraries, and frameworks

– Dale

Attached is what I have installed currently. The VS Installer exported this.

vs2022.txt (5.1 KB)

Ok, I looked through your manifest. I don’t see those particular MFC and ATL V142 (Visual Studio 2019) tools installed at all, though there is the general 2019 pack

“Microsoft.VisualStudio.ComponentGroup.VC.Tools.142.x86.x64”,

I do see a bunch of V141, (Visual studio 2017) ttoolsets installed:

“Microsoft.VisualStudio.Component.VC.v141.ATL”,
“Microsoft.VisualStudio.Component.VC.v141.CLI.Support”,
“Microsoft.VisualStudio.Component.VC.v141.MFC”,