Re: Just starting with D (linking with C++)
On Saturday, 28 October 2017 at 02:20:42 UTC, codephantom wrote: On Friday, 27 October 2017 at 17:14:20 UTC, sivakon wrote: I want to use C++ libraries for machine learning and deep learning. How do I add C++ libraries to my d code. on FreeBSD, I use: for C static binding: -- clang -c sample.c dmd -L-lc foo.d sample.o or ldc -L-lc foo.d sample.o for c++ static binding: --- clang++ -c sample.cpp dmd -L-lc++ foo.d sample.o or ldc -L-lc++ foo.d sample.o There is nice article here that was pretty interesting too: https://www.gamedev.net/blogs/entry/2254003-binding-d-to-c/ Thanks! That worked like a charm. Now I can use dlang confidently. Any tips to make it faster cflags etc.
Re: Just starting with D (linking with C++)
On Friday, 27 October 2017 at 17:14:20 UTC, sivakon wrote: I want to use C++ libraries for machine learning and deep learning. How do I add C++ libraries to my d code. on FreeBSD, I use: for C static binding: -- clang -c sample.c dmd -L-lc foo.d sample.o or ldc -L-lc foo.d sample.o for c++ static binding: --- clang++ -c sample.cpp dmd -L-lc++ foo.d sample.o or ldc -L-lc++ foo.d sample.o There is nice article here that was pretty interesting too: https://www.gamedev.net/blogs/entry/2254003-binding-d-to-c/
Re: Just starting with D (linking with C++)
On Friday, 27 October 2017 at 17:43:08 UTC, sivakon wrote: On Friday, 27 October 2017 at 17:21:39 UTC, Joakim wrote: This should work: dmd foo.d Sample.o Just like the C examples from the D blog: https://dlang.org/blog/2017/10/25/dmd-windows-and-c/ Just used this! Got this error! sample.o: In function `foo(int, int, int)': sample.cpp:(.text+0x17): undefined reference to `std::cout' Sorry, just responded quickly from my tablet, didn't try it out first. There's actually a variant of this sample that is run as a test from the dmd compiler testsuite, so it is checked hundreds of times a day for pending pull requests, on all officially supported platforms by the auto-tester: https://auto-tester.puremagic.com/pulls.ghtml?projectid=1 https://github.com/dlang/dmd/blob/master/test/runnable/extra-files/cppb.cpp#L41 https://github.com/dlang/dmd/blob/master/test/runnable/cppa.d#L25 Looking at the D script that runs each compiler test, it adds the following flag for all C++ objects: https://github.com/dlang/dmd/blob/master/test/d_do_test.d#L499 So adding that flag got your example to work for me: dmd -L-lstdc++ foo.d Sample.o
Re: Just starting with D (linking with C++)
On 10/27/17 1:43 PM, sivakon wrote: On Friday, 27 October 2017 at 17:21:39 UTC, Joakim wrote: This should work: dmd foo.d Sample.o Just like the C examples from the D blog: https://dlang.org/blog/2017/10/25/dmd-windows-and-c/ Just used this! Got this error! sample.o: In function `foo(int, int, int)': sample.cpp:(.text+0x17): undefined reference to `std::cout' You need to link against the C++ standard library. On my system, it appears to be -lc++. So in order to pass this value to the linker, use the dmd parameter -L-lc++ In order to find out what the name of the c++ library is, you need to compile a C++ program with the -v option. The linker step will show the library parameters you need to send to dmd. -Steve
Re: Just starting with D (linking with C++)
On Friday, 27 October 2017 at 17:21:39 UTC, Joakim wrote: This should work: dmd foo.d Sample.o Just like the C examples from the D blog: https://dlang.org/blog/2017/10/25/dmd-windows-and-c/ Just used this! Got this error! sample.o: In function `foo(int, int, int)': sample.cpp:(.text+0x17): undefined reference to `std::cout'
Re: Just starting with D (linking with C++)
On Friday, 27 October 2017 at 17:14:20 UTC, sivakon wrote: Hi, Just started to work with D. Great language. I want to use C++ libraries for machine learning and deep learning. How do I add C++ libraries to my d code. For example, //sample.cpp #include using namespace std; int foo(int i, int j, int k) { cout << "i = " << i << endl; cout << "j = " << j << endl; cout << "k = " << k << endl; return 7; } //foo.d extern (C++) int foo(int i, int j, int k); void main() { foo(1,2,3); } How do I compile and link each of them to produce the result? dmd -c foo.d gcc -c Sample.cpp Both of them get me .o files. Where do I go from there? Thanks, Siv This should work: dmd foo.d Sample.o Just like the C examples from the D blog: https://dlang.org/blog/2017/10/25/dmd-windows-and-c/
Just starting with D (linking with C++)
Hi, Just started to work with D. Great language. I want to use C++ libraries for machine learning and deep learning. How do I add C++ libraries to my d code. For example, //sample.cpp #include using namespace std; int foo(int i, int j, int k) { cout << "i = " << i << endl; cout << "j = " << j << endl; cout << "k = " << k << endl; return 7; } //foo.d extern (C++) int foo(int i, int j, int k); void main() { foo(1,2,3); } How do I compile and link each of them to produce the result? dmd -c foo.d gcc -c Sample.cpp Both of them get me .o files. Where do I go from there? Thanks, Siv
Re: [Starting with D] d2html.d issues an error
On Thursday, 25 May 2017 at 15:02:33 UTC, Oleksii wrote: Hi everyone, Could you please help me? I'm get the following error from all.sh: $ /e/D/dmd2/windows/bin/shell.exe all.sh shell 1.05 ..\..\windows\bin\dmd d2html d2html.d(18): Error: module stream is in file 'std\stream.d' which cannot be read import path[0] = E:\D\dmd2\windows\bin\..\..\src\phobos import path[1] = E:\D\dmd2\windows\bin\..\..\src\druntime\import --- errorlevel 1 Where is std\stream.d located, and how can I make DMD find it? Thanks, -- Oleksii Examples will work again in the next DMD release. Recently There's been some changes to fix them all. For now you can copy the new versions from the repository. https://github.com/dlang/dmd/tree/master/samples
Re: [Starting with D] d2html.d issues an error
On Thursday, 25 May 2017 at 15:02:33 UTC, Oleksii wrote: Hi everyone, Could you please help me? I'm get the following error from all.sh: $ /e/D/dmd2/windows/bin/shell.exe all.sh shell 1.05 ..\..\windows\bin\dmd d2html d2html.d(18): Error: module stream is in file 'std\stream.d' which cannot be read import path[0] = E:\D\dmd2\windows\bin\..\..\src\phobos import path[1] = E:\D\dmd2\windows\bin\..\..\src\druntime\import --- errorlevel 1 Where is std\stream.d located, and how can I make DMD find it? Thanks, -- Oleksii std.stream was deprecated and is now apparently removed.
[Starting with D] d2html.d issues an error
Hi everyone, Could you please help me? I'm get the following error from all.sh: $ /e/D/dmd2/windows/bin/shell.exe all.sh shell 1.05 ..\..\windows\bin\dmd d2html d2html.d(18): Error: module stream is in file 'std\stream.d' which cannot be read import path[0] = E:\D\dmd2\windows\bin\..\..\src\phobos import path[1] = E:\D\dmd2\windows\bin\..\..\src\druntime\import --- errorlevel 1 Where is std\stream.d located, and how can I make DMD find it? Thanks, -- Oleksii
Re: Starting with D
On 6/02/11 11:35 PM, Julius wrote: Hi there, i'm all new to D but not new to programming in general. I'd like to try D but i didn't find a nice tutorial yet. I don't want to read a whole book, I just want to get the basics so I can start. Can you help me find something like that? Best regards, Julius What languages do you know already? If it's one of C++, C#, or Java, you might just be able to jump right in, and just reference the website every now and then for specifics.
Re: Starting with D
== Quote from Peter Alexander (peter.alexander...@gmail.com)'s article On 6/02/11 11:35 PM, Julius wrote: Hi there, i'm all new to D but not new to programming in general. I'd like to try D but i didn't find a nice tutorial yet. I don't want to read a whole book, I just want to get the basics so I can start. Can you help me find something like that? Best regards, Julius What languages do you know already? If it's one of C++, C#, or Java, you might just be able to jump right in, and just reference the website every now and then for specifics. I know Java yet. Can you point me to the parts of the website where i should look? I'm somehow unable to find the right site. Thank you.
Re: Starting with D
On 2011-02-07 15:20, Julius wrote: == Quote from Peter Alexander (peter.alexander...@gmail.com)'s article On 6/02/11 11:35 PM, Julius wrote: Hi there, i'm all new to D but not new to programming in general. I'd like to try D but i didn't find a nice tutorial yet. I don't want to read a whole book, I just want to get the basics so I can start. Can you help me find something like that? Best regards, Julius What languages do you know already? If it's one of C++, C#, or Java, you might just be able to jump right in, and just reference the website every now and then for specifics. I know Java yet. Can you point me to the parts of the website where i should look? I'm somehow unable to find the right site. Thank you. Language: http://www.digitalmars.com/d/2.0/lex.html Standard library: http://www.digitalmars.com/d/2.0/phobos/phobos.html -- /Jacob Carlborg
Re: Starting with D
Julius Wrote: Hi there, i'm all new to D but not new to programming in general. I'd like to try D but i didn't find a nice tutorial yet. I don't want to read a whole book, I just want to get the basics so I can start. Can you help me find something like that? Best regards, Julius Well there is the Starting with D page on Wiki4D http://www.wikiservice.at/d/wiki.cgi?D__Tutorial/StartingWithD And also a related page for those comping from another language http://www.wikiservice.at/d/wiki.cgi?ComingFrom Any improvement to these pages as you learn D are welcome.
Starting with D
Hi there, i'm all new to D but not new to programming in general. I'd like to try D but i didn't find a nice tutorial yet. I don't want to read a whole book, I just want to get the basics so I can start. Can you help me find something like that? Best regards, Julius
Re: Starting with D
On Sun, Feb 6, 2011 at 5:35 PM, Julius n0r3...@web.de wrote: Hi there, i'm all new to D but not new to programming in general. I'd like to try D but i didn't find a nice tutorial yet. I don't want to read a whole book, I just want to get the basics so I can start. Can you help me find something like that? Best regards, Julius I say get the book. The D Programming Language is a great book. If you are a university student you'll probably be able to read it for free. I finally got my hard-copy, and it's great.