Closed snosov1 closed 9 years ago
Sorry, the problem turned out to be in name mangling.
When I used project(clib C)
, it worked fine. When I used extern "C" {}
on the C++ side, it also worked fine.
However, it doesn't seem to work with C++ mangling. Even after I change extern(C) int sqr(int x);
to extern(C++) int sqr(int x);
Do you know what could be the problem?
OS: Ubuntu 12.04 x86_64 C++ compiler: g++-4.6.3 D compiler: DMD 2.065.0
Does the extern(C++) work okay if you do the following?
g++ -o sqr.o -c sqr.cpp
dmd app.d sqr.o
Yes, it does. And also, it works with cmake build if I do make clean && make
.
Hi! Thanks a lot for doing this work!
I have a problem though. What I'm trying to do is to have a project, that has a D application and a C library.
So, on the top level I have app.d:
And CMakeLists.txt:
In the clib subdirectory I have sqr.cpp:
sqr.di:
And CMakeLists.txt:
The error I get upon building: