unittests, dub and libraries

Joe jma at freedomcircle.com
Wed Mar 28 02:16:59 UTC 2018


I'm trying to build a very simple library. For now it just has a 
single class, constructor, destructor and one method.  I added a 
unit test right after the method, declared the targetType to be 
"library" and a buildType of "unittest" (with options 
"unittests", "debugMode", "debugInfo"). When I run

   dub run -b unittest

it builds the library, but then says:

   Target is a library. Skipping execution.

If I compile with ldc2 -unittest the linker throws the error:

   (.text+0x20): undefined reference to `main'

If I add an empty main function to the source file, ldc2/gcc 
manage to create an executable that can be invoked manually and 
it runs through the unit test.

Is this the best that can be done?


More information about the Digitalmars-d-learn mailing list