Menu

simple_plugin in a dll project

Help
2004-05-14
2004-06-18
  • Nicolas Gendron

    Nicolas Gendron - 2004-05-14

    Hi, here's what I want to do :

    I have a dll project containing DCOM objects and other simple classes that I want to test.  So, I decided to build my test with the dll to be able to use a graphical interface to see results.

    I made a new Build/configuration called CPPUNIT.  I add "SimplePlugIn.cpp" for this configuration and built it.  The compiler said that I had more than one defenition of dllmain.  So, I define a preprocessor macro called CPPUNIT_TESTS and put #ifndef CPPUNIT_TESTS to "isolate" the project dllmain function.

    After that, the linker still give me some errors such as : unresolved external symbol "public: __thiscall CppUnit::TestPlugInDefaultImpl::TestPlugInDefaultImpl(void)" (??0TestPlugInDefaultImpl@CppUnit@@QAE@XZ).  So, I put "cppunitd_dll.lib" in "Object/library module" under tab "link" of project setting.

    It builds without errors :-) nice.
    So I decided to add some basic tests.  I took "ExampleTestCase.cpp" and "ExampleTestCase.cpp" from hostapp example project, add those two files to my project and compile it.

    I get a lot of errors at linking.

    ExampleTestCase.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::
    allocator<char> >(void)" (__imp_??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ)
    ExampleTestCase.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::a
    llocator<char> >(char const *,class std::allocator<char> const &)" (__imp_??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@PBDABV?$allocator@D@1@@Z)
    ExampleTestCase.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::a
    llocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (__imp_??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z)
    ExampleTestCase.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __thiscall std::basic_ostringstream<char,struct std::char_traits<char>,class std::allocator<char> >::`vbase destructor'(void)" (__imp_??_D?$basic_ost
    ringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ)

    could somebody tell me what I'm doing wrong?

     
    • Nicolas Gendron

      Nicolas Gendron - 2004-05-14

      I got the error, it was the compiler option /nodefaultlib that was not correct.
      :-)

      Nic

       
    • Baptiste Lepilleur

      If you just want to share test from a dll and don't need to register specific listener, don't bother with the CPPUNIT_PLUGIN_IMPLEMENT macro, just use the dll version of cppunit. Since test register in a static variable, they are automatically shared between the runner and dll.

      See the documentation of that macro to see how to export only test listener.

      As for the linking issue, you're not using the same version of the CRT as cppunit (see FAQ).

      Baptiste.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.