compilation issues (dmd, rdmd, ldc2)

kraxli via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Feb 21 13:21:30 PST 2016


On Sunday, 21 February 2016 at 20:50:11 UTC, anonymous wrote:
> On Sunday, 21 February 2016 at 20:04:34 UTC, kraxli wrote:
>> What is going on here and what is the difference between dmd 
>> and rdmd?
>
> dmd compiles the modules that you specify on the command line. 
> By default, it then links an executable from the generated 
> object files. The linking can only work when you give dmd all 
> the code, either in source form or in compiled object form. 
> When something is missing, you get "undefined reference" errors.

Thanks for coming back on that! The problem is the 
consoled-package which has the library:
~/.dub/packages/consoled-1.0.0/libconsoled.a

So I link it (or aim to do it ;-) ) but dmd cannot find it:

$ dmd -I~/.dub/packages/consoled-1.0.0/source  
-L-l~/.dub/packages/consoled-1.0.0/libconsoled  appX.d
/usr/bin/ld: cannot find 
-l~/.dub/packages/consoled-1.0.0/libconsoled
collect2: error: ld returned 1 exit status
--- errorlevel 1


>
> That means, when your program has multiple source files 
> (including libraries), you must put them all on the dmd command 
> line. Or you can compile modules individually (without linking, 
> -c flag), and then put the generated object files on the 
> command line when linking.
>
> rdmd is a wrapper around dmd (or another, compatible compiler). 
> It reads the dependency tree of the modules, and runs dmd on 
> all of the source files at once. That means, you only need to 
> put the root module on the command line for rdmd. rdmd reads 
> the imports and generates a full list of source files for dmd.
>
>> Moreover, ldc2 has conflicts with modules which is probably 
>> due to installation, linking and scope issues. How can I 
>> shrink the scope for ldc2 such that it only looks at the 
>> "right place" for modules (and where is that?) ?
>>
>> $ ldc2 -I~/.dub/packages/consoled-1.0.0/source/  appX.d
>> /usr/local/include/d/std/range.d(287): Error: module std.range 
>> from file /usr/local/include/d/std/range.d conflicts with 
>> package name range
>
> I don't know what's going on there, but there shouldn't be a 
> std/range.d with recent versions of phobos. It's a package 
> since 2.067.0. Maybe a leftover from a previous installation?

I just reinstalled it and it seems as it would have installed in 
the directory mentioned by ldc2:
-- Installing: /usr/local/include/d/std/range
-- Installing: /usr/local/include/d/std/range/primitives.d
-- Installing: /usr/local/include/d/std/range/package.d
-- Installing: /usr/local/include/d/std/range/interfaces.d





More information about the Digitalmars-d-learn mailing list