<?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 Re: Linker error:  function already defined in Archicad C++ API</title>
    <link>https://community.graphisoft.com/t5/Archicad-C-API/Linker-error-function-already-defined/m-p/590312#M9222</link>
    <description>&lt;P&gt;Good find!&amp;nbsp; I will dig in to this later today, or perhaps tomorrow and let you know of my success or failure with the same approach.&lt;BR /&gt;&lt;BR /&gt;Thanks for posting the update!&lt;/P&gt;
&lt;P&gt;Chris&lt;/P&gt;</description>
    <pubDate>Wed, 28 Feb 2024 15:52:42 GMT</pubDate>
    <dc:creator>MudratDetector</dc:creator>
    <dc:date>2024-02-28T15:52:42Z</dc:date>
    <item>
      <title>Linker error:  function already defined</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Linker-error-function-already-defined/m-p/589216#M9184</link>
      <description>&lt;P&gt;At build time, I receive many errors that are similar in nature and alert me of breaking the One Definition Rule, as I understand what is happening.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The output from the build is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="cpp"&gt;    Checking File Globs
    ConsultantSheets.cpp
    ConsultantSheetsDialog.cpp
    ConsultantSheetsExcel.cpp
    JHP_Layouts.cpp
    Generating Code...
G:\dev\v27\JHP_Layouts\out\build\x64-Release\JHP_Layouts.obj : error LNK2005: "int __cdecl ACAPI_3D_CreateSight(void * *)" (?ACAPI_3D_CreateSight@@YAHPEAPEAX@Z) already defined in ConsultantSheets.obj

G:\dev\v27\JHP_Layouts\out\build\x64-Release\JHP_Layouts.obj : error LNK2005: "int __cdecl ACAPI_3D_DecomposePgon(int,int * * *)" (?ACAPI_3D_DecomposePgon@@YAHHPEAPEAPEAH@Z) already defined in ConsultantSheets.obj

G:\dev\v27\JHP_Layouts\out\build\x64-Release\JHP_Layouts.obj : error LNK2005: "int __cdecl ACAPI_3D_DeleteSight(void *)" (?ACAPI_3D_DeleteSight@@YAHPEAX@Z) already defined in ConsultantSheets.obj

G:\dev\v27\JHP_Layouts\out\build\x64-Release\JHP_Layouts.obj : error LNK2005: "int __cdecl ACAPI_3D_GetComponent(union API_Component3D *)" (?ACAPI_3D_GetComponent@@YAHPEATAPI_Component3D@@@Z) already defined in ConsultantSheets.obj

G:\dev\v27\JHP_Layouts\out\build\x64-Release\JHP_Layouts.obj : error LNK2005: "int __cdecl ACAPI_3D_GetCurrentWindowSight(void * *)" (?ACAPI_3D_GetCurrentWindowSight@@YAHPEAPEAX@Z) already defined in ConsultantSheets.obj

G:\dev\v27\JHP_Layouts\out\build\x64-Release\JHP_Layouts.obj : error LNK2005: "int __cdecl ACAPI_3D_GetCutPolygonInfo(int,struct API_Plane3D const &amp;amp;,class GS::Array&amp;lt;class Geometry::CustomMultiPolygon2D&amp;lt;class Geometry::PolyId,class Geometry::PolyId,class Geometry::PolyId,class Geometry::PolyId&amp;gt; &amp;gt; *,double *)" (?ACAPI_3D_GetCutPolygonInfo@@YAHHAEBUAPI_Plane3D@@PEAV?$Array@V?$CustomMultiPolygon2D@VPolyId@Geometry@@V12@V12@V12@@Geometry@@@GS@@PEAN@Z) already defined in ConsultantSheets.obj

G:\dev\v27\JHP_Layouts\out\build\x64-Release\JHP_Layouts.obj : error LNK2005: "int __cdecl ACAPI_3D_GetNum(enum API_3DTypeID,int *)" (?ACAPI_3D_GetNum@@YAHW4API_3DTypeID@@PEAH@Z) already defined in ConsultantSheets.obj

G:\dev\v27\JHP_Layouts\out\build\x64-Release\JHP_Layouts.obj : error LNK2005: "int __cdecl ACAPI_3D_SelectSight(void *,void * *)" (?ACAPI_3D_SelectSight@@YAHPEAXPEAPEAX@Z) already defined in ConsultantSheets.obj&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The errors originate from the JHP_Layouts.obj file because of previous definitions in the ConsultantSheets.obj file.&amp;nbsp; The offensive duplicated functions [ACAPI_3D_CreateSight, ACAPI_3D_DecomposePgon, etc] appear to come from GS header files and have never been flagged in previous ArchiCAD versions of this same Add-On or any of the many other Add-Ons that #include the same header files.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;From JHP_Layouts.cpp:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="cpp"&gt;#pragma once
// GS files
#include "ACAPI_MigrationHeader.hpp"
#include "APIEnvir.h"
#include "ACAPinc.h" // also includes APIdefs.h
// my files
#include "JHP_LayoutsResIDs.hpp"
#include "ConsultantSheetsDialog.h"
#include "..\\..\\functions_27.hpp"&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;From ConsultantSheets.cpp&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="cpp"&gt;#pragma once

#include "ACAPI_MigrationHeader.hpp"
#include "APIEnvir.h"
#include "ACAPinc.h"
#include "DG.h"
#include "DGFileDialog.hpp"

#include "JHP_LayoutsResIDs.hpp"
#include "ConsultantSheets.h"

#include "FileSystem.hpp"&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would have also thought that&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="cpp"&gt;#pragma once&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;in each of the .cpp and .h files would prevent the duplcates.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have deleted and rebuilt the CMake Cache.&lt;/P&gt;
&lt;P&gt;I have renamed the &lt;STRONG&gt;..\&amp;lt;project&amp;gt;\out\build\&lt;/STRONG&gt; folder so that it would recreate from scratch.&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;From&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://msdn.microsoft.com/en-us/library/70abkas3.aspx" target="_blank" rel="noopener noreferrer"&gt;MSDN&lt;/A&gt;&lt;SPAN&gt;:&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;I have read that I can&amp;nbsp;&lt;SPAN&gt;"Use /FORCE:MULTIPLE to create an output file whether or not LINK finds more than one definition for a symbol."&amp;nbsp; This seems like a workaround and not a true fix of the problem and should be avoided.&lt;BR /&gt;&lt;BR /&gt;Because if the "ACAPI_*" nature of the duplicates, this seems like something I have gotten away with in previous versions of this add-on and in many others.&amp;nbsp; And I am not sure why this particular add-on is raising such a fuss.&lt;BR /&gt;&lt;BR /&gt;Any point in the right direction would be helpful.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thanks, as always - -&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Chris&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Sep 2024 09:26:09 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Linker-error-function-already-defined/m-p/589216#M9184</guid>
      <dc:creator>MudratDetector</dc:creator>
      <dc:date>2024-09-17T09:26:09Z</dc:date>
    </item>
    <item>
      <title>Re: Linker error:  function already defined</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Linker-error-function-already-defined/m-p/589323#M9186</link>
      <description>&lt;P&gt;Hi Chris,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;#pragma once&lt;/STRONG&gt; should really only go into header files. There's no need to put them in .cpp files. Also you should check if all the headers you include in these files have either the &lt;STRONG&gt;#pragma once&lt;/STRONG&gt; directive or have include guards. (They serve basically the same job).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My guess is that the issue is connected to &lt;STRONG&gt;ACAPI_MigrationHeader.hpp&lt;/STRONG&gt;, since the functions &lt;STRONG&gt;ACAPI_3D_*&lt;/STRONG&gt; were renamed in the AC27 DevKit and so only show up there. Mentioning that, another issue could be that you are somehow accidentally including headers from the AC26 DevKit (where the &lt;STRONG&gt;ACAPI_3D_*&lt;/STRONG&gt; functions are defined also). &lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;So further things to check that I can think of:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Check your include directories in your build setup&lt;/LI&gt;
&lt;LI&gt;Make sure that you don't &lt;STRONG&gt;#include&lt;/STRONG&gt; any .cpp files&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Hope that helps,&lt;BR /&gt;Bernd&lt;/P&gt;</description>
      <pubDate>Thu, 22 Feb 2024 09:22:54 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Linker-error-function-already-defined/m-p/589323#M9186</guid>
      <dc:creator>BerndSchwarzenbacher</dc:creator>
      <dc:date>2024-02-22T09:22:54Z</dc:date>
    </item>
    <item>
      <title>Re: Linker error:  function already defined</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Linker-error-function-already-defined/m-p/589392#M9197</link>
      <description>&lt;P&gt;Hello Bernd,&lt;/P&gt;
&lt;P&gt;You continue to teach me the subtle nuances of this complicated machine that is C++.&lt;/P&gt;
&lt;P&gt;And it is very much appreciated!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;"&lt;STRONG&gt;#pragma once&lt;/STRONG&gt;&amp;nbsp;should really only go into header files."&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;Good info.&amp;nbsp; They didn't teach me that in Architecture School.&amp;nbsp; &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I thought I had verified that all header files have a &lt;STRONG&gt;#pragma once&lt;/STRONG&gt; line at the top.&lt;/P&gt;
&lt;P&gt;I will edit .cpp files and double check the .h and .hpp files&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;"another issue could be that you are somehow accidentally including headers from the AC26 DevKit"&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;This is possible.&amp;nbsp; As our ArchiCAD experience has evolved, I will develop an add-on and when we upgrade ArchiCAD, I copy then edit add-on files from the previous version to the current version.&amp;nbsp; Then copy/edit on to the next version and the next version and so on...&amp;nbsp; I believe that I identify all of the 'typical GS files' and replace them with equivilent versions from the ..\Examples folder from the current API install.&amp;nbsp; I will double check all of these.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;"Check your include directories in your build setup"&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;Not sure exactly how to do that with a CMake project, but will research.&lt;/P&gt;
&lt;P&gt;Should not be too difficult to figure that out.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;"Make sure that you don't&amp;nbsp;&lt;STRONG&gt;#include&lt;/STRONG&gt;&amp;nbsp;any .cpp files"&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;No problems here.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;"Hope that helps,"&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;It always does.&amp;nbsp; Thanks again.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Chris&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Feb 2024 16:08:41 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Linker-error-function-already-defined/m-p/589392#M9197</guid>
      <dc:creator>MudratDetector</dc:creator>
      <dc:date>2024-02-22T16:08:41Z</dc:date>
    </item>
    <item>
      <title>Re: Linker error:  function already defined</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Linker-error-function-already-defined/m-p/590269#M9221</link>
      <description>&lt;P&gt;Hello Mudrat, did you manage to solve this issue? If so I would like to know more about that.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the exact same issue, I'm extending the software to AC27 and I tried to add &lt;STRONG&gt;#pragma once&lt;/STRONG&gt; to the migration header but this didn't solve my issue.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for opening this topic,&lt;/P&gt;&lt;P&gt;Manuel&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Update:&lt;/P&gt;&lt;P&gt;I've solved the issue by writing a fix in the &lt;STRONG&gt;ACAPI_MigrationHeader.hpp&lt;/STRONG&gt;, basically I added before each function definition the keyword&amp;nbsp;&lt;STRONG&gt;inline&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basically as explained &lt;A href="https://learn.microsoft.com/en-us/cpp/error-messages/tool-errors/linker-tools-error-lnk2005?view=msvc-170" target="_self"&gt;there&lt;/A&gt;&amp;nbsp;the problem of this header file is that contains the definition and not just the declaration (usually you split that respectively in .&lt;EM&gt;cpp&lt;/EM&gt; and .&lt;EM&gt;h&lt;/EM&gt;/.&lt;EM&gt;hpp&lt;/EM&gt;). But Microsoft provide an easier solution to that, just prefix the function with the&amp;nbsp;&lt;STRONG&gt;inline&lt;/STRONG&gt; keyword which directly substitues the function call with the function itself during compilation (in this way is not really calling the function).&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="pagliu96_0-1709133962952.png" style="width: 400px;"&gt;&lt;img src="https://community.graphisoft.com/t5/image/serverpage/image-id/54099i9333DCA7A2BF58CE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="pagliu96_0-1709133962952.png" alt="pagliu96_0-1709133962952.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2024 15:31:06 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Linker-error-function-already-defined/m-p/590269#M9221</guid>
      <dc:creator>pagliu96</dc:creator>
      <dc:date>2024-02-28T15:31:06Z</dc:date>
    </item>
    <item>
      <title>Re: Linker error:  function already defined</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Linker-error-function-already-defined/m-p/590312#M9222</link>
      <description>&lt;P&gt;Good find!&amp;nbsp; I will dig in to this later today, or perhaps tomorrow and let you know of my success or failure with the same approach.&lt;BR /&gt;&lt;BR /&gt;Thanks for posting the update!&lt;/P&gt;
&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2024 15:52:42 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Linker-error-function-already-defined/m-p/590312#M9222</guid>
      <dc:creator>MudratDetector</dc:creator>
      <dc:date>2024-02-28T15:52:42Z</dc:date>
    </item>
    <item>
      <title>Re: Linker error:  function already defined</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Linker-error-function-already-defined/m-p/590365#M9224</link>
      <description>&lt;P&gt;There is even easier fix - you can put the function bodies in anonymous namespace. ACAPI_MigrationHeader.hpp will look like this&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;#ifndef __GS_ACAPI_MIGRATION_HEADER_HPP__
#define __GS_ACAPI_MIGRATION_HEADER_HPP__

#include "ACAPinc.h"
#include "Polygon2D.hpp"

#define APIDo_LoadLibrariesID APIEnv_SetLibrariesID
#define APIDo_ShowSelectionIn3DID APIIo_ShowSelectionIn3DID
#define APIDo_ShowAllIn3DID APIIo_ShowAllIn3DID
#define APIDo_EditHierarchicalElemID APIIo_EditHierarchicalElemID
#define APIDo_CancelHierarchicalElemID APIIo_CancelHierarchicalElemID
#define APIDo_OkHierarchicalElemID APIIo_OkHierarchicalElemID

namespace
{
    // all functions go here
}

#endif // __GS_ACAPI_MIGRATION_HEADER_HPP__&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2024 20:44:40 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Linker-error-function-already-defined/m-p/590365#M9224</guid>
      <dc:creator>kolioi</dc:creator>
      <dc:date>2024-02-28T20:44:40Z</dc:date>
    </item>
    <item>
      <title>Re: Linker error:  function already defined</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Linker-error-function-already-defined/m-p/590640#M9228</link>
      <description>&lt;P&gt;Wow, I didn't knew about that, I will definitely try it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for this!&lt;/P&gt;</description>
      <pubDate>Fri, 01 Mar 2024 09:52:08 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Linker-error-function-already-defined/m-p/590640#M9228</guid>
      <dc:creator>pagliu96</dc:creator>
      <dc:date>2024-03-01T09:52:08Z</dc:date>
    </item>
  </channel>
</rss>

