Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Problem with ManualMacOSXInstall on Snow Leopard

Moderators: kris

Posted: 11/17/10 12:31:57

I followed the instructions on http://www.dsource.org/projects/tango/wiki/ManualMacOSXInstall

At the end of executing ./build/bin/osx32/bob -vu -r=dmd -c=dmd . I got the following message:

ar: creating archive libtango.a /usr/bin/ranlib: object: libtango.a(tango-core-BitArray?-release.o) malformed object (LC_SEGMENT command 0 filesize field greater than vmsize field) ar: internal ranlib command failed 413 files

Help is appreciated; I can't use now the Tango book I bought!

Bert Fitié

Author Message

Posted: 11/18/10 04:46:12

Hi bertlhf

which version of the compiler are you using?

Posted: 11/18/10 08:13:43

Hi Kris,

Thanks for the prompt reply.

bert@phynix2:~ $ dmd --help | head -n1 Digital Mars D Compiler v2.050

I noted 2 deprecated items in the terminal output:

dmd -c -I./tango/core -I. -I./tango/core/vendor -release -oftango-core-Atomic-release.o ./tango/core/Atomic.d tango.core.Atomic is deprecated. Please use tango.core.sync.Atomic instead. ... dmd -c -I./tango/core -I. -I./tango/core/vendor -release -oftango-io-FileScan?-release.o ./tango/io/FileScan.d tango.io.FileScan? is deprecated. Please use tango.io.FilePath?.toList or tango.io.vfs.* instead.

-- Bert Fitié

Posted: 11/18/10 11:43:43

Hi Kris,

I have to correct my last post. During the "./build/bin/osx32/bob -vu -r=dmd -c=dmd ." execution the dmd used was of course the downloaded one mentioned in http://www.dsource.org/projects/tango/wiki/ManualMacOSXInstall:

bert@phynix2:trunk $ which dmd
/opt/dmd/bin/dmd
bert@phynix2:trunk $ dmd --help | head -n1
Digital Mars D Compiler v1.065

My 'standard' dmd is

bert@phynix2:~ $ which dmd
/usr/local/bin/dmd
bert@phynix2:~ $ dmd --help | head -n1
Digital Mars D Compiler v2.050

-- Bert Fitié

Posted: 11/18/10 12:31:05

I've noticed the same problem myself, more and more often. I'm not sure but it might be a bug in DMD. But anyway, you can build Tango as a dynamic library instead with the -d flat and it should work. Then you also have to change your dmd.conf file so your applications can find libtango.dylib when running them. Add the following to DFLAGS in dmd.conf:

-L-rpath -L/path/to/libtango

Posted: 11/18/10 13:43:57

I tried your '-L-rpath -L/Users/bert/Downloads/sw/dmd-tango/trunk' in dmd.conf pointing to libtango.a in the trunk (there is no libtango.dylib in the trunk download), but I got exactly the same error.

Wouldn't fixing the 2 deprecations, from the terminal output, help?

dmd -c -I./tango/core -I. -I./tango/core/vendor -release -oftango-core-Atomic-release.o ./tango/core/Atomic.d tango.core.Atomic is deprecated. Please use tango.core.sync.Atomic instead.

dmd -c -I./tango/core -I. -I./tango/core/vendor -release -oftango-io-FileScan?-release.o ./tango/io/FileScan.d tango.io.FileScan? is deprecated. Please use tango.io.FilePath?.toList or tango.io.vfs.* instead.

Posted: 11/18/10 15:41:36

First you have to build Tango as a dynamic library using the -d flag. You can build tango as a dynamic library like this:

./build/script/bob.rb -r dmd -c dmd -d .

Then you can change dmd.conf according to my previous post. BTW this won't fix the deprecation warnings, you don't have to worry about them.

Posted: 11/18/10 17:29:27

I managed to generate the libtango.dylib in the trunk directory:

bert@phynix2:trunk $ ./build/script/bob.rb -r dmd -c dmd -d .
tango.core.Atomic is deprecated. Please use tango.core.sync.Atomic instead.
tango.io.FileScan is deprecated. Please use tango.io.FilePath.toList or tango.io.vfs.* instead.
413 files

To test things out I switched to a 'dlang' working directory containing the main.d example from http://www.dsource.org/projects/tango/wiki/ManualMacOSXInstall

bert@phynix2:trunk $ cd /Users/bert/workspaces/dlang
bert@phynix2:dlang $ which dmd
/opt/dmd/bin/dmd
bert@phynix2:dlang $ dmd main.d
object.d: Error: module object is in file 'object.d' which cannot be read
Specify path to file 'object.d' with -I switch

I only could find a 'object.di' file in the trunk which I copied to 'object.d'. I added a switch -I/Users/bert/Downloads/sw/dmd-tango/trunk to point to object.d. Unfortunately, I only got errors:

bert@phynix2:dlang $ dmd main.d
Undefined symbols:
  "_main", referenced from:
      start in crt1.10.6.o
  "_D14TypeInfo_Tuple6__vtblZ", referenced from:
      _D13TypeInfo_B2Aa6__initZ in main.o
  "_D5tango2io6stream6Format20__T12FormatOutputTaZ12FormatOutput5printMFYC5tango2io6stream6Format20__T12FormatOutputTaZ12FormatOutput", referenced from:
      __Dmain in main.o
  "_D5tango2io6Stdout6StdoutC5tango2io6stream6Format20__T12FormatOutputTaZ12FormatOutput", referenced from:
      _D5tango2io6Stdout6StdoutC5tango2io6stream6Format20__T12FormatOutputTaZ12FormatOutput$non_lazy_ptr in main.o
     (maybe you meant: _D5tango2io6Stdout6StdoutC5tango2io6stream6Format20__T12FormatOutputTaZ12FormatOutput$non_lazy_ptr)
  "_D5tango2io6Stdout12__ModuleInfoZ", referenced from:
      _D4main12__ModuleInfoZ in main.o
  "_D5tango2io6stream6Format20__T12FormatOutputTaZ12FormatOutput7newlineMFZC5tango2io6stream6Format20__T12FormatOutputTaZ12FormatOutput", referenced from:
      __Dmain in main.o
  "_D10ModuleInfo6__vtblZ", referenced from:
      _D4main12__ModuleInfoZ in main.o
  "_D11TypeInfo_Aa6__initZ", referenced from:
      internal in main.o
ld: symbol(s) not found

After a change in the conf file:

bert@phynix2:dlang $ dmd main.d
ld: library not found for -lphobos
collect2: ld returned 1 exit status
--- errorlevel 1

Probably my conf file is incorrect (I have no experience with this). I have the following in 'DFLAGS=':

-I/Users/bert/Downloads/sw/dmd2/src/phobos (to point to the standard phobos sources)
-L-rpath (your suggestion)
-I/Users/bert/Downloads/sw/dmd-tango/trunk (to point to object.d, renamed from object.di)
-L/Users/bert/Downloads/sw/dmd-tango/trunk (to point to the generated tango.dylib)
-L/opt/dmd/lib (to point to the libphobos.a coming with the D Compiler v1.065)

Can you put me in the right direction?

-- Bert Fitié

Posted: 11/18/10 20:17:31

You have not followed the instructions from http://www.dsource.org/projects/tango/wiki/ManualMacOSXInstall at all. Follow the instructions at the link but when it comes to building Tango, use the build command that I wrote in my previous post. When you copy the library you will copy libtango.dylib instead of libtango.a. Then also add this:

-L-rpath -L/path/to/libtango

To DFLAGS in dmd.conf.

Posted: 11/19/10 09:25:43

You were right, I confused things by starting somewhere in the middle of my old workflow. I now started from scratch again, and everything worked. Thanks very much. I can enjoy my Tango book now.

Just for documentation purposes, here is the complete alternative workflow. Maybe interesting as an addition to http://www.dsource.org/projects/tango/wiki/ManualMacOSXInstall.

~ $ system_profiler | grep OS
      System Version: Mac OS X 10.6.5 (10H574)
~ $ cd ~/Downloads/sw/dmd-tango
dmd-tango $ wget http://ftp.digitalmars.com/dmd.1.065.zip
dmd-tango $ unzip dmd.1*.zip
dmd-tango $ sudo mkdir /opt/dmd
dmd-tango $ sudo cp -r dmd/osx/* /opt/dmd/
dmd-tango $ sudo chmod a+x /opt/dmd/bin/dmd
dmd-tango $ export PATH=/opt/dmd/bin:$PATH
dmd-tango $ svn co http://svn.dsource.org/projects/tango/trunk
dmd-tango $ cd trunk/
trunk $ ./build/script/bob.rb -r dmd -c dmd -d .
tango.core.Atomic is deprecated. Please use tango.core.sync.Atomic instead.
tango.io.FileScan is deprecated. Please use tango.io.FilePath.toList or tango.io.vfs.* instead.
413 files
trunk $ sudo cp libtango.dylib /opt/dmd/lib/libtango.dylib
trunk $ sudo mkdir /opt/dmd/import
trunk $ sudo cp -r object.di tango /opt/dmd/import/
trunk $ cat /opt/dmd/bin/dmd.conf
[Environment]

DFLAGS=-I%@P%/../import -I%@P%/../import/tango/core/vendor -L-L%@P%/../lib  -version=Tango -defaultlib=tango -debuglib=tango -version=osx -L-rpath -L/opt/dmd/lib
trunk $ cd ~/workspaces/dlang/
dlang $ cat main.d
module main;

import tango.io.Stdout;

void main(char[][] args)
{
   Stdout("Hello World").newline;
}
dlang $ dmd main.d
dlang $ ./main
Hello World

Posted: 11/20/10 18:51:56

I'm glad that it turned out to work for you. I guess we should add a note about the problem you had.