Author Topic: Error from Linker : LNK1120: unresolved externals  (Read 1889 times)

0 Members and 1 Guest are viewing this topic.

melomayo

  • Guest
Error from Linker : LNK1120: unresolved externals
« on: May 19, 2014, 05:53:28 am »
Why do I get this error from Linker?

Error 1 error LNK2019:
unresolved external symbol "public: static void __cdecl CKMLIBLayer::FreezeAll(void)" (?FreezeAll@CKMLIBLayer@@SAXXZ)
referenced in function "public: static void __cdecl CKMLIB2015App::KM_MyGroupTest(void)" (?KM_MyGroupTest@CKMLIB2015App@@SAXXZ) J:\...\acrxEntryPoint.obj

Error 2 error LNK1120:
1 unresolved externals   J:\...\x64\Debug\KM_KMLIB2015.arx

thank you in advance for your help  :wink:

File: acrxEntryPointc.pp
Code - C++: [Select]
  1. #include "StdAfx.h"
  2. #include "resource.h"
  3. #include "dbmain.h"
  4.  
  5. #include "Layer.h"
  6.  
  7. //-----------------------------------------------------------------------------
  8.  
  9. #define szRDS _RXST("")
  10.  
  11. //-----------------------------------------------------------------------------
  12.  
  13. class CKMLIB2015App : public AcRxArxApp {
  14.  
  15. public:
  16.  
  17. CKMLIB2015App () : AcRxArxApp ()
  18. {
  19. }
  20.  
  21. virtual AcRx::AppRetCode On_kInitAppMsg   ( void *pkt )
  22. {
  23. return AcRxArxApp::On_kInitAppMsg ( pkt ) ;
  24. }
  25. virtual AcRx::AppRetCode On_kUnloadAppMsg ( void *pkt )
  26. {
  27. return AcRxArxApp::On_kUnloadAppMsg ( pkt ) ;
  28. }
  29. virtual void RegisterServerComponents     ( )
  30. {
  31.  
  32. }
  33.  
  34. static void KM_MyGroupTest       ( )
  35. {
  36. ::acutPrintf( _T("\nTest called: " ));
  37.  
  38. CKMLIBLayer::FreezeAll();
  39. }
  40. } ;
  41.  
  42. IMPLEMENT_ARX_ENTRYPOINT  ( CKMLIB2015App )
  43. ACED_ARXCOMMAND_ENTRY_AUTO( CKMLIB2015App, KM_MyGroup, Test, Test, ACRX_CMD_MODAL, NULL )
  44.  
  45.  

File: Layer.cpp

Code - C++: [Select]
  1. #include "StdAfx.h"
  2. #include "resource.h"
  3. #include "dbmain.h"
  4.  
  5. class CKMLIBLayer
  6. {
  7. public:
  8.  
  9. CKMLIBLayer ( void )
  10. {
  11.  
  12. }
  13.  
  14.      ~CKMLIBLayer ( void )
  15. {
  16.  
  17. }
  18.  
  19.  
  20. static void FreezeAll ( )
  21. {
  22. AcDbLayerTable       *pTable  = NULL;
  23. AcDbLayerTableRecord *pRecord = NULL;
  24.  
  25. Acad::ErrorStatus     acEs;
  26.  
  27. // open the layertable in the current drawing
  28.  
  29. if( (acEs = acdbHostApplicationServices()->workingDatabase()->getLayerTable( pTable, AcDb::kForRead )) != Acad::eOk )
  30. {
  31. acutPrintf( _T("\nCouldn't get the layer table: %s" ), acadErrorStatusText( acEs ));
  32.  
  33. return;
  34. }
  35.  
  36. AcDbObjectId currentId = acdbHostApplicationServices()->workingDatabase()->clayer();
  37.  
  38. AcDbObjectId recordId;
  39.  
  40. AcDbLayerTableIterator *pIter;
  41.  
  42. for( pTable->newIterator( pIter ); !pIter->done(); pIter->step() )
  43. {
  44. acEs = pIter->getRecordId(recordId);
  45.  
  46. if( acEs != Acad::eOk )
  47. {
  48. acutPrintf( _T("Cannot get layer %s"),acadErrorStatusText( acEs ));
  49. continue;
  50. }
  51.  
  52. if( recordId == currentId )
  53. continue;
  54.  
  55. AcDbObject *pObj = NULL;
  56.  
  57. acEs    = acdbOpenAcDbObject( pObj, recordId, AcDb::kForWrite );
  58. pRecord = AcDbLayerTableRecord::cast( pObj );
  59.  
  60. if( acEs != Acad::eOk || pRecord == NULL)
  61. {
  62. acutPrintf(_T("Cannot open layer %s"),acadErrorStatusText(acEs));
  63.  
  64. if( pObj != NULL )
  65. pObj->close();
  66.  
  67. continue;
  68. }
  69.  
  70. acEs = pRecord->setIsFrozen( Adesk::kTrue );
  71.  
  72. pRecord->close();
  73.  
  74. if( acEs != Acad::eOk )
  75. {
  76. acutPrintf(_T("Cannot set layer to be frozen %s"),acadErrorStatusText(acEs));
  77. }
  78.  
  79. pRecord = NULL;
  80. }
  81.  
  82. delete pIter;
  83.  
  84. pTable->close();
  85. }
  86. };
  87.  

File: Layer.h
Code - C++: [Select]
  1. #pragma once
  2.  
  3. class CKMLIBLayer
  4. {
  5. public:
  6.  
  7. CKMLIBLayer ( void );
  8.   ~CKMLIBLayer ( void );
  9.  
  10. static void FreezeAll ();
  11. };
  12.  
  13.  

melomayo

  • Guest
Re: Error from Linker : LNK1120: unresolved externals
« Reply #1 on: May 19, 2014, 08:57:56 am »
Problem was solved

Code - C++: [Select]
  1. #include "StdAfx.h"
  2. #include "resource.h"
  3. #include "dbmain.h"
  4. #include "Layer.h"
  5.  
  6. //class CKMLIBLayer
  7. //{
  8. // public:
  9.  
  10. CKMLIBLayer::CKMLIBLayer()
  11. {
  12.  
  13. }
  14.  
  15.   CKMLIBLayer::~CKMLIBLayer (  )
  16. {
  17.  
  18. }
  19.  
  20.  
  21. void CKMLIBLayer::FreezeAll ( )
  22. {
  23. AcDbLayerTable       *pTable  = NULL;
  24. AcDbLayerTableRecord *pRecord = NULL;
  25.  
  26. Acad::ErrorStatus     acEs;
  27.  
  28. // open the layertable in the current drawing
  29.  
  30. if( (acEs = acdbHostApplicationServices()->workingDatabase()->getLayerTable( pTable, AcDb::kForRead )) != Acad::eOk )
  31. {
  32. acutPrintf( _T("\nCouldn't get the layer table: %s" ), acadErrorStatusText( acEs ));
  33.  
  34. return;
  35. }
  36.  
  37. AcDbObjectId currentId = acdbHostApplicationServices()->workingDatabase()->clayer();
  38.  
  39. AcDbObjectId recordId;
  40.  
  41. AcDbLayerTableIterator *pIter;
  42.  
  43. for( pTable->newIterator( pIter ); !pIter->done(); pIter->step() )
  44. {
  45. acEs = pIter->getRecordId(recordId);
  46.  
  47. if( acEs != Acad::eOk )
  48. {
  49. acutPrintf( _T("Cannot get layer %s"),acadErrorStatusText( acEs ));
  50. continue;
  51. }
  52.  
  53. if( recordId == currentId )
  54. continue;
  55.  
  56. AcDbObject *pObj = NULL;
  57.  
  58. acEs    = acdbOpenAcDbObject( pObj, recordId, AcDb::kForWrite );
  59. pRecord = AcDbLayerTableRecord::cast( pObj );
  60.  
  61. if( acEs != Acad::eOk || pRecord == NULL)
  62. {
  63. acutPrintf(_T("Cannot open layer %s"),acadErrorStatusText(acEs));
  64.  
  65. if( pObj != NULL )
  66. pObj->close();
  67.  
  68. continue;
  69. }
  70.  
  71. acEs = pRecord->setIsFrozen( Adesk::kTrue );
  72.  
  73. pRecord->close();
  74.  
  75. if( acEs != Acad::eOk )
  76. {
  77. acutPrintf(_T("Cannot set layer to be frozen %s"),acadErrorStatusText(acEs));
  78. }
  79.  
  80. pRecord = NULL;
  81. }
  82.  
  83. delete pIter;
  84.  
  85. pTable->close();
  86. }
  87.  
  88. //};
  89.