Bind C++ class to DLang : undefined reference to `Canvas::Foo()'

zoujiaqing zoujiaqing at gmail.com
Mon Jul 13 09:34:35 UTC 2020


I changed string to basic_string.

///  source/main.d
import std.stdio;
import core.stdcpp.string;

extern(C++)
{
     class Canvas
     {
         @disable this();

         static Canvas Create();

         basic_string!ubyte Foo();

         basic_string!ubyte Bar();
     };
}

void main()
{
	Canvas canvas = Canvas.Create();

	writeln(canvas.Foo());

	writeln(canvas.Bar());
}

Error ...

# dmd source/main.d Canvas.o -L-lstdc++ && ./main
[1]    49078 segmentation fault  ./main



More information about the Digitalmars-d-learn mailing list