Using C/C++-DLL in D

S0urc3C0de s0urc3c0de at d.learn
Mon Aug 26 15:12:56 PDT 2013


Hello guys,

I'm trying to use a C++-DLL in D.
I compiled it via GCC, created a .lib-File with implib, but dmd 
keeps telling me that the symbol was undefined.
For test purposes, I created a Test-DLL with just one simple 
function that should output a simple text to the console.

#define TEST_DLL __declspec(dllexport)

#include <iostream>

void TEST_DLL printCpp()
{
	std::cout << "Hello from Cpp-DLL :)" << std::endl;
}

I compiled everything and then tried to call this function from 
inside D.

pragma(lib,"C:\\Path\\to\\Dll\\Test.lib");

extern(C++) void printCpp();

printCpp();

Everything works fine until I try to call the function. dmd says:
Error 42: Symbol Undefined _printCpp

The problem is more or less obvious but I'm not able to solve it.
By the way: this error also occurs when I'm creating the 
.lib-File with a self-written .def-File.
I've searched for hours but didn't find anything that could help 
me solving this, so I hope you guys can help :)


More information about the Digitalmars-d-learn mailing list