<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic UniString Compile Error in Archicad C++ API</title>
    <link>https://community.graphisoft.com/t5/Archicad-C-API/UniString-Compile-Error/m-p/255278#M2024</link>
    <description>&lt;DIV class="actalk-migrated-content"&gt;I am writing a small AddOn with uses a UniString constant. However, I copied the line from Element_Test which compiles and runs OK.&lt;BR /&gt;
&lt;PRE&gt;const GS::UniString text = L("This multistyle\nword w\u00E1s created\nby the Element Test example project.");&lt;/PRE&gt;
The above line gives a unresolved external error. Since the line compiles fine in the content of Element_Test, I assume there is a lib or something I need to include.&lt;BR /&gt;&lt;BR /&gt;The errors are:&lt;BR /&gt;&lt;BR /&gt;Severity Code Description Project File Line Suppression State&lt;BR /&gt;Error LNK2019 unresolved external symbol "__declspec(dllimport) unsigned short const * __cdecl GS::DefineConstantUTF16CharacterOrString(wchar_t const *)" (__imp_?DefineConstantUTF16CharacterOrString@GS@@YAPEBGPEB_W@Z) referenced in function "int __cdecl CreateMultiTextElement(struct API_Coord const &amp;amp;,double,struct API_Guid const &amp;amp;)" (?CreateMultiTextElement@@YAHAEBUAPI_Coord@@NAEBUAPI_Guid@@@Z) AddOn C:\Users\gteac\Archicad_C++\Labels\AddOnMain.obj &lt;BR /&gt;&lt;BR /&gt;Any ideas on how to fix??1&lt;/DIV&gt;</description>
    <pubDate>Tue, 14 Sep 2021 07:51:02 GMT</pubDate>
    <dc:creator>poco2013</dc:creator>
    <dc:date>2021-09-14T07:51:02Z</dc:date>
    <item>
      <title>UniString Compile Error</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/UniString-Compile-Error/m-p/255278#M2024</link>
      <description>&lt;DIV class="actalk-migrated-content"&gt;I am writing a small AddOn with uses a UniString constant. However, I copied the line from Element_Test which compiles and runs OK.&lt;BR /&gt;
&lt;PRE&gt;const GS::UniString text = L("This multistyle\nword w\u00E1s created\nby the Element Test example project.");&lt;/PRE&gt;
The above line gives a unresolved external error. Since the line compiles fine in the content of Element_Test, I assume there is a lib or something I need to include.&lt;BR /&gt;&lt;BR /&gt;The errors are:&lt;BR /&gt;&lt;BR /&gt;Severity Code Description Project File Line Suppression State&lt;BR /&gt;Error LNK2019 unresolved external symbol "__declspec(dllimport) unsigned short const * __cdecl GS::DefineConstantUTF16CharacterOrString(wchar_t const *)" (__imp_?DefineConstantUTF16CharacterOrString@GS@@YAPEBGPEB_W@Z) referenced in function "int __cdecl CreateMultiTextElement(struct API_Coord const &amp;amp;,double,struct API_Guid const &amp;amp;)" (?CreateMultiTextElement@@YAHAEBUAPI_Coord@@NAEBUAPI_Guid@@@Z) AddOn C:\Users\gteac\Archicad_C++\Labels\AddOnMain.obj &lt;BR /&gt;&lt;BR /&gt;Any ideas on how to fix??1&lt;/DIV&gt;</description>
      <pubDate>Tue, 14 Sep 2021 07:51:02 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/UniString-Compile-Error/m-p/255278#M2024</guid>
      <dc:creator>poco2013</dc:creator>
      <dc:date>2021-09-14T07:51:02Z</dc:date>
    </item>
    <item>
      <title>Re: UniString Compile Error</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/UniString-Compile-Error/m-p/255279#M2025</link>
      <description>I found out what was causing the compile error. The problem occurs because I was using the default demo CMAKETEXT.txt file as supplied by Graphisoft to generate the VS build file. &lt;BR /&gt;
&lt;BR /&gt;
I created a custom AddOn using snippets from the example files. One included: const GS::UniString  which is a wchar_t. VS now treats that as a built-in function, Archicad, however, defines it as a typedef -- the old method.&lt;BR /&gt;
&lt;BR /&gt;
There is a compiler switch to switch between the two but ON is the default. Graphisoft's Cmake does not include this option so by default, it is ON, which will result in a compile error if UniStrings are used within. The solution was to simply change the property switch to NO which will use the typedef.&lt;BR /&gt;
&lt;BR /&gt;
Others may come across this problem in the future if you use Cmake. The NO option should be included in the Cmake txt file but might then cause other problems. This brings to mind that other compiler switches may be needed for other snippets of code. This should be defined in the examples.&lt;BR /&gt;
&lt;BR /&gt;
Since Graphisoft may be moving, in the future, to use Cmake in their examples, they should recognize that it will make it easier to cut/paste from the examples but then compiler switch settings may be affected depending on what code is being reused. &lt;BR /&gt;
&lt;BR /&gt;
I don't have a solution other than to suggest that more documentation from Graphisoft regarding Cmake's options be included in the demo files. Assuming that Graphisioft decides to use it.&lt;BR /&gt;
&lt;BR /&gt;
Cmake can be very complicated, but as I see it, most of the commands/options are repeated in groups and are readily understandable once explained and only a few are used.&lt;BR /&gt;
&lt;BR /&gt;
Hope this helps someone who may also come across this in the future.</description>
      <pubDate>Sun, 28 Mar 2021 21:10:34 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/UniString-Compile-Error/m-p/255279#M2025</guid>
      <dc:creator>poco2013</dc:creator>
      <dc:date>2021-03-28T21:10:34Z</dc:date>
    </item>
    <item>
      <title>Re: UniString Compile Error</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/UniString-Compile-Error/m-p/255280#M2026</link>
      <description>Thank you for pointing this out. We constantly try to make the compilation as close to Archicad's own compilation as possible. I've already known about this one, but it didn't cause any errors in Add-Ons before.&lt;BR /&gt;
&lt;BR /&gt;
I've modified the CMake template here:&lt;BR /&gt;
&lt;A href="https://github.com/GRAPHISOFT/archicad-addon-cmake/commit/646a7067667586e38eff3e3378d24de7f2c58abc" target="_blank"&gt;&lt;LINK_TEXT text="https://github.com/GRAPHISOFT/archicad- ... e7f2c58abc"&gt;https://github.com/GRAPHISOFT/archicad-addon-cmake/commit/646a7067667586e38eff3e3378d24de7f2c58abc&lt;/LINK_TEXT&gt;&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
Now the build option is turned off by default. Thank you again for the report!</description>
      <pubDate>Mon, 29 Mar 2021 13:51:53 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/UniString-Compile-Error/m-p/255280#M2026</guid>
      <dc:creator>Viktor Kovacs</dc:creator>
      <dc:date>2021-03-29T13:51:53Z</dc:date>
    </item>
  </channel>
</rss>

