-fPIC related error compiling hello_world.d with dmd
Hi everyone, I'm almost ashamed to ask help on this... I used dmd/dub on an arch linux machine for some time in the past without any problem. Now I'm experiencing a strange problem after switching to a debian jessie (testing) machine when compiling even the simplest hello_world application :( !! After successfully compiling the source file, I get hundreds of linker error messages of the form: /usr/bin/ld: /usr/lib/x86_64-linux-gnu/libphobos2.a(aaA_52e_53e.o): relocation R_X86_64_32 against symbol `__dmd_personality_v0' can not be used when making a shared object; recompile with -fPIC It looks like the linker cannot link together phobos library modules into the final binary or something like that. I'm using the official package dmd_2.072.0-0_amd64.deb from dlang website, but also the package in debian repositories (version 2.071.2) does the same. Any idea what the problem might be?
Re: -fPIC related error compiling hello_world.d with dmd
On 19/11/2016 2:09 AM, Alessandro wrote: Hi everyone, I'm almost ashamed to ask help on this... I used dmd/dub on an arch linux machine for some time in the past without any problem. Now I'm experiencing a strange problem after switching to a debian jessie (testing) machine when compiling even the simplest hello_world application :( !! After successfully compiling the source file, I get hundreds of linker error messages of the form: /usr/bin/ld: /usr/lib/x86_64-linux-gnu/libphobos2.a(aaA_52e_53e.o): relocation R_X86_64_32 against symbol `__dmd_personality_v0' can not be used when making a shared object; recompile with -fPIC It looks like the linker cannot link together phobos library modules into the final binary or something like that. I'm using the official package dmd_2.072.0-0_amd64.deb from dlang website, but also the package in debian repositories (version 2.071.2) does the same. Any idea what the problem might be? Yup lots of posts about this problem lately. Here's my answer to an identical question[0]. [0] http://forum.dlang.org/post/nvekf6$1pvb$1...@digitalmars.com
Re: -fPIC related error compiling hello_world.d with dmd
On Friday, 18 November 2016 at 13:12:14 UTC, rikki cattermole wrote: On 19/11/2016 2:09 AM, Alessandro wrote: Hi everyone, I'm almost ashamed to ask help on this... I used dmd/dub on an arch linux machine for some time in the past without any problem. Now I'm experiencing a strange problem after switching to a debian jessie (testing) machine when compiling even the simplest hello_world application :( !! After successfully compiling the source file, I get hundreds of linker error messages of the form: /usr/bin/ld: /usr/lib/x86_64-linux-gnu/libphobos2.a(aaA_52e_53e.o): relocation R_X86_64_32 against symbol `__dmd_personality_v0' can not be used when making a shared object; recompile with -fPIC It looks like the linker cannot link together phobos library modules into the final binary or something like that. I'm using the official package dmd_2.072.0-0_amd64.deb from dlang website, but also the package in debian repositories (version 2.071.2) does the same. Any idea what the problem might be? Yup lots of posts about this problem lately. Here's my answer to an identical question[0]. [0] http://forum.dlang.org/post/nvekf6$1pvb$1...@digitalmars.com Thank you for your support Rikki! Indeed, modifying dmd.conf as you suggested solved the problem. Sorry for duplicating posts on this: I searched for fPIC problems beforehand but somehow didn't find that previous post. Is this problem affecting debian users only? Or maybe just those using testing? Would it be an option to modify the configuration of the official .deb package accordingly? Thank you again!
Re: -fPIC related error compiling hello_world.d with dmd
On 19/11/2016 3:05 AM, Alessandro wrote: On Friday, 18 November 2016 at 13:12:14 UTC, rikki cattermole wrote: On 19/11/2016 2:09 AM, Alessandro wrote: Hi everyone, I'm almost ashamed to ask help on this... I used dmd/dub on an arch linux machine for some time in the past without any problem. Now I'm experiencing a strange problem after switching to a debian jessie (testing) machine when compiling even the simplest hello_world application :( !! After successfully compiling the source file, I get hundreds of linker error messages of the form: /usr/bin/ld: /usr/lib/x86_64-linux-gnu/libphobos2.a(aaA_52e_53e.o): relocation R_X86_64_32 against symbol `__dmd_personality_v0' can not be used when making a shared object; recompile with -fPIC It looks like the linker cannot link together phobos library modules into the final binary or something like that. I'm using the official package dmd_2.072.0-0_amd64.deb from dlang website, but also the package in debian repositories (version 2.071.2) does the same. Any idea what the problem might be? Yup lots of posts about this problem lately. Here's my answer to an identical question[0]. [0] http://forum.dlang.org/post/nvekf6$1pvb$1...@digitalmars.com Thank you for your support Rikki! Indeed, modifying dmd.conf as you suggested solved the problem. Sorry for duplicating posts on this: I searched for fPIC problems beforehand but somehow didn't find that previous post. Is this problem affecting debian users only? Or maybe just those using testing? Would it be an option to modify the configuration of the official .deb package accordingly? Thank you again! No problem, its Ubuntu/Debian has moved over to a hardened mode fairly recently and we haven't updated to match it yet.
Re: -fPIC related error compiling hello_world.d with dmd
On Friday, 18 November 2016 at 14:10:43 UTC, rikki cattermole wrote: No problem, its Ubuntu/Debian has moved over to a hardened mode fairly recently and we haven't updated to match it yet. I see. I'm happy to hear things will settle again when the .deb package will be update. By the way, I just realized the problem is still there when using dub to build my project. I added: "dflags": [ "-fPIC", "-defaultlib=libphobos2.so" ] to the dub.json file, but it still doesn't work. Also tried a couple of variants of this setting with no luck. Any suggestion?
Re: -fPIC related error compiling hello_world.d with dmd
On Friday, 18 November 2016 at 14:54:29 UTC, Alessandro wrote: On Friday, 18 November 2016 at 14:10:43 UTC, rikki cattermole wrote: No problem, its Ubuntu/Debian has moved over to a hardened mode fairly recently and we haven't updated to match it yet. I see. I'm happy to hear things will settle again when the .deb package will be update. By the way, I just realized the problem is still there when using dub to build my project. I added: "dflags": [ "-fPIC", "-defaultlib=libphobos2.so" ] to the dub.json file, but it still doesn't work. Also tried a couple of variants of this setting with no luck. Any suggestion? Ok, I figured it out. I forgot to build --force the whole project so that all libraries could get fPIC. Thanks a lot again!
Re: Why is three safety levels need in D?
On Thursday, 17 November 2016 at 17:18:27 UTC, Nordlöw wrote: Why does D need both `@safe`, `@trusted` and `@system` when Rust seems to get by with only safe (default) and `unsafe`? Rust has 3 levels of safety: the code inside unsafe block is @system, and the unsafe block as a whole is a @trusted wrapper providing safe interface to be called by safe code. The rationale for function-level safety is better encapsulation: the function accesses only its parameters and nothing more, but unsafe block has access to all visible local variables of its function, not only those it works with. D supports Rust-style unsafe blocks with @trusted lambdas.
the best language I have ever met(?)
The simpler - the better. After reading "D p.l." by A.Alexandrescu two years ago I have found my past dream. It's theory to start with. That book should be read at least two times especially if you have asm/c/c++/python3/math/physics background, and dealt with Watcom/Symantec C/C++ compilers (best to Walter Bright) with very high optimization goal. No stupid questions, just doing things. That was preface. Now I have server written in D for C++ pretty ancient client. Most things are three times shorter in size and clear (@clear? suffix). All programming paradigms were used. I have the same text in russian, but who has bothered russian(s)? The meaning of all of that is: powerfull attractive language with sufficient infrastructure with future. Just use it. p.s. I'm excused for my primitive english.
Re: the best language I have ever met(?)
On Fri, Nov 18, 2016 at 05:54:52PM +, Igor Shirkalin via Digitalmars-d-learn wrote: > The simpler - the better. > After reading "D p.l." by A.Alexandrescu two years ago I have found my > past dream. It's theory to start with. That book should be read at > least two times especially if you have asm/c/c++/python3/math/physics > background, and dealt with Watcom/Symantec C/C++ compilers (best to > Walter Bright) with very high optimization goal. No stupid questions, > just doing things. > That was preface. > Now I have server written in D for C++ pretty ancient client. Most > things are three times shorter in size and clear (@clear? suffix). All > programming paradigms were used. Welcome, Igor! Your sentiments reflect mine years ago when I first discovered D. I came from a C/C++/Perl background. It was also Andrei's book that got me started; in those early days documentation was scant and I didn't know how to write idiomatic D code. But after I found TDPL, the rest was history. :-) > I have the same text in russian, but who has bothered russian(s)? We have a few Russians on this forum, and I can understand some Russian too. Though on this mailing list English is the language to use. > The meaning of all of that is: powerfull attractive language with > sufficient infrastructure with future. Just use it. Yes, I agree! > p.s. I'm excused for my primitive english. [...] Your English is understandable. That's good enough, I think. :-) T -- If the comments and the code disagree, it's likely that *both* are wrong. -- Christopher
Re: the best language I have ever met(?)
On Friday, 18 November 2016 at 18:14:41 UTC, H. S. Teoh wrote: Welcome, Igor! Hello, Teoh! Your sentiments reflect mine years ago when I first discovered D. I came from a C/C++/Perl background. It was also Andrei's book that got me started; in those early days documentation was scant and I didn't know how to write idiomatic D code. But after I found TDPL, the rest was history. :-) I was a little bit afraid of my missunderstanding in terms of sentiments. You've got me right (I don't quite feel the meaning of that in these non-cyrillic letters:). But what I understand is the path you have walked and what I have in my mind. Simple example about D: I spent two hours to write a line (borrowed from Python), related with lazy calculations, but finally I got it with deep great thinking, and it was like understanding of Moon alienation from Earth. We have a few Russians on this forum, and I can understand some Russian too. Though on this mailing list English is the language to use. Sure, I don't have any doubt of it. I hope to be one of russian understandables here:) Your English is understandable. That's good enough, I think. :-) Thank you, Teoh. That is very important for me to hear. What is your using of D? For me it is tool to develope other tools. Igor
Re: the best language I have ever met(?)
On Fri, Nov 18, 2016 at 07:26:56PM +, Igor Shirkalin via Digitalmars-d-learn wrote: > On Friday, 18 November 2016 at 18:14:41 UTC, H. S. Teoh wrote: > > Welcome, Igor! > Hello, Teoh! > > > > Your sentiments reflect mine years ago when I first discovered D. I > > came from a C/C++/Perl background. It was also Andrei's book that > > got me started; in those early days documentation was scant and I > > didn't know how to write idiomatic D code. But after I found TDPL, > > the rest was history. :-) > I was a little bit afraid of my missunderstanding in terms of > sentiments. You've got me right (I don't quite feel the meaning of > that in these non-cyrillic letters:). But what I understand is the > path you have walked and what I have in my mind. Yes, I meant 'sentiments' as in опыта, not as in сентметальность. :-) > Simple example about D: I spent two hours to write a line (borrowed > from Python), related with lazy calculations, but finally I got it > with deep great thinking, and it was like understanding of Moon > alienation from Earth. Great! Would you like to share the code snippet? [...] > What is your using of D? > For me it is tool to develope other tools. [...] Sadly, I have not been able to use D in a professional capacity. My coworkers are very much invested into C/C++ and have a very high level of skepticism to anything else, in addition to resistance to adding new toolchains (much less languages) to the current projects. So my use of D has mainly been in personal projects. I do contribute to Phobos (the standard library) every now and then, though. It's my way of "contributing to the cause" in the hopes that one day D may be more widespread and accepted by the general programming community. T -- By understanding a machine-oriented language, the programmer will tend to use a much more efficient method; it is much closer to reality. -- D. Knuth
Re: the best language I have ever met(?)
On Fri, Nov 18, 2016 at 11:43:49AM -0800, H. S. Teoh via Digitalmars-d-learn wrote: [...] > Yes, I meant 'sentiments' as in опыта, not as in сентметальность. :-) [...] Sorry, typo. I meant сентиментальности. But I think you understand what I mean. :-) T -- The most powerful one-line C program: #include "/dev/tty" -- IOCCC
Re: the best language I have ever met(?)
On Friday, 18 November 2016 at 19:43:49 UTC, H. S. Teoh wrote: I was a little bit afraid of my missunderstanding in terms of sentiments. You've got me right (I don't quite feel the meaning of that in these non-cyrillic letters:). But what I understand is the path you have walked and what I have in my mind. Yes, I meant 'sentiments' as in опыта, not as in сентметальность. :-) I used to mean 'sentiments' as "сентиметальность", but "опыт - сын ошибок трудных" (Пушкин) is what realy in behind :) Simple example about D: I spent two hours to write a line (borrowed from Python), related with lazy calculations, but finally I got it with deep great thinking, and it was like understanding of Moon alienation from Earth. Great! Would you like to share the code snippet? Sure. We have an array of uint. And we need to get a string of these values in hex separated with ','. In Python it looks like ', '.join(map(hex, array)) array.map!(v=>"%x".format(v)).join(", ") [...] What is your using of D? For me it is tool to develope other tools. [...] Sadly, I have not been able to use D in a professional capacity. My coworkers are very much invested into C/C++ and have a very high level of skepticism to anything else, in addition to resistance to adding new toolchains (much less languages) to the current projects. So my use of D has mainly been in personal projects. I do contribute to Phobos (the standard library) every now and then, though. It's my way of "contributing to the cause" in the hopes that one day D may be more widespread and accepted by the general programming community. T
Re: the best language I have ever met(?)
On Friday, 18 November 2016 at 19:43:49 UTC, H. S. Teoh wrote: I was a little bit afraid of my missunderstanding in terms of sentiments. You've got me right (I don't quite feel the meaning of that in these non-cyrillic letters:). But what I understand is the path you have walked and what I have in my mind. Yes, I meant 'sentiments' as in опыта, not as in сентметальность. :-) I used to mean 'sentiments' as "сентиметальность", but "опыт - сын ошибок трудных" (Пушкин) is what realy in behind :) Simple example about D: I spent two hours to write a line (borrowed from Python), related with lazy calculations, but finally I got it with deep great thinking, and it was like understanding of Moon alienation from Earth. Great! Would you like to share the code snippet? Sure. Let we have a uint_array of values. And we need to get a string of these values in hex separated with ','. In Python it looks like ', '.join(map(hex, uint_array)) After 2 hours of brain breaking (as D newbie) I have come to: uint_array.map!(v=>"%x".format(v)).join(", ") Why 2 hours? Because I have started with 'joiner' function and aftewords found out the 'join'. To my mind there is more simple form for this task in D (about formatting). What is your using of D? Sadly, I have not been able to use D in a professional capacity. My coworkers are very much invested into C/C++ and have a very high level of skepticism to anything else, in addition to resistance to adding new toolchains (much less languages) to the current projects. So my use of D has mainly been in personal projects. I do contribute to Phobos (the Same here. But my coworkers are not addicted to programming at all :) standard library) every now and then, though. It's my way of "contributing to the cause" in the hopes that one day D may be more widespread and accepted by the general programming community. I don't hope about "D some day", I'm sure about that (5 to 30 years). The idea is "I D", not "I C++" :)
Re: the best language I have ever met(?)
On Friday, 18 November 2016 at 19:47:17 UTC, H. S. Teoh wrote: Yes, I meant 'sentiments' as in опыта, not as in сентметальность. :-) [...] Sorry, typo. I meant сентиментальности. But I think you understand what I mean. :-) Oh, I think you understand what you think what I mean :)
Re: the best language I have ever met(?)
On Friday, 18 November 2016 at 19:47:17 UTC, H. S. Teoh wrote: On Fri, Nov 18, 2016 at 11:43:49AM -0800, H. S. Teoh via Digitalmars-d-learn wrote: [...] Yes, I meant 'sentiments' as in опыта, not as in сентметальность. :-) [...] Sorry, typo. I meant сентиментальности. But I think you understand what I mean. :-) T I Think there's a bug. When I'm answerring a message, and if my recipient send me the message, and after I press 'send' button, my message is duplicated. Simple bug to repare.
Re: the best language I have ever met(?)
On Friday, 18 November 2016 at 20:31:57 UTC, Igor Shirkalin wrote: After 2 hours of brain breaking (as D newbie) I have come to: uint_array.map!(v=>"%x".format(v)).join(", ") Why 2 hours? Because I have started with 'joiner' function and aftewords found out the 'join'. To my mind there is more simple form for this task in D (about formatting). sure ;-) import std.stdio; import std.format; void main () { uint[$] a = [42, 69]; string s = "%(%s, %)".format(a); writefln(s); }
Re: the best language I have ever met(?)
On Friday, 18 November 2016 at 21:28:44 UTC, ketmar wrote: On Friday, 18 November 2016 at 20:31:57 UTC, Igor Shirkalin wrote: After 2 hours of brain breaking (as D newbie) I have come to: uint_array.map!(v=>"%x".format(v)).join(", ") Why 2 hours? Because I have started with 'joiner' function and aftewords found out the 'join'. To my mind there is more simple form for this task in D (about formatting). sure ;-) import std.stdio; import std.format; void main () { uint[$] a = [42, 69]; string s = "%(%s, %)".format(a); writefln(s); } Please don't post non-d. People might use it an then complain that it does not work.
Re: the best language I have ever met(?)
On Saturday, 19 November 2016 at 00:28:36 UTC, Stefan Koch wrote: Please don't post non-d. it slipped accidentally, sorry. ;-) for OP: `uint[2] a = [42, 69];` is the correct syntax.
Why double not? (!!)
Why do I see double `not` operators sometimes in D code? An example it the last post of this thread. http://forum.dlang.org/thread/ktlpnikvdwgbvfaam...@forum.dlang.org import core.sys.windows.windows : GetConsoleCP; bool hasConsole = !!GetConsoleCP(); Thanks.
Re: Why double not? (!!)
On Saturday, 19 November 2016 at 03:52:02 UTC, Ryan wrote: Why do I see double `not` operators sometimes in D code? An example it the last post of this thread. http://forum.dlang.org/thread/ktlpnikvdwgbvfaam...@forum.dlang.org import core.sys.windows.windows : GetConsoleCP; bool hasConsole = !!GetConsoleCP(); Thanks. It's a more concise way of writing: GetConsoleCP() != 0 You can do this in C/C++ as well (and presumably some other languages).
Creating shared library on Monodevelop with MonoD, Implib problem
I am on Ubuntu. I try to create a very basic (one empty function declaration) shared library for testing. MonoD (version 2.14.5), generates a command line similar to following: dmd -debug -gc "myclass.d" "-I/usr/include/dmd" "-L/IMPLIB:/home/user/Projects/Router/bin/Debug/libRouter.a" "-odobj/Debug" "-of/home/user/Projects/Router/bin/Debug/libRouter.so" -fPIC -defaultlib=libphobos2.so /usr/bin/ld: cannot find /IMPLIB:/home/user/Projects/Router/bin/Debug/libRouter.a: No such file or directory collect2: error: ld returned 1 exit status Error: linker exited with status 1 I don't understand why it is trying to link the project with libRouter.a. Am I missing something?
Re: fPIC Error
On Thursday, 3 November 2016 at 06:11:48 UTC, rikki cattermole wrote: [Environment32] DFLAGS=-I/usr/include/dmd/phobos -I/usr/include/dmd/druntime/import -L-L/usr/lib/i386-linux-gnu -L--export-dynamic -fPIC -defaultlib=libphobos2.so [Environment64] DFLAGS=-I/usr/include/dmd/phobos -I/usr/include/dmd/druntime/import -L-L/usr/lib/x86_64-linux-gnu -L--export-dynamic -fPIC -defaultlib=libphobos2.so I'm sorry bit that's horseshit. I'm not compiling everything with fPIC because DMD can't get it's act straight.
what is mean? ( Offset 78887H Record Type 00C3)
hello. i got a problem when i build my source code(windows7 x64 / DMD32 D Compiler v2.072.0), here: OPTLINK (R) for Win32 Release 8.00.17 Copyright (C) Digital Mars 1989-2013 All rights reserved. http://www.digitalmars.com/ctg/optlink.html main.obj(main) Offset 78887H Record Type 00C3 Error 1: Previous Definition Different : _D4Xaru8logArrayFAyaAAyaZv Error: linker exited with status 337446008 what is mean? i don't understand.
Re: Why double not? (!!)
On Saturday, 19 November 2016 at 04:54:22 UTC, Xinok wrote: On Saturday, 19 November 2016 at 03:52:02 UTC, Ryan wrote: Why do I see double `not` operators sometimes in D code? An example it the last post of this thread. http://forum.dlang.org/thread/ktlpnikvdwgbvfaam...@forum.dlang.org import core.sys.windows.windows : GetConsoleCP; bool hasConsole = !!GetConsoleCP(); Thanks. It's a more concise way of writing: GetConsoleCP() != 0 You can do this in C/C++ as well (and presumably some other languages). Hmmm... thinking about it, it does make perfect sense. The first ! converts it to bool, the other inverts it back to it's positive/negative state. Although it's a combination of logic I wouldn't have through of unless I saw it. But testing the result on any number (float, double or real) won't be precise and would take far longer (and more complicated) using another method.
Re: what is mean? ( Offset 78887H Record Type 00C3)
On Saturday, 19 November 2016 at 06:54:37 UTC, xky wrote: hello. i got a problem when i build my source code(windows7 x64 / DMD32 D Compiler v2.072.0), here: OPTLINK (R) for Win32 Release 8.00.17 Copyright (C) Digital Mars 1989-2013 All rights reserved. http://www.digitalmars.com/ctg/optlink.html main.obj(main) Offset 78887H Record Type 00C3 Error 1: Previous Definition Different : _D4Xaru8logArrayFAyaAAyaZv Error: linker exited with status 337446008 what is mean? i don't understand. Idk. If you're using x64 then you should be using the microsoft linker. are you invoking the linker manually? are
Re: Why double not? (!!)
On Saturday, 19 November 2016 at 06:58:38 UTC, Era Scarecrow wrote: On Saturday, 19 November 2016 at 04:54:22 UTC, Xinok wrote: On Saturday, 19 November 2016 at 03:52:02 UTC, Ryan wrote: Why do I see double `not` operators sometimes in D code? An example it the last post of this thread. http://forum.dlang.org/thread/ktlpnikvdwgbvfaam...@forum.dlang.org import core.sys.windows.windows : GetConsoleCP; bool hasConsole = !!GetConsoleCP(); Thanks. It's a more concise way of writing: GetConsoleCP() != 0 You can do this in C/C++ as well (and presumably some other languages). Hmmm... thinking about it, it does make perfect sense. The first ! converts it to bool, the other inverts it back to it's positive/negative state. Although it's a combination of logic I wouldn't have through of unless I saw it. But testing the result on any number (float, double or real) won't be precise and would take far longer (and more complicated) using another method. It's a very common practice in any language that uses truthy/falsey, especially seen a lot in Javascript. Generally it's not necessary unless you want to be explicit about checking upon a bool. Ex. auto hasModel = !!view.model; if (hasModel) { ... } Could very well just be auto model = view.model; if (model) { }