Compilation and Linking Issues

 
The recommended way of development is that you should use the given example projects rather than creating your own project. Although these projects are fully configured to API development, we would like to call your attention to some especially important issues.

However if you would like to create a new project you can use the Xcode Template on macOS. All of the following configurations are already set in the projects generated by this.

Compiler directives: macintosh or WINDOWS, ACExtension

Most of the include files require the above directives to be defined.

Platform Settings
macOS set the Preprocessor Macros in Project Info (section: GCC 4.0 – Preprocessing) to

macintosh=1 ACExtension
Windows ACExtension and WINDOWS are usually defined in the source/header files before including the ACAPinc.h header.

Enums Always Int: ON

The structures in APIdefs_xxx.h refer to enum variables, and therefore its size must be strictly defined. (In Xcode this is the default value.)

Struct Alignment: 8 byte

This is required because of compatibility reasons.

  6.1  Please note that from Archicad 9 in the API structures the built-in bool type has been replaced with GS::Bool8. The reason for that is the migration to the new GCC compiler on the MacTel platform, where bool is implemented as a type with a size of 4 bytes rather than 1 byte. In order to maintain the structures aligned, a new type has been introduced in the GSRoot module, which is compiled to 1 byte on both platforms (GS::Bool8 stands for 8-bit boolean type).

Calling convention: __cdecl

The communication between Archicad and add-ons suppose __cdecl type parameter passing. In Visual C++ you should set this compiler flag in the Calling Convention line of the C/C++/Advanced page in Solution Properties. On Macintosh, the only standard calling convention style is used.

File name extension, creator and type

On Windows you must change the standard .dll file extension to .apx (can be adjusted in the Linker/General/Output File tab in Solution Properties).
In Xcode add the following key-value pairs to the Info.plist file:
   <key>CFBundlePackageType</key>
        <string>.APX</string>
        <key>CFBundleSignature</key>
        <string>GSAP</string>
    

Export lists

In order to establish a connection between Archicad and add-ons, you must make export function from your DLL / code fragment. These functions are platform dependent, and are coded in the shipped libraries. The only thing you should do is just export them.

On both platforms the functions named GetExportedFuncAddrs and SetImportedFuncAddrs must be exported. On Windows set the following Additional Options in the Linker/Command Line page in Solution Properties:

/export:GetExportedFuncAddrs,@1 /export:SetImportedFuncAddrs,@2
or use a project_name.def file:

Example.def


GetExportedFuncAddrs
SetImportedFuncAddrs