building sample plugin

Development of custom GMAT plugins

building sample plugin

Postby mcj » Thu Apr 11, 2013 2:55 pm

I am trying to build the sample plugin described in "Building a GMAT Plug-in: A Walkthrough Using Visual Studio 2010". I have the project set up as described in the document, but after updating the project's include directories, the build still fails with several inconsistent dll linkage warnings and the following error:

> ..\..\src\command\ConsolePrint.cpp(88): error C2259: 'GmatCommand' : cannot instantiate abstract class due to following members:
> 'bool GmatBase::RenameRefObject(const Gmat::ObjectType,const std::string &,const std::string &)' : is abstract
> ..\..\..\..\GmatDevelopment\src\base\foundation\GmatBase.hpp(126) : see declaration of 'GmatBase::RenameRefObject'
> 'GmatBase *GmatBase::Clone(void) const' : is abstract
> ..\..\..\..\GmatDevelopment\src\base\foundation\GmatBase.hpp(171) : see declaration of 'GmatBase::Clone'
> 'bool GmatBase::HasLocalClones(void)' : is abstract
> ..\..\..\..\GmatDevelopment\src\base\foundation\GmatBase.hpp(461) : see declaration of 'GmatBase::HasLocalClones'
> 'bool GmatCommand::Execute(void)' : is abstract
> ..\..\..\..\GmatDevelopment\src\base\command\GmatCommand.hpp(201) : see declaration of 'GmatCommand::Execute'

Any idea as to what the problem is here?

Thanks.
mcj
 
Posts: 8
Joined: Thu Apr 11, 2013 1:47 pm

Re: building sample plugin

Postby DJCinSB » Thu Apr 11, 2013 9:06 pm

Before starting: Are you building the Release version? If you build debug, you'll get the inconsistent dll linkage messages.

Assuming that part is okay: I can't quite tell where the issue is from the messages you posted. I just did a quick check on the code at svn://svn.code.sf.net/p/gmatplugins/code/trunk, and it seems to be okay with the current code base. Please post your ConsolePrint code files (the .cpp and .hpp files) so I can take a look at them.

Other questions:
Are you using the current GMAT source code, or something else?
What platform are you building on (Windows, Mac, Linux)? I'm assuming Windows since the instructions are written for VS2010, but want to be sure.
DJCinSB
 
Posts: 274
Joined: Mon Jun 09, 2008 3:57 pm

Re: building sample plugin

Postby mcj » Thu Apr 11, 2013 10:00 pm

Yes, I am building the Release version.

I had trouble with the svn client when accessing svn://svn.code.sf.net/p/gmatplugins/code/trunk (I believe it may be a firewall issue), so I used https://gmat.svn.sourceforge.net/svnroo ... ins/trunk/ instead.

I am using the current GMAT source code (as of Monday) and building on Windows with VS2010.
Attachments
ConsolePrint.hpp
(2.16 KiB) Downloaded 278 times
ConsolePrint.cpp
(9.91 KiB) Downloaded 290 times
mcj
 
Posts: 8
Joined: Thu Apr 11, 2013 1:47 pm

Re: building sample plugin

Postby DJCinSB » Fri Apr 12, 2013 6:33 pm

When I use the code you supplied, I see the same issues. It looks like some of the code was garbled there -- for example, in the ConsolePrint assignment operator I see this:
Code: Select all
ConsolePrint & ConsolePrint::operator=(const ConsolePrint &cp)
{
   if (this != &cp)
   {
      GmatCommand operator=(cp)
   }
   
   return *this;
}
where it should be this:
Code: Select all
ConsolePrint & ConsolePrint::operator=(const ConsolePrint &cp)
{
   if (this != &cp)
   {
      GmatCommand::operator=(cp);
   }
   
   return *this;
}

(Notice the missing the "::" and trailing semicolon in this block.) So I poked around a bit with the current code in the repository; the code there is a bit different from yours. I'm attaching the current files from the repository. Please try these and let me know if they fix the issues you are seeing.

ConsolePrint.hpp
Header file
(1.92 KiB) Downloaded 286 times

ConsolePrint.cpp
Source file
(9.91 KiB) Downloaded 285 times
DJCinSB
 
Posts: 274
Joined: Mon Jun 09, 2008 3:57 pm

Re: building sample plugin

Postby mcj » Fri Apr 12, 2013 8:43 pm

The updated code eliminated the error. However, there are still linking errors. I noticed the earlier discussion at http://gmat.ed-pages.com/forum/viewtopic.php?f=2&t=43552#p45136, and the error report from my build looks almost identical. From the earlier discussion, adding _DYNAMICLINK and PRINT_EXPORTS to the list of preprocessor definitions resolved the issue. However, even though these two definitions are included in my project, I still have the following warnings/errors:


1> ConsolePrint.cpp
1>..\..\src\command\ConsolePrint.cpp(40): warning C4273: 'ConsolePrint::ConsolePrint' : inconsistent dll linkage
1> ..\..\src\command\ConsolePrint.hpp(32) : see previous definition of '{ctor}'
1>..\..\src\command\ConsolePrint.cpp(54): warning C4273: 'ConsolePrint::~ConsolePrint' : inconsistent dll linkage
1> ..\..\src\command\ConsolePrint.hpp(33) : see previous definition of '{dtor}'
1>..\..\src\command\ConsolePrint.cpp(67): warning C4273: 'ConsolePrint::ConsolePrint' : inconsistent dll linkage
1> ..\..\src\command\ConsolePrint.hpp(34) : see previous definition of '{ctor}'
1>..\..\src\command\ConsolePrint.cpp(85): warning C4273: 'ConsolePrint::operator =' : inconsistent dll linkage
1> ..\..\src\command\ConsolePrint.hpp(35) : see previous definition of '='
1>..\..\src\command\ConsolePrint.cpp(103): warning C4273: 'ConsolePrint::Clone' : inconsistent dll linkage
1> ..\..\src\command\ConsolePrint.hpp(37) : see previous definition of 'Clone'
1>..\..\src\command\ConsolePrint.cpp(130): warning C4273: 'ConsolePrint::InterpretAction' : inconsistent dll linkage
1> ..\..\src\command\ConsolePrint.hpp(38) : see previous definition of 'InterpretAction'
1>..\..\src\command\ConsolePrint.cpp(167): warning C4273: 'ConsolePrint::Initialize' : inconsistent dll linkage
1> ..\..\src\command\ConsolePrint.hpp(42) : see previous definition of 'Initialize'
1>..\..\src\command\ConsolePrint.cpp(220): warning C4273: 'ConsolePrint::Execute' : inconsistent dll linkage
1> ..\..\src\command\ConsolePrint.hpp(43) : see previous definition of 'Execute'
1>..\..\src\command\ConsolePrint.cpp(243): warning C4273: 'ConsolePrint::RunComplete' : inconsistent dll linkage
1> ..\..\src\command\ConsolePrint.hpp(44) : see previous definition of 'RunComplete'
1>..\..\src\command\ConsolePrint.cpp(257): warning C4273: 'ConsolePrint::BuildReferences' : inconsistent dll linkage
1> ..\..\src\command\ConsolePrint.hpp(59) : see previous definition of 'BuildReferences'
1>..\..\src\command\ConsolePrint.cpp(289): warning C4273: 'ConsolePrint::GetData' : inconsistent dll linkage
1> ..\..\src\command\ConsolePrint.hpp(60) : see previous definition of 'GetData'
1>
1> SampleFactory.cpp
1>..\..\src\factory\SampleFactory.cpp(35): warning C4273: 'SampleFactory::SampleFactory' : inconsistent dll linkage
1> ..\..\src\factory\SampleFactory.hpp(41) : see previous definition of '{ctor}'
1>..\..\src\factory\SampleFactory.cpp(55): warning C4273: 'SampleFactory::~SampleFactory' : inconsistent dll linkage
1> ..\..\src\factory\SampleFactory.hpp(42) : see previous definition of '{dtor}'
1>..\..\src\factory\SampleFactory.cpp(68): warning C4273: 'SampleFactory::SampleFactory' : inconsistent dll linkage
1> ..\..\src\factory\SampleFactory.hpp(43) : see previous definition of '{ctor}'
1>..\..\src\factory\SampleFactory.cpp(93): warning C4273: 'SampleFactory::operator =' : inconsistent dll linkage
1> ..\..\src\factory\SampleFactory.hpp(44) : see previous definition of '='
1>..\..\src\factory\SampleFactory.cpp(128): warning C4273: 'SampleFactory::CreateCommand' : inconsistent dll linkage
1> ..\..\src\factory\SampleFactory.hpp(78) : see previous definition of 'CreateCommand'
1>
1> GmatPluginFunctions.cpp
1>..\..\src\plugin\GmatPluginFunctions.cpp(39): warning C4273: 'GetFactoryCount' : inconsistent dll linkage
1> ..\..\src\plugin\GmatPluginFunctions.hpp(28) : see previous definition of 'GetFactoryCount'
1>..\..\src\plugin\GmatPluginFunctions.cpp(56): warning C4273: 'GetFactoryPointer' : inconsistent dll linkage
1> ..\..\src\plugin\GmatPluginFunctions.hpp(29) : see previous definition of 'GetFactoryPointer'
1>..\..\src\plugin\GmatPluginFunctions.cpp(85): warning C4273: 'SetMessageReceiver' : inconsistent dll linkage
1> ..\..\src\plugin\GmatPluginFunctions.hpp(30) : see previous definition of 'SetMessageReceiver'
1>
1> Creating library ..\..\..\..\GmatDevelopment\application\plugins\libConsolePrint.lib and object ..\..\..\..\GmatDevelopment\application\plugins\libConsolePrint.exp
1>
1>ConsolePrint.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) const ConsolePrint::`vftable'" (__imp_??_7ConsolePrint@@6B@)
1>ConsolePrint.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: virtual bool __thiscall ConsolePrint::RenameRefObject(enum Gmat::ObjectType,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (__imp_?RenameRefObject@ConsolePrint@@UAE_NW4ObjectType@Gmat@@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@1@Z)
1>ConsolePrint.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: virtual bool __thiscall ConsolePrint::HasLocalClones(void)" (__imp_?HasLocalClones@ConsolePrint@@UAE_NXZ)
1>SampleFactory.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) const SampleFactory::`vftable'" (__imp_??_7SampleFactory@@6B@)
mcj
 
Posts: 8
Joined: Thu Apr 11, 2013 1:47 pm

Re: building sample plugin

Postby DJCinSB » Fri Apr 12, 2013 10:18 pm

The declspec settings are made in the SampleDefs.hpp header file. Your project settings should match the settings in that file. If the file reads
Code: Select all
   #ifdef _DYNAMICLINK  // Only used for Visual C++ Windows DLLs
      #ifdef SAMPLE_EXPORTS
         #define SAMPLE_API __declspec(dllexport)
      #else
         #define SAMPLE_API __declspec(dllimport)
      #endif
then you need the preprocessor settings to define the macros _DYNAMICLINK and SAMPLE_EXPORTS, because these preprocessor declarations determine the DLL import/export linkage settings. Check your header file to see if it matches what I pasted above, but if I'm reading what you did correctly and if your header matches mine, you ought to define SAMPLE_EXPORTS rather than PRINT_EXPORTS. Try that, and let me know.
DJCinSB
 
Posts: 274
Joined: Mon Jun 09, 2008 3:57 pm

Re: building sample plugin

Postby mcj » Mon Apr 15, 2013 12:04 pm

The declspec settings were correct in SampleDefs.hpp, but SAMPLE_EXPORTS was not specified in the project's preprocessor settings. After defining SAMPLE_EXPORTS, the project built successfully.

Thanks for the input.
mcj
 
Posts: 8
Joined: Thu Apr 11, 2013 1:47 pm


Return to Plugin Development

Who is online

Users browsing this forum: No registered users and 2 guests

cron