[SOLVED]Linking 2 c++ libraries with D
Milvakili
maliy.kayit at gmail.com
Fri Jun 28 11:24:13 PDT 2013
On Friday, 28 June 2013 at 04:21:19 UTC, Milvakili wrote:
> On Friday, 28 June 2013 at 02:34:01 UTC, Juan Manuel Cabo wrote:
>> On 06/27/2013 10:12 PM, Milvakili wrote:
>>> 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++
>>
>> I tried it and it works _perfectly_ for me, but instead of .a I
>> compiled the C++ files to .o
>>
>> g++ -c cpp1.cpp
>> g++ -c cpp2.cpp
>> dmd cpp1.o cpp2.o file.d -L-lstdc++
>>
>> (I had to comment the printf in cpp1.cpp)
>>
>> Running the program prints this output:
>>
>> Testing callinf C++ main from D
>>
>> cbin2 c++ library called from:cbin.cpp
>>
>> I'm on Kubuntu 12.04 64bits, using DMD v2.063.2
>> I have the following libstdc++ packages installed
>> As shown by dpkg -l libstd*|grep ^ii
>>
>> libstdc++6 4.6.3-1ubuntu5
>> libstdc++6-4.4-dev 4.4.7-1ubuntu2
>> libstdc++6-4.6-dev 4.6.3-1ubuntu5
>>
>> G++ version is: g++ (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
>>
>> ldd on the executable shows that it's using these libraries:
>> linux-vdso.so.1 => (0x00007fff989ff000)
>> libstdc++.so.6 =>
>> /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f9c0cbb7000)
>> libpthread.so.0 =>
>> /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f9c0c99a000)
>> librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1
>> (0x00007f9c0c791000)
>> libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1
>> (0x00007f9c0c57b000)
>> libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6
>> (0x00007f9c0c1bc000)
>> /lib64/ld-linux-x86-64.so.2 (0x00007f9c0cedb000)
>> libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6
>> (0x00007f9c0bebf000)
>>
>>
>> Hope that any of this was useful to you!
>>
>> --jm
> Thanks for the answer, I had the same ldd output. The
> interesting thing is the code is working with same libraries
> when we have one dependency.
The problem is I manually build some the libraries and link them.
I fix the problem by using the os standard libraries.
More information about the Digitalmars-d
mailing list