digitalmars.D - Linking 2 c++ libraries with D
- Milvakili (41/41) Jun 27 2013 I have successfully link c++ with D.
- Adam D. Ruppe (4/7) Jun 27 2013 did you compile the C++ and run the program on the same computer?
- Milvakili (2/10) Jun 27 2013 Yes everything is on same computer and the library.
-
Milvakili
(3/14)
Jun 27 2013
When I changed the string to vector
it still runs. Error is - Juan Manuel Cabo (28/36) Jun 27 2013 I tried it and it works _perfectly_ for me, but instead of .a I
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++ It compiles but when I run it I get relocation error: "some path": symbol _ZNSsC1EPKcRKSaIcE, version GLIBCXX_3.4 not defined in file libstdc++.so.6 with link time reference When I replace the string variable of bar2 in cbin2.cpp with an interger, code runs. here is the files: ****dfile*** import std.stdio; extern (C++) void foo(int i, int j, int k) { writefln("i = %s", i); writefln("j = %s", j); writefln("k = %s", k); writefln("looks ok"); } extern (C++) void bar(); void main(){ writeln("Testing callinf C++ main from D\n"); bar(); } ****cbin.cpp*** #include <vector> #include <iostream> using namespace std; void bar2(string i); void bar(){ bar2("cbin.cpp"); printf("PRINTF:In cbin code\n"); } ****cbin2.cpp #include <vector> #include <iostream> using namespace std; void bar2(string s){ cout << "cbin2 c++ library called from:" << s; }
Jun 27 2013
On Friday, 28 June 2013 at 01:12:11 UTC, Milvakili wrote:relocation error: "some path": symbol _ZNSsC1EPKcRKSaIcE, version GLIBCXX_3.4 not defined in file libstdc++.so.6 with link time referencedid you compile the C++ and run the program on the same computer? This is complaining that it couldn't find the specific version of std::basic_string it was looking for in the c++ standard lib.
Jun 27 2013
On Friday, 28 June 2013 at 01:39:49 UTC, Adam D. Ruppe wrote:On Friday, 28 June 2013 at 01:12:11 UTC, Milvakili wrote:Yes everything is on same computer and the library.relocation error: "some path": symbol _ZNSsC1EPKcRKSaIcE, version GLIBCXX_3.4 not defined in file libstdc++.so.6 with link time referencedid you compile the C++ and run the program on the same computer? This is complaining that it couldn't find the specific version of std::basic_string it was looking for in the c++ standard lib.
Jun 27 2013
On Friday, 28 June 2013 at 01:42:35 UTC, Milvakili wrote:On Friday, 28 June 2013 at 01:39:49 UTC, Adam D. Ruppe wrote:When I changed the string to vector<int> it still runs. Error is specific to string, currentOn Friday, 28 June 2013 at 01:12:11 UTC, Milvakili wrote:Yes everything is on same computer and the library.relocation error: "some path": symbol _ZNSsC1EPKcRKSaIcE, version GLIBCXX_3.4 not defined in file libstdc++.so.6 with link time referencedid you compile the C++ and run the program on the same computer? This is complaining that it couldn't find the specific version of std::basic_string it was looking for in the c++ standard lib.
Jun 27 2013
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
Jun 27 2013
On Friday, 28 June 2013 at 02:34:01 UTC, Juan Manuel Cabo wrote:On 06/27/2013 10:12 PM, Milvakili wrote: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.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
Jun 27 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:The problem is I manually build some the libraries and link them. I fix the problem by using the os standard libraries.On 06/27/2013 10:12 PM, Milvakili wrote: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.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
Jun 28 2013