pragma (lib, "") doesn't work on linux. I would expect for instance pragma (lib, "dl") to make libdl be linked in, aka -ldl There is nothing in the docs about this not working on Linux. I also think it is a silly feature to have as optional for implementations.
Bill Baxter wrote: > d-bugmail@puremagic.com wrote: >> http://d.puremagic.com/issues/show_bug.cgi?id=1663 >> >> Summary: pragma(lib, "") don't work on linux >> Product: D >> Version: 1.023 >> Platform: Other >> OS/Version: Linux >> Status: NEW >> Severity: normal >> Priority: P2 >> Component: DMD >> AssignedTo: bugzilla@digitalmars.com >> ReportedBy: larsivar@igesund.net >> >> >> pragma (lib, "") doesn't work on linux. >> >> I would expect for instance >> >> pragma (lib, "dl") to make libdl be linked in, aka -ldl >> >> There is nothing in the docs about this not working on Linux. I also >> think it is a silly feature to have as optional for implementations. > > dsss implements a pragma(link,...) which does basically that. > It's really what pragma(lib,...) should have been to begin with. > > From > http://svn.dsource.org/projects/dsss/trunk/docs/README.software_engineers > """ > The -ll flag is only useful for explicitly linking libraries into > binaries. If the DSSS-implemented library depends on a non-DSSS library, > the dependency must be specified in a .d file which is part of the > DSSS-implemented library. This is done with the 'link' pragma, which > must always be specified within version(build): > > version (build) { > pragma(link, "example"); > } > > The above example will cause any binary linked against the > DSSS-implemented library to link against the library named libexample.a > (or example.lib on Windows). > """ I know, but I'm after a solution that isn't tool dependent (and pragma (lib, "")) appears to be that solution.
See also Issue 1690. GDC has chosen to not implement pragma(lib) at all, at least not yet. This makes it a pretty useless thing to have in the spec. Either make it required, or remove it.
Created attachment 243 [details] patch to use libfiles, disable pragma statements This attachment makes two changes that make this pragma work properly: 1. Produces an error when used as a statement. The Windows compiler does not support this either, and it doesn't make sense anyway. 2. Adds "-lLIBRARY" to global.params.libfiles for each library on Linux. This way, it will be passed to gcc like any other (since I presume obj_includelib does not work with gcc on Linux.) I realize #1 isn't exactly this bug, but it is related to the pragma not working (on any OS) while being silently ignored. -[Unknown]
Fixed in DMD 1.037 and 2.021
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル