Just starting with D (linking with C++)
sivakon
sivakon at outlook.com
Fri Oct 27 17:14:20 UTC 2017
Hi,
Just started to work with D. Great language.
I want to use C++ libraries for machine learning and deep
learning. How do I add C++ libraries to my d code.
For example,
//sample.cpp
#include <iostream>
using namespace std;
int foo(int i, int j, int k)
{
cout << "i = " << i << endl;
cout << "j = " << j << endl;
cout << "k = " << k << endl;
return 7;
}
//foo.d
extern (C++) int foo(int i, int j, int k);
void main()
{
foo(1,2,3);
}
How do I compile and link each of them to produce the result?
dmd -c foo.d
gcc -c Sample.cpp
Both of them get me .o files. Where do I go from there?
Thanks,
Siv
More information about the Digitalmars-d-learn
mailing list