D.gnu - Linking with object file compiled with g++
- John Fletcher (26/26) Jun 03 2004 Hi
Hi I have started to use the SWIG with DMD (see the last posting. This makes it possible to interface to an existing class written in C++ from D. This may not be what was intended, but it has now become possible. SWIG generates automatically a code layer which is linked in C style which goes between the D and C++ codes. In order to use this it is necessary to compile and link all the modules. Typically there will be the function bodies for the C++ code (say example.cxx) the interface which will be example_wrap.cxx and some d code e.g. example.d. There will be an example application, say app.d. The natural thing is to compile this with g++ -c example.cxx g++ -c example_wrap.cxx dmd app.d example.d example_wrap.o example.o Unfortunately, this does not work as dmd links with gcc rather than g++. It is necessary to compile all the modules e.g. dmd -c app.d (and make sure all the files have different names) and then link with g++, which involves spelling out the D libraries g++ app.o -oapp exampled.o example_wrap.o example.o -lphobos -lpthread -lm Could dmd for Linux have a flag -c++ which would mean that the link step used g++ instead of gcc? That way it could be done in one step. Thanks John Fletcher
Jun 03 2004