digitalmars.D - Problems linking with C++ using g++?
- Nick (18/18) Nov 07 2005 I'm trying to build a simple interface between D with C++. I've made the
- Nick (7/11) Nov 07 2005 Nevermind, I found the answer. The problem is that dmd uses gcc to link,...
- R'emy Mou:eza (3/11) Nov 08 2005 You may need to link with the libstdc++ if you're working with both g++ ...
- Robert Jones (2/16) Dec 14 2005 how usable is that tool and where can i get it?
I'm trying to build a simple interface between D with C++. I've made the following short test: -- dtest.d -- import std.stdio; extern(C) void cfunc(); extern(C) void dfunc() {} void main() { cfunc(); } -- ctest.cpp -- extern "C" void dfunc(); extern "C" void cfunc() { dfunc(); } Compiling: $ g++ -c ctest.cpp $ dmd dtest.d ctest.o gives the linker error: tmp.o:(.eh_frame+0x11): undefined reference to `__gxx_personality_v0' Does anybody have any hints? It works perfectly if I rename .cpp to .c and use gcc instead. I have gcc 4.0.2. Nick
Nov 07 2005
In article <dkoiic$nnc$1 digitaldaemon.com>, Nick says... [...]$ g++ -c ctest.cpp $ dmd dtest.d ctest.o gives the linker error: tmp.o:(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'Nevermind, I found the answer. The problem is that dmd uses gcc to link, not g++, and that may cause some problems when linking c++ programs. For some reason it worked with my actual program once I tested it. Anyway, the safest solution (in case anyone stumbles onto this later) is to link using g++, not dmd. Nick
Nov 07 2005
In article <dkoiic$nnc$1 digitaldaemon.com>, Nick says... [...]You may need to link with the libstdc++ if you're working with both g++ and dmd. I also made a tool to wrap C++ header files to D and when I was working with gdc it would not work unless I use the -lstdc++ flag.$ g++ -c ctest.cpp $ dmd dtest.d ctest.o gives the linker error: tmp.o:(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'Nevermind, I found the answer. The problem is that dmd uses gcc to link, not g++, and that may cause some problems when linking c++ programs.
Nov 08 2005
R'emy Mou:eza said the following on 11/8/2005 3:22 AM:how usable is that tool and where can i get it?In article <dkoiic$nnc$1 digitaldaemon.com>, Nick says... [...]You may need to link with the libstdc++ if you're working with both g++ and dmd. I also made a tool to wrap C++ header files to D and when I was working with gdc it would not work unless I use the -lstdc++ flag.$ g++ -c ctest.cpp $ dmd dtest.d ctest.o gives the linker error: tmp.o:(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'Nevermind, I found the answer. The problem is that dmd uses gcc to link, not g++, and that may cause some problems when linking c++ programs.
Dec 14 2005