Linking 2 c++ libraries with D

Milvakili maliy.kayit at gmail.com
Thu Jun 27 18:12:07 PDT 2013


I have successfully link c++ with D.

Have ever when I create a dependency:
cpp2->cpp1->d

when compile with dmd

dmd cpp1.a cpp2.a file.d -L-lstdc++

It compiles but when I run it I get

relocation error: "some path": symbol _ZNSsC1EPKcRKSaIcE, version 
GLIBCXX_3.4 not defined in file libstdc++.so.6 with link time 
reference

When I replace the string variable of bar2 in cbin2.cpp  with an 
interger, code runs.

here is the files:

****dfile***
import std.stdio;
extern (C++) void foo(int i, int j, int k) {
   writefln("i = %s", i);
   writefln("j = %s", j);
   writefln("k = %s", k);
   writefln("looks ok");
}

extern (C++) void bar();

void main(){
   writeln("Testing callinf C++ main from D\n");
   bar();
}
****cbin.cpp***
#include <vector>
#include <iostream>
using namespace std;
void bar2(string i);

void bar(){
   bar2("cbin.cpp");
   printf("PRINTF:In cbin code\n");
}
****cbin2.cpp
#include <vector>
#include <iostream>

using namespace std;

void bar2(string s){
   cout << "cbin2 c++ library called from:" << s;
}


More information about the Digitalmars-d mailing list