Thread overview
Compiling DMD on MAC OS X
Feb 19, 2012
Tyro[a.c.edwards]
Feb 19, 2012
kraybourne
Feb 20, 2012
Tyro[a.c.edwards]
Feb 29, 2012
Joshua Niehus
Feb 29, 2012
Joshua Niehus
February 19, 2012
Hi all,

I've just installed DMD 2.058 and attempted to compile a little script but was greeted with the following error:

gcc: Invalid argument

I used the .dmg installer from http://www.dlang.org/download.html and issued the command:

dmd average

Is there something I'm missing?

Thanks,
Andrew
February 19, 2012
On 2/19/12 09:20 , Tyro[a.c.edwards] wrote:
> Hi all,
>
> I've just installed DMD 2.058 and attempted to compile a little script
> but was greeted with the following error:
>
> gcc: Invalid argument
>
> I used the .dmg installer from http://www.dlang.org/download.html and
> issued the command:
>
> dmd average
>
> Is there something I'm missing?
>
> Thanks,
> Andrew

Hi!

Could you try

	dmd -v avarage

and tell us what comes out?
Also, how does avarage.d look? Also what does

	uname -a

and
	gcc --version

say? Also, just in case

	which dmd

February 20, 2012
On Sunday, 19 February 2012 at 11:39:15 UTC, kraybourne wrote:
> On 2/19/12 09:20 , Tyro[a.c.edwards] wrote:
>> Hi all,
>>
>> I've just installed DMD 2.058 and attempted to compile a little script
>> but was greeted with the following error:
>>
>> gcc: Invalid argument
>>
>> I used the .dmg installer from http://www.dlang.org/download.html and
>> issued the command:
>>
>> dmd average
>>
>> Is there something I'm missing?
>>
>> Thanks,
>> Andrew
>
> Hi!
>
> Could you try
>
> 	dmd -v avarage
>
> and tell us what comes out?
> Also, how does avarage.d look? Also what does
>
> 	uname -a
>
> and
> 	gcc --version
>
> say? Also, just in case
>
> 	which dmd

I made the mistake of assuming that gcc was automatically installed in MAC OSX. After installing Xcode the problem went away. To answer your questions though:

I'm using DMD version 2.058 for MAC OSX which I installed using the .dmg package available at "http://www.dlang.org/download.html".

"gcc --version" yields:

i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.9.00)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

"uname -a" yields:

Darwin Andrews-MacBook-Pro.local 11.3.0 Darwin Kernel Version 11.3.0: Thu Jan 12 18:47:41 PST 2012; root:xnu-1699.24.23~1/RELEASE_X86_64 x86_64

the average program is as follows:

[code]
import std.stdio: stdin, writefln;
import std.conv: to;

void main(string[] args)
{
   double sum = 0.0;
   int cnt = 0;
   foreach(line; stdin.byLine())
   {
      if(line.length)
      {
         sum += to!double (line);
         cnt++;
      }
   }

   double avg = sum / cnt;
   writefln("Average is %.5f", avg);
}
[/code]

and I doubt you want me to put all of what "dmd -v" spits out for this little script.

Thanks,
Andrew

February 29, 2012
On Monday, 20 February 2012 at 11:18:34 UTC, Tyro[a.c.edwards] wrote:
> ...
>
> and I doubt you want me to put all of what "dmd -v" spits out for this little script.
>
> Thanks,
> Andrew

Hi Andrew,

I ran into this problem as well and here is how I fixed/hacked it:
OSX Lion, and soon to be Mountain Lion, no longer come with GCC installed for the Command Line (/usr/bin/gcc)
What you need to do is Install Xcode from the app store, which is free, and then:
  * Launch your Xcode 4.1
  * Go to preferences > Downloads
  * Click on the "install" button near the "Command line tools"

This will put gcc in your /usr/bin directory.

Then try to recompile your code.

-- the new mac installer on the website should probably come with gcc or check for dependencies

Josh
February 29, 2012
> Hi Andrew,
>
> I ran into this problem as well and here is how I fixed/hacked it:
> OSX Lion, and soon to be Mountain Lion, no longer come with GCC installed for the Command Line (/usr/bin/gcc)
> What you need to do is Install Xcode from the app store, which is free, and then:
>   * Launch your Xcode 4.1
>   * Go to preferences > Downloads
>   * Click on the "install" button near the "Command line tools"
>
> This will put gcc in your /usr/bin directory.
>
> Then try to recompile your code.
>
> -- the new mac installer on the website should probably come with gcc or check for dependencies
>
> Josh

Quick Edit:  just noticed that your gcc command is working, so i guess this isnt the prob.