<?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 LNK 2019 Unresolved external symbol in Archicad C++ API</title>
    <link>https://community.graphisoft.com/t5/Archicad-C-API/LNK-2019-Unresolved-external-symbol/m-p/578216#M8935</link>
    <description>&lt;P&gt;I have a function to get the library part index from name.&amp;nbsp;&lt;BR /&gt;The function uses &lt;FONT face="courier new,courier"&gt;GS::DefineConstatntUTF16CharacterOrString()&lt;/FONT&gt;&amp;nbsp;method.&lt;BR /&gt;On building this function is not resolved. And is giving the following error:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;ArchiCADElements.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) unsigned short const * __cdecl GS::DefineConstantUTF16CharacterOrString(char const * &amp;amp;)" (__imp_?DefineConstantUTF16CharacterOrString@GS@@YAPEBGAEAPEBD@Z) referenced in function "int __cdecl GetLibraryIndex(char const *,enum API_LibTypeID)" (?GetLibraryIndex@@YAHPEBDW4API_LibTypeID@@@Z)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;The function is defined in &lt;EM&gt;uchar_t.h&lt;/EM&gt; . Correct me if I am wrong, the corresponding dependency library is :&lt;BR /&gt;&lt;EM&gt;\Support\Modules\GSRoot\Win\GSRootImp.LIB&lt;/EM&gt; which is already included in the project's additional libraries.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How to fix this issue?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;#include "uchar_t.hpp"&lt;BR /&gt;#include "ACAPinc.h"&lt;BR /&gt;#include "APIEnvir.h"&lt;BR /&gt;#include "ArchiCADElements.hpp"&lt;BR /&gt;&lt;BR /&gt;Int32 GetLibraryIndex(const char* name, API_LibTypeID typeId)&lt;BR /&gt;{&lt;BR /&gt;&lt;SPAN&gt; GSErrCode err;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; API_LibPart searchPart;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;BR /&gt; auto str = GS::DefineConstantUTF16CharacterOrString(name);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; GS::ucscpy(searchPart.docu_UName, str);&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; err = ACAPI_LibPart_Search(&amp;amp;searchPart, false);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;BR /&gt; if (searchPart.location != nullptr)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;   delete searchPart.location;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;BR /&gt; if (err == NoError) &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;   return searchPart.index;&lt;/SPAN&gt;&lt;BR /&gt; &lt;BR /&gt;&lt;SPAN&gt; std::cout &amp;lt;&amp;lt; "Could not find library part with name:" &amp;lt;&amp;lt; name &amp;lt;&amp;lt; std::endl;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; return 0;&lt;/SPAN&gt;&lt;BR /&gt;}&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Aathil_0-1701324921403.png" style="width: 999px;"&gt;&lt;img src="https://community.graphisoft.com/t5/image/serverpage/image-id/49879i6604431107AD0FCA/image-size/large?v=v2&amp;amp;px=999" role="button" title="Aathil_0-1701324921403.png" alt="Aathil_0-1701324921403.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 17 Sep 2024 10:45:44 GMT</pubDate>
    <dc:creator>Aathil</dc:creator>
    <dc:date>2024-09-17T10:45:44Z</dc:date>
    <item>
      <title>LNK 2019 Unresolved external symbol</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/LNK-2019-Unresolved-external-symbol/m-p/578216#M8935</link>
      <description>&lt;P&gt;I have a function to get the library part index from name.&amp;nbsp;&lt;BR /&gt;The function uses &lt;FONT face="courier new,courier"&gt;GS::DefineConstatntUTF16CharacterOrString()&lt;/FONT&gt;&amp;nbsp;method.&lt;BR /&gt;On building this function is not resolved. And is giving the following error:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;ArchiCADElements.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) unsigned short const * __cdecl GS::DefineConstantUTF16CharacterOrString(char const * &amp;amp;)" (__imp_?DefineConstantUTF16CharacterOrString@GS@@YAPEBGAEAPEBD@Z) referenced in function "int __cdecl GetLibraryIndex(char const *,enum API_LibTypeID)" (?GetLibraryIndex@@YAHPEBDW4API_LibTypeID@@@Z)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;The function is defined in &lt;EM&gt;uchar_t.h&lt;/EM&gt; . Correct me if I am wrong, the corresponding dependency library is :&lt;BR /&gt;&lt;EM&gt;\Support\Modules\GSRoot\Win\GSRootImp.LIB&lt;/EM&gt; which is already included in the project's additional libraries.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How to fix this issue?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;#include "uchar_t.hpp"&lt;BR /&gt;#include "ACAPinc.h"&lt;BR /&gt;#include "APIEnvir.h"&lt;BR /&gt;#include "ArchiCADElements.hpp"&lt;BR /&gt;&lt;BR /&gt;Int32 GetLibraryIndex(const char* name, API_LibTypeID typeId)&lt;BR /&gt;{&lt;BR /&gt;&lt;SPAN&gt; GSErrCode err;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; API_LibPart searchPart;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;BR /&gt; auto str = GS::DefineConstantUTF16CharacterOrString(name);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; GS::ucscpy(searchPart.docu_UName, str);&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; err = ACAPI_LibPart_Search(&amp;amp;searchPart, false);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;BR /&gt; if (searchPart.location != nullptr)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;   delete searchPart.location;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;BR /&gt; if (err == NoError) &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;   return searchPart.index;&lt;/SPAN&gt;&lt;BR /&gt; &lt;BR /&gt;&lt;SPAN&gt; std::cout &amp;lt;&amp;lt; "Could not find library part with name:" &amp;lt;&amp;lt; name &amp;lt;&amp;lt; std::endl;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; return 0;&lt;/SPAN&gt;&lt;BR /&gt;}&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Aathil_0-1701324921403.png" style="width: 999px;"&gt;&lt;img src="https://community.graphisoft.com/t5/image/serverpage/image-id/49879i6604431107AD0FCA/image-size/large?v=v2&amp;amp;px=999" role="button" title="Aathil_0-1701324921403.png" alt="Aathil_0-1701324921403.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Sep 2024 10:45:44 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/LNK-2019-Unresolved-external-symbol/m-p/578216#M8935</guid>
      <dc:creator>Aathil</dc:creator>
      <dc:date>2024-09-17T10:45:44Z</dc:date>
    </item>
    <item>
      <title>Re: LNK 2019 Unresolved external symbol</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/LNK-2019-Unresolved-external-symbol/m-p/578661#M8951</link>
      <description>&lt;P&gt;If you open&amp;nbsp;uchar_t.hpp header file, you can see that you're not allowed to use the function&amp;nbsp;DefineConstantUTF16CharacterOrString() alone. That function is called from the macro L(str) which takes as a parameter string or character constants only. You can not call the function with a variable because it doesn't have implementation.&lt;/P&gt;&lt;P&gt;In your case, you have to convert multibyte string to wide-character string. There are several ways to do that but maybe the easiest way is to use&amp;nbsp;GS::UniString. Something like this&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;GS::ucscpy(searchPart.docu_UName, GS::UniString(name).ToCStr().Get());&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 02 Dec 2023 21:52:25 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/LNK-2019-Unresolved-external-symbol/m-p/578661#M8951</guid>
      <dc:creator>kolioi</dc:creator>
      <dc:date>2023-12-02T21:52:25Z</dc:date>
    </item>
  </channel>
</rss>

