Archicad C++ API
About Archicad add-on development using the C++ API.

unordered_map, APIinc.h and errors

MudratDetector
Enthusiast

I have errors at build time, many of which are tied back to unordered_map.

 

 

 

 

C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\include\unordered_map(38,23): error C2061: syntax error: identifier '_Node_handle' 
  C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\include\unordered_map(63): message : see reference to class template instantiation 'std::_Umap_traits<_Kty,_Ty,_Tr,_Alloc,_Mfl>' being compiled [G:\dev\v27\JHP_Audit\out\build\x64-Release\JHP_Audit.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\include\unordered_map(39,41): error C2059: syntax error: '>' 
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\include\unordered_map(67,35): error C2143: syntax error: missing ',' before '<' 
  C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\include\unordered_map(405): message : see reference to class template instantiation 'std::unordered_map<_Kty,_Ty,_Hasher,_Keyeq,_Alloc>' being compiled [G:\dev\v27\JHP_Audit\out\build\x64-Release\JHP_Audit.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\include\unordered_map(67,60): error C2065: '_Uhash_compare': undeclared identifier 
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\include\unordered_map(67,36): error C2974: 'std::_Umap_traits': invalid template argument for '_Tr', type expected 
  C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\include\unordered_map(30): message : see declaration of 'std::_Umap_traits' [G:\dev\v27\JHP_Audit\out\build\x64-Release\JHP_Audit.vcxproj]

 

 

 

 


Here are results of a grep on my project files for unordered_map.

MudratDetector_0-1708454139866.png


settings.json >>> the one instance is associated with "files.associations": {}
CL.read.1.tlog >>> is a log file that ties ..\TOOLS\MSVC\14.29.30133\INCLUDE\UNORDERED_MAP back to ACADinc.h
unordered_map.txt >>> is a file I saved of the text in the output window after the build
ACAPinc.h >>> appears to be the culpret.  The two instances in this file are the #include and the usage as an argument in ACAPI_AutoText_GetNoteAutotexts().  This copy of ACAPinc.h is dated 8/14/2023 3:14:52 PM and appears to be the latest.

I have read about a different bug with unordered_map and a fix HERE that implies using VS17.1

MudratDetector_1-1708455300246.png


And another different bug with a workaround HERE that implies removing options from the compiler.

MudratDetector_3-1708456179822.png

 


I am using VS2019, Tool set 142, Version 16.11.30
Would an upgrade to VS17 address my issue too?
I sort of expected that somethign like this was being handled by

 

 

 

#include	"ACAPI_MigrationHeader.hpp"

 

 

 


Anyone else ever experience this?

Thanks to all - 
Chris

Chris Gilmer
Intel i9-12950HX CPU @ 2.30GHz, 16 cores
NVIDIA GeForce RTX 3080
48.0 GB RAM
Windows 10 Pro 64-bit
13 REPLIES 13

Hi Chris,

 

That's a tough one. At first glance the bugs you've found seem unrelated to me.
But they got me thinking that maybe the C++ versions are not matching.
What C++ version are you using? (C++11, C++14, C++17, or something else?)

And what AC Devkit are you using?

Best,
Bernd

MudratDetector
Enthusiast

I am developing AC27 Add-ons in Visual Studio 2019 using Tool Set 142.

 

I am verifying in CMakeLists.txt file with this:

message( STATUS ">>> AC_API_DEVKIT_DIR: $ENV{AC_API_DEVKIT_DIR}")
message (STATUS "Archicad Version: ${ACVersion}")

With output of:

1> [CMake] -- >>> AC_API_DEVKIT_DIR: C:/Program Files/GRAPHISOFT/API Development Kit 27.3001/Support
1> [CMake] -- Archicad Version: 27


I am verifying in CMakeCommon.cmake file with this:

 

set (AddOnSourcesFolder ${addOnFolder}/Src)
get_filename_component (AddOnSourcesFolderAbsolute "${CMAKE_CURRENT_LIST_DIR}/${AddOnSourcesFolder}" ABSOLUTE)
get_filename_component (AddOnResourcesFolderAbsolute "${CMAKE_CURRENT_LIST_DIR}/${AddOnResourcesFolder}" ABSOLUTE)
message(STATUS ">>> " ${CMAKE_CURRENT_SOURCE_DIR} " >>> " ${AddOnSourcesFolder})
message(STATUS ">>> Value of AddOnSourcesFolderAbsolute is:  " ${AddOnSourcesFolderAbsolute})
message(STATUS ">>> Value of AddOnResourcesFolderAbsolute is:  " ${AddOnResourcesFolderAbsolute})

 

With output of:

 

1> [CMake] -- >>> G:/dev/v27/JHP_Audit >>> ./Src
1> [CMake] -- >>> Value of AddOnSourcesFolderAbsolute is:  G:/dev/v27/JHP_Audit/Src
1> [CMake] -- >>> Value of AddOnResourcesFolderAbsolute is:  G:/dev/v27/JHP_Audit

 

All of that appears to dial me in to AC27.

 

I believe the choice of C++17 is being managed also in CMakeCommon.cmake file with this:

if (${acVersion} LESS 27)
    target_compile_features (${target} PUBLIC cxx_std_14)
else ()
    target_compile_features (${target} PUBLIC cxx_std_17)
endif ()

I feel I have a marginal understanding of the difference between C++17 features being available in VS2019 and choosing to compile as C++17 with the code snippet above.  Is there a setting in VS2019 that needs to be made to ensure that the C++17 version of the language features are being used?  I know I have seen this choice in VS properties in older, pre-cmake projects but not sure if this handles that choice in the cmake world we are working in these days.

 

Are there other places I can look to find the answers to your questions above?

 

And, as always, thanks bunches...

Chris

 

Chris Gilmer
Intel i9-12950HX CPU @ 2.30GHz, 16 cores
NVIDIA GeForce RTX 3080
48.0 GB RAM
Windows 10 Pro 64-bit

The parts of your setup you've posted look good to me. It seems like setting the compile features is done in a CMake function. So as long as that function is then applied to your target (from the error messages I assume it's called JHP_Audit) you should be good.


Just to be sure, it's sometimes good to clear the CMake cache (In Visual Studio: "Project -> Clear Cache and Reconfigure") or even delete the whole build folder and just configure again.

Otherwise I don't have any further ideas to investigate unfortunately.


Best,
Bernd

MudratDetector
Enthusiast

Hey Bernd,

 

Thanks for continuing this conversation.  It is a real head scratcher...

"I assume it's called JHP_Audit"

correct

 

"it's sometimes good to clear the CMake cache"

have done that several times

 

"or even delete the whole build folder and just configure again"

have done that a couple of times

 

My latest take on this is that I have somewhere in the CMake config files something that is triggereing this behavior that is a leftover relic from the multitude of edits that I did when trying to get this to work when source files were in multiple directories.  I have archived and downloaded the current CMake templates from the GS git now that I have pushed all source files into a single directory.  I am going to put this project back together from scratch.  I notice that the current CMake templates are modified from what I originally downloaded from the GS git.

 

Maybe when I copy/paste the archived source code into this new project in bits and pieces I can see what/when/where it happens.  Fingers crossed.

 

Thanks again for your attention to this effort I am making,

Chris

 

Chris Gilmer
Intel i9-12950HX CPU @ 2.30GHz, 16 cores
NVIDIA GeForce RTX 3080
48.0 GB RAM
Windows 10 Pro 64-bit
Viktor Kovacs
Graphisoft
Graphisoft

Could you show some examples on how do you use the unordered_map? Are you sure that the unordered_map and the type you use it with known in the file (you have all the necessary includes)?

MudratDetector
Enthusiast

Hello Viktor,

 

[please note edits.  40 years of AutoCAD is a hard habit to break...]

Thanks for showing an interest in my little problem here.  What follows is how unordered_map is being used in this project.  It appears that I am not using unordered_map() specifically in my code, but I do #include ACADinc.h  #include ACAPinc.h, which is the only reference I can find to it when I search 'Entire solution'.

 

In ACADinc.h ACAPinc.h [dated 8/14/2023 3:14 PM]:

MudratDetector_3-1708705890904.png

 

In ACADinc.h ACAPinc.h [dated 8/14/2023 3:14 PM]:

MudratDetector_4-1708706026095.png

Maybe I have a different configuration issue that does not allow me to find ACAPI_AutoText_GetNoteAutotexts?  I also notice that all the function definitions above and below this one have the same 'not found' message and green squiggle underline.  Could that be an indication of why my build is being so grumpy about this???  Not sure...

 

Regardless, a search in VS...

MudratDetector_1-1708705612241.png

...only finds the two results above, and then this.

MudratDetector_0-1708705597098.png

 

The attached .pdf file is output from build.  Maybe that helps too...

 

Thanks for looking in to this!

Chris

Chris Gilmer
Intel i9-12950HX CPU @ 2.30GHz, 16 cores
NVIDIA GeForce RTX 3080
48.0 GB RAM
Windows 10 Pro 64-bit
Viktor Kovacs
Graphisoft
Graphisoft

Seems like something is really off with your setup. Based on the log it's not only about unordered_map, it's not able to find such basic things as fabs. As a last resort I would try to reinstall/repair Visual Studio 2019 to see if it solves the problem.

MudratDetector
Enthusiast

Thanks for the quick reply Viktor.  I will give that a go later this afternoon...

Chris

Chris Gilmer
Intel i9-12950HX CPU @ 2.30GHz, 16 cores
NVIDIA GeForce RTX 3080
48.0 GB RAM
Windows 10 Pro 64-bit

To all who are interested,

.

ArchiCAD 27 | Win 10 | VS 2019, Tool Set v142
.

- - created a virtual machine on my box with Hyper-V

- - installed VS 2019

- - installed ArchiCAD 27

- - installed API Development Kit 27.3001

- - installed Python 3.11.8 with 'include in PATH' option

- - archived current version of Add-On project

- - clone this git repo with the command, for latest CMake template files:

git clone https://github.com/GRAPHISOFT/archicad-addon-cmake.git --recurse-submodules

- - copy all previous source code from archive files into current project

- - verify #include "ACAPI_MigrationHeader.hpp" is in all .cpp files that I add to the project.

- - build

 

The build failed with output as documented in the attached .pdf file. These errors are similar to the previous errors except they start in APICommon.c with what seems to be pretty standard stuff, for example ..\GSRoot\StandardTypeTraits.hpp, before the errors areonce again found in unordered_map.  It appears that a clean install if Visual Studio does not remedy these seemingly typical, boiler plate type issues.

 

 

All questions, observations, or comments are welcomed. Many thanks to all that have helped and continue to help with this.

Chris

Chris Gilmer
Intel i9-12950HX CPU @ 2.30GHz, 16 cores
NVIDIA GeForce RTX 3080
48.0 GB RAM
Windows 10 Pro 64-bit