cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 
2024 Technology Preview Program

2024 Technology Preview Program:
Master powerful new features and shape the latest BIM-enabled innovations

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

Compile error on Mac

dushyant
Enthusiast

Hi, 

I'm getting a compile error on Mac:

 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/usr/include/c++/v1/locale:2827:22: no member named 'GS_realloc' in namespace 'std'; did you mean simply 'GS_realloc'?

    _Tp* __t = (_Tp*)std::realloc(__owns ? __b.get() : 0, __new_cap);

The same code compiles fine with MSVC on windows.

Anyone faced this error?

 

Thanks.

21 REPLIES 21

Hi,

That's a weird error and I haven't experienced it myself.
But a different thing I noticed is, that you are using the MacOSx14.0 devkit. I would try to use the same as the recommended deployment target. So that's 10.15 for AC25+.
It's a bit tough to get older macOS devkits installed. I think I got them from here: https://github.com/phracker/MacOSX-SDKs
but proceed at your own risk ^^

 

Hope that helps,
Bernd

Bernd Schwarzenbacher - Archicad Add-On Developer - Get Add-Ons & Archicad Tips on my Website: Archi-XT.com
dushyant
Enthusiast

Hi Bernd,

Thanks for your reply. I'm building for AC27. Where do you find which version no. is the recommended for it?

I thought there was a mention of it somewhere in the API docu or at the site of the SDK downloads. But now I can't find it anymore.


But you can find the LSMinimumSystemVersion for the libraries in the AC API SDK or also for the Archicad main app on macOS. This is one entry in the Info.plist files. For AC27 all of these say "10.15.0". Here's the main one on my machine:

/Applications/GRAPHISOFT/Archicad 27/Archicad 27.app/Contents/Info.plist

 

Bernd Schwarzenbacher - Archicad Add-On Developer - Get Add-Ons & Archicad Tips on my Website: Archi-XT.com

Okay, that's the same for me (10.15.0). I tried with MacOSX10.15.sdk and the project failed to configure.

 

-- The CXX compiler identification is unknown

 

In CMakeLists.txt: set(CMAKE_OSX_SYSROOT "/path/to/MacOSX-SDKs/MacOSX10.15.sdk")

 

Btw, could this lead to compatibility issues with higher versions of MacOS when distributed?

I think the main issue could be, that your XCode version is not compatible with the SDK.

You could try changing the MinimumSDKVersion version to 10.15 there as well:

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Info.plist

This fixed it for me IIRC and I'm running XCode 14.1. For editing the plist file you can use e.g. the command line utility "plutil" and convert to xml first and then back to binary. Also make a backup of this Info.plist in case anything goes wrong.

Sorry if all of this is vague. It's been a while since I've last done this and my notes on it are a bit scattered.

 

Also you might need to adapt the Info.plist in your builds of the Add-On itself to match.

 

About compatibility: I can't say for sure, but I'm not too worried about it myself, since GS distributes AC with this exact same MinimumSystemVersion.


Best,
Bernd

Bernd Schwarzenbacher - Archicad Add-On Developer - Get Add-Ons & Archicad Tips on my Website: Archi-XT.com

Hi, 

I changed the MinimumSDKVersion to 10.15 in XCode's Info.plist.

I moved the MacOSX10.15.sdk dir to /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs
passed the option to CMake to use MacOSX10.15.sdk, but it doesn't seem to look there for it.

Are you working in the XCode IDE itself? How do you set it to use any particular SDK? Do you use CMake?

 

Update: I made CMake to use the specific SDK but it fails to generate the project with it..

 

OK, so good news and bad news:

  • Good news: The issue should definitely be with the MacOSX14.0 SDK, since in the file mentioned in your original question, it uses std::realloc instead of realloc as in older DevKits like the ones I have installed (13.0 and 10.13). And in the file Archicad SDK there's following line in the file Support/Modules/GSRoot/GSMalloc.hpp:
    #define realloc(p, s)	GS_realloc(p, s)​
    And the combination explains the issue, since GS_realloc really isn't in the std namespace. And switching the MacOSX SDK to an older version should really help.

    Another possibility could be to also put GS_realloc in the std namespace or add another #define std::realloc(p, s) GS_realloc(p, s) before any includes. Not sure if any of it works and it's very hacky, but could be a temporary solution.
  • Bad news: I'm actually using MacOSX13.0 SDK instead of the MacOSX10.13/10.15 devkits I thought I used. I have 10.13 installed and I'm sure I've used it before, but probably through one XCode update I got 13.0 installed and it was switched then. So I don't have recent experience about switching the MacOSX SDK apparently 😅 (I'm using Cmake as well).

What's your error in cmake during the build generation now?

Bernd Schwarzenbacher - Archicad Add-On Developer - Get Add-Ons & Archicad Tips on my Website: Archi-XT.com

Hi,

Thanks for the info.

I discovered that the error occurs when I include <iostream> library. So it could be related to the std namespace somehow (though I don't have any components in use from the library, and I could disable it).

 

I tried: 

#define realloc(p, s)	GS_realloc(p, s)​

That didn't help.

 

CMake just fails to identify the manually supplied MacOSX SDK as a valid one. I tried with a custom path and also by placing the SDK in the same place as the main SDK in XCode: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs

It fails in both cases. I removed the SDKs so I don't have the actual error messages to quote. 

 

How do you supply the custom SDK to your CMake? Are you using CMake within the XCode IDE?

 

Anyway it seems I can get around this error by just avoiding the iostream library and use the latest SDK (v14) from XCode.

 

Thanks for the help and the info.

 

 

Good to hear that you found a way to get around the error!

Supplying another line of

#define realloc(p, s)	GS_realloc(p, s)​

won't help, since it's already defined like this anyway.

I suggested to try the following (note the extra std:: in front of realloc😞

#define std::realloc(p, s)	GS_realloc(p, s)​

 
On Mac I'm using CMake sometimes with XCode and sometimes with Visual Studio Code.

About switching the macOS SDK, there are some hints in the readme on the github repo I provided above: https://github.com/phracker/MacOSX-SDKs
But I haven't tested it.

Bernd Schwarzenbacher - Archicad Add-On Developer - Get Add-Ons & Archicad Tips on my Website: Archi-XT.com