Nugroho's blog.: mac
Showing posts with label mac. Show all posts
Showing posts with label mac. Show all posts

Thursday, November 12, 2015

Delphi on OS X

 Here's the WineSkin version.

 I found it's way smoother than WineBottler version, ...., but hard to figure how to use it

 To install Delphi in OS X using WineSkin, we have to download and install Wineskin, of course, :)

  • Open Wineskin Winery.app
  • Make sure you have a Wrapper version and an Engine
  • Select the Engine you want to use (I use WS9Wine1.7.52)
  • Press the Create Wrapper button
  • Enter in the name Delphi (or whatever you have in mind) for the wrapper and press OK
  • When its done being created, click the button to view it in Finder in the finished window
  • Close Wineskin Winery.app.
  • Right click Delphi.app in Finder and select “Show Package Contents”
  • Double click and run Wineskin.app.
  • Now click on the Install Software button
  • Select to choose a setup executable
  • Navigate to the Delphi setup exe file you downloaded in step one
  • Select the setup exe file and press the choose button
  • At this point Delphi setup should begin, go through the Delphi setup like a normal install
  • After the setup is done, back in Wineskin.app, it should pop up asking you to select the .exe file
  • Choose the delphi32.exe file in the drop down list and press the Select Button
  • Now press the Quit button to exit Wineskin.app
  • Back in Finder, double click Delphi.app and start coding

 It has the same problem with WineBottler,  the toolbar tab's seem order by itself alphabetically, so the default toolbar tab is not ' standard ' tab but 'additional' one

code
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
jalan:boolean=false;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
jalan := not jalan;
if jalan = true then button1.Caption:='Stop'
else button1.Caption:='Run';

end;

procedure TForm1.FormCreate(Sender: TObject);
begin
button1.Caption:='Run';
end;

end.
.









Friday, October 16, 2015

iWork Update on El Capitan

 My Pages, Number and Keynote received new feature.

 ...and hey, my view is increased twofold, :D

(And my Keynote on iPhone 4s is upgraded as well)







Saturday, October 3, 2015

HFS+ (Journaled) Flash Drive on Ubuntu

 I have no problem mount it on Centos, read and write mode.

 But, on Ubuntu, it needs some works.

 Install hfsprogs

 
sudo apt-get install hfsprogs


 umount the drive if it's already meunted


sudo umount /dev/sdb2


create folder to mount the drive


mkdir flash


mount again


sudo mount -t hfsplus -o force,rw /dev/sdb2 flash


It works for me, but it need sudo privilege to write to it. Maybe because it's journaled and ubuntu didn't support journaled HFS+ filesystem.

At least it works, :)

Friday, November 7, 2014

iOS and OS X's Note

Want to edit Pages document 'on the fly' but don't have a Pages on iPhone? It's OK.

Copy the content of your Page document by select all -> copy, then paste to Note app on OS X. Wait a moment, it will sync with the Note app on iPhone, complete with the formatting and the images, :)





Tuesday, October 21, 2014

Keynote on Linux

No, there's no native iWork on my Debian Sid.

It has done via iCloud Drive and iCloud Keynote.

My keynote, wrote it using my old OS X Maverick (or maybe even when my MacBook is still using Lion or Snow Leopard, I forgot), can be accessed via Chrome browser.


Monday, October 20, 2014

Stuck on "Upgrading" iCloud Drive

Well, nothing we can do about it.

But, just remember that sometime the process time on apple based device (and others platform as well) didn't as reliable.

The "1 minute remaining" installation message that took 2 hours to finish.

The Mail app sending message that tell "34 minute remaining" but actually it's sent and we got bewildered when receiving reply of our message that "didn't" sent yet.  

So, be patient, :)

You could soft reset it, power-off and then turn it on again, or another reset, press home button and power button at same time until the device turned off and boot by itself.

Got some solution from discussions.apple.com, flip the airplane switch to on, it'll gave the error message, flip it to off again, and all is well, the iCloud drive status is on. Weird, not pretty solution, but worked, so no problem for me.

But that won't guarantee the problem is solved for everyone, :)

Some succeed by using it and some didn't.

The alternative is, again, be patient, :)


Trace Animation on Keynote

I used it on my OS X Yosemite, still prefer Anagram+Anvil/Appear combo though, :)



Thursday, November 7, 2013

Laggy Mavericks and QuickLook that Neither Quick nor Look on Anything

Don't know what happened, but my Maverick is getting slower and slower.

QuickLook can't preview .f,  .py and .tex files (and other files type too as I tried to "quick-looking" other type but fortran, python and latex  is what I "quick-looking" most).

Thursday, October 24, 2013

My new OS X Maverick

Just install it on my mid 2009 Macbook Pro 13 inch and well..., nothing change at the first look. It just like the old Mountain Lion appearance.

Wait, oh yeah, there is iBooks in the Dock and wow..., iOS Maps is there as well.

More importantly, the Safari is quite stable now, at least I didn't use Chrome for 3 hours now, :). Of course it's good signal of Safari direction,  I used to use Chrome in Mountain Lion and now glad I can switch back.

Saturday, December 8, 2012

Mountain Lion's Spotlight didn't Spot Application

Maybe it's just me, after upgrading from leopard to snowleopard to lion and finally mountain lion (always upgrade, no fresh install), this big cat suddenly refuse to index my Application. Whenever I type application name in Spotlight, it just show document, picture but not Application. Typing "macvim" bring me to macvim installation folder, macvim on the web but not Macvim apps. Spotlight setting clearly didn't ban Application folder, so maybe this is another Mountain Lion problem

Still looking for solution...

Mountain Lion's Fullscreen Apps on Extended Display

It seems that weakness of this big cat isn't resolved yet. I used Pages in my Desktop while the big one browsing trough web using safari for refence. When I switch (automatically, bad behaviour I think) to fullscreen on Pages, suddenly the other display become blank (not actually blank, just linen-like wall, or maybe canvas).

Sunday, December 18, 2011

Displaying Calculation Output of Python Script to Web Page using Python-based Web Server

It'll be convenient if we could displaying output from our Python code to web page.

To convert calculation output of Python script to web page we need BaseHTTPServer, a Python-based web server. With it, we could write any python code and display it in no time. It has advantage in form of simplicity, we don't need php to convert our result or typing it to static html code, we just used python alone (it's possible to write html and php code on python though).
This code below will display python script calculating value of a function (sin(x)+x^2) to web page. As it behave as web server too, we don't need apache or other web server to broadcast it.

Here the code. It's written in Python 2.7 on Mac OS X Lion with numpy module and sys, parser and basehttpserver built in module.

from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
import sys,parser
from math import *
import numpy as np

class Handler(BaseHTTPRequestHandler):
def do_GET(self):
n=10
x=7
y = 'sin(x)+x**2'
z = parser.expr(y).compile()

self.send_response(200)
self.send_header("Content-type", "text/html")
self.end_headers()

self.wfile.write("Hi Folks, Aravir here")
self.wfile.write("")
self.wfile.write("Hi Folks, Aravir here
")
self.wfile.write("
")
self.wfile.write("The value of ")
self.wfile.write(y )
self.wfile.write(" on x = " )
self.wfile.write(x)
self.wfile.write(" is " )
self.wfile.write(eval(z) )

self.wfile.write("")

if __name__=="__main__":
try:
server = HTTPServer(("", 8080), Handler)
server.serve_forever()
except KeyboardInterrupt:
server.socket.close()

Access it using web browser in localhost:8080 from your computer running code above, or :8080 and get this


From python

Django ain't for This

While I'm searching for tutorial about creating simple static web page using Django, I surprised that i found almost nothing. There is Django documentation for it but I think it's too much; creating microblogger, forum, note, wiki, etc.

According what I found after surfed a while, Django isn't for this. I was suggestet to use basehttpserver instead.



Here what I found

"I have python scripts which provides output and I need to have this output on the web."


That is not what Django is for. What you want to do can be achieved with something as simple as this:

from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer

class Handler(BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.send_header("Content-type", "text/html")
self.end_headers()

self.wfile.write("magic content goes here")

if __name__=="__main__":
try:
server = HTTPServer(("", 8080), Handler)
server.serve_forever()
except KeyboardInterrupt:
server.socket.close()
Observe the self.wfile.write line. Whatever you write there ends up in the browser. If it matters, you can use self.path in the Handler to check which file was requested.

Tested with Python 2.6.4, accessed the server with Chrome browser.

..........

If you need a quick web server running and you don't want to mess with setting up apache or something similar, then Python can help. Python comes with a simple builtin HTTP server. With the help of this little HTTP server you can turn any directory in your system into your web server directory. The only thing you need to have installed is Python.

Practically speaking this is very useful to share files inside your local network. Implementing this tiny but hugely useful HTTP server is very simple, its just a single line command.

Assume that I would like to share my home directory
Open up a terminal and type:

$ cd 
$ python -m SimpleHTTPServer

That's it! Now your http server will start in port 8000. You will get the message:
Serving HTTP on 0.0.0.0 port 8000 ...

Now open a browser and type the computer address like:
http://192.168.1.1:8000

If you on computer that is running server, you can also access it via:
http://127.0.0.1:8000

If the directory has a file named index.html, that file will be served as the initial file. If there is no index.html, then the files in the directory will be listed.
If you wish to change the port that's used start the program via:

$ python -m SimpleHTTPServer 8080

If you want to only serve on localhost you'll need to write a custom Python program such as:


import sys
import BaseHTTPServer
from SimpleHTTPServer import SimpleHTTPRequestHandler

HandlerClass = SimpleHTTPRequestHandler
ServerClass = BaseHTTPServer.HTTPServer
Protocol = "HTTP/1.0"

if sys.argv[1:]:
port = int(sys.argv[1])
else:
port = 8000
server_address = ('127.0.0.1', port)

HandlerClass.protocol_version = Protocol
httpd = ServerClass(server_address, HandlerClass)

sa = httpd.socket.getsockname()
print "Serving HTTP on", sa[0], "port", sa[1], "..."
httpd.serve_forever()


Saturday, December 17, 2011

LLVM-GCC on OS X Lion

I confused about GCC version brought by XCode 4.2 on OS X Lion, so I surfing and landing on several sites to find out what is this llvm version.

Here some result.

Llvm stand for low level virtual machine



The LLVM Project (llvm.org) is a collection of modular and reusable compiler and toolchain technologies. Despite its name, LLVM has little to do with traditional virtual machines, though it does provide helpful libraries that can be used to build them.

The llvm-gcc command is the LLVM C front end. It is a modified version of gcc that compiles C/ObjC programs into native objects, LLVM bitcode or LLVM assembly language, depending upon the options.

By default, llvm-gcc compiles to native objects just like GCC does. If the -emit-llvm and -c options are given then it will generate LLVM bitcode files instead. If -emit-llvm and -S are given, then it will generate LLVM assembly.

Being derived from the GNU Compiler Collection, llvm-gcc has many of gcc's features and accepts most of gcc's options. It handles a number of gcc's extensions to the C programming language. See the gcc documentation for details.

Clang vs GCC (GNU Compiler Collection)

Clang ( /ˈklæŋ/)[2] is a compiler front end for the C, C++, Objective-C, and Objective-C++ programming languages. It uses the Low Level Virtual Machine (LLVM) as its back end, and Clang has been part of LLVM releases since LLVM 2.6.

Its goal is to offer a replacement to the GNU Compiler Collection (GCC). Development is sponsored by Apple. Clang is available under a free software license.

The Clang project includes the Clang front end and the Clang static analyzer among others.[3]

Pro's of GCC vs clang:


  • GCC supports languages that clang does not aim to, such as Java, Ada, FORTRAN, etc.
  • GCC has a few C++'11 features that Clang does not yet support.
  • GCC supports more targets than LLVM.
  • GCC is popular and widely adopted.
  • GCC does not require a C++ compiler to build it.

Pro's of clang vs GCC:


  • The Clang ASTs and design are intended to be easily understandable by anyone who is familiar with the languages involved and who has a basic understanding of how a compiler works. GCC has a very old codebase which presents a steep learning curve to new developers.
  • Clang is designed as an API from its inception, allowing it to be reused by source analysis tools, refactoring, IDEs (etc) as well as for code generation. GCC is built as a monolithic static compiler, which makes it extremely difficult to use as an API and integrate into other tools. Further, its historic design and current policy makes it difficult to decouple the front-end from the rest of the compiler.
  • Various GCC design decisions make it very difficult to reuse: its build system is difficult to modify, you can't link multiple targets into one binary, you can't link multiple front-ends into one binary, it uses a custom garbage collector, uses global variables extensively, is not reentrant or multi-threadable, etc. Clang has none of these problems.
  • For every token, clang tracks information about where it was written and where it was ultimately expanded into if it was involved in a macro. GCC does not track information about macro instantiations when parsing source code. This makes it very difficult for source rewriting tools (e.g. for refactoring) to work in the presence of (even simple) macros.
  • Clang does not implicitly simplify code as it parses it like GCC does. Doing so causes many problems for source analysis tools: as one simple example, if you write "x-x" in your source code, the GCC AST will contain "0", with no mention of 'x'. This is extremely bad for a refactoring tool that wants to rename 'x'.
  • Clang can serialize its AST out to disk and read it back into another program, which is useful for whole program analysis. GCC does not have this. GCC's PCH mechanism (which is just a dump of the compiler memory image) is related, but is architecturally only able to read the dump back into the exact same executable as the one that produced it (it is not a structured format).
  • Clang is much faster and uses far less memory than GCC.
  • Clang aims to provide extremely clear and concise diagnostics (error and warning messages), and includes support for expressive diagnostics. GCC's warnings are sometimes acceptable, but are often confusing and it does not support expressive diagnostics. Clang also preserves typedefs in diagnostics consistently, showing macro expansions and many other features.
  • GCC is licensed under the GPL license. clang uses a BSD license, which allows it to be used by projects that do not themselves want to be GPL.
  • Clang inherits a number of features from its use of LLVM as a backend, including support for a bytecode representation for intermediate code, pluggable optimizers, link-time optimization support, Just-In-Time compilation, ability to link in multiple code generators, etc.
  • Clang's support for C++ is more compliant than GCC's in many ways (e.g. conformant two phase name lookup).


From forum (http://www.cocos2d-iphone.org/forum/topic/7923)
"Have you experienced any incompatibility between LLVM compiler and GCC compiler ?


I found one strange issue:
If you compile ParticleTests with GCC and if you try sub-test "issue 872", it works as expected: a particle system will emit particles.
But if you compile it with LLVM 1.5, you won't see any particle at all. I'm not sure what's the problem, but I'll investigate it a bit further.


I can only reproduce this bug on the simulator. It seems that this bug can't be reproduced on the devices.


I tested it both in Release & Debug mode using Xcode 3.2.3"
............

"A developer at Apple (guy working on LLVM) highly suggested moving away from GCC immediately. He says Apple is no longer fixing bugs in GCC, and in XCode 4 GCC-LLVM will be the default option.


I've noticed sometimes LLVM will not compile against really old libraries compiled with GCC (gives errors about built in runtime functions not found). I can fix that by using GCC-LLVM (gcc parser, LLVM code generator).


A few days ago I noticed a bug in my code that only showed up when using LLVM (but not GCC). I tracked it down to a non initialized local variable that was being read from, and GCC would always initialize to zero (even with O3 optimizations). Since the variable value should be undefined, LLVM was giving the correct behavior of using whatever was in that memory already (even though it's clearly not the desired result). I'd speculate something similar is going on with ParticleTests.


I did a quick test, and compiling Cocos2D with GCC-LLVM works correctly with issue 872."

JPEG Support for Python 2.7's PIL Module on OS X Lion

My PIL module refuse to process jpeg image. It says that there is no decoder jpeg on my system. It's no good  since I want to process that kind of file using PIL in future, and my older iPhoto picture on my 13 inch MacBook Pro is generally in jpeg format too.

Here the snapshot


Nugrohos-MacBook-Pro:olah gambar nugroho$ python olahgambar.py 
Program Image Enchancement
Oleh Nugroho Adi Pramono
275514
===========================
format awal: JPEG 2448x3264 RGB
konversi ke grayscale
Traceback (most recent call last):
File "olahgambar.py", line 14, in
gbw = gb.convert("L")
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PIL/Image.py", line 679, in convert
self.load()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PIL/ImageFile.py", line 189, in load
d = Image._getdecoder(self.mode, d, a, self.decoderconfig)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PIL/Image.py", line 385, in _getdecoder
raise IOError("decoder %s not available" % decoder_name)
IOError: decoder jpeg not available
Nugrohos-MacBook-Pro:olah gambar nugroho$

So I googling for it and found libjpeg at http://www.ijg.org/files/, download, exctract and install it using magic UNIX words ./configure, make, make install

Nugrohos-MacBook-Pro:~ nugroho$ cd Downloads/jpeg-8c/
Nugrohos-MacBook-Pro:jpeg-8c nugroho$ ./configure
Nugrohos-MacBook-Pro:jpeg-8c nugroho$ make
Nugrohos-MacBook-Pro:jpeg-8c nugroho$ make test
rm -f testout*
./djpeg -dct int -ppm -outfile testout.ppm ./testorig.jpg
./djpeg -dct int -bmp -colors 256 -outfile testout.bmp ./testorig.jpg
./cjpeg -dct int -outfile testout.jpg ./testimg.ppm
./djpeg -dct int -ppm -outfile testoutp.ppm ./testprog.jpg
./cjpeg -dct int -progressive -opt -outfile testoutp.jpg ./testimg.ppm
./jpegtran -outfile testoutt.jpg ./testprog.jpg
cmp ./testimg.ppm testout.ppm
cmp ./testimg.bmp testout.bmp
cmp ./testimg.jpg testout.jpg
cmp ./testimg.ppm testoutp.ppm
cmp ./testimgp.jpg testoutp.jpg
cmp ./testorig.jpg testoutt.jpg
Nugrohos-MacBook-Pro:jpeg-8c nugroho$ sudo make install

reinstall PIL

PIL 1.1.7 SETUP SUMMARY
--------------------------------------------------------------------
version 1.1.7
platform darwin 2.7.2 (v2.7.2:8527427914a2, Jun 11 2011, 15:22:34)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)]
--------------------------------------------------------------------
--- TKINTER support available
--- JPEG support available
--- ZLIB (PNG/ZIP) support available
*** FREETYPE2 support not available
*** LITTLECMS support not available
--------------------------------------------------------------------
To add a missing option, make sure you have the required
library, and set the corresponding ROOT variable in the
setup.py script.

Friday, December 16, 2011

Ubuntu 11.10 Oneiric Ocelot On OS X Lion's VBox (NAT and Host-Guest Sharing Folder)

After installing Ubuntu 11.10 on Mac OS X Lion using VirtualBox, here first impression of Oneiric Ocelot



There is dock at left, like on Mac.

Network is works flawlessy, I can surf internet using firefox, its NAT configuration come by default while installing it.
From Oneiric Ocelot

Firefox run at fullscreen(I mean ubuntu screen), just like Lion's or iPad's Safari (Lion's version of firefox didn't auto fullscreen yet). We can windowed-mode-ed it by hovering mouse at top edge of screen, it'll show menu-bar too

Hover mouse at top
From Oneiric Ocelot
It's windowed firefox

From Oneiric Ocelot
 If we click dash home, we'll got launchpad like (just like iPad or Lion's launchpad). At second tab, there's apps available to download.

From Oneiric Ocelot

 To access shared folder on Lion named vbox, I opened terminal by clicking Dash home and type terminal on search box
From Oneiric Ocelot

 First create directory
aravir@aravir-VirtualBox:~$mkdir vbox

mount shared vbox on lion using this command
aravir@aravir-VirtualBox:~$sudo mount -t vboxsf vbox vbox 

at screenshot you know it generate error because ubuntu did'nt recognize vboxsf filesystem. To introduce it, guest addition must be installed.
From Oneiric Ocelot
From Oneiric Ocelot
From Oneiric Ocelot
From Oneiric Ocelot
Failed. Guest addition need root privilege.
aravir@aravir-VirtualBox:~$cd /Media/VBOXADDITIONS_4.1.6_74713
$sudo ./VBoxLinuxAdditions.run

After guest addition installed and the system restarted (it's support full screen on my Macbook monitor now), retype the command above, and done

 Vbox directory before mounted
From Oneiric Ocelot
After mounted
From Oneiric Ocelot

Thursday, December 15, 2011

Installing Python-2.7's Imaging Library Module on OS X Lion

PIL, as its name suggest, is an imaging library for python. I used PIL to get every pixel of an image as 2x2 array information. With that I could modify it with many possibilities; edge detection, black and white transformation, log transformation, creating watermark, etc.

{update: I install this PIL module on my OS X El Capitan too, :), and easier



Installing PIL is an easy task, if we have its prerequities installed. Just download it and extract it and then install using this command

Nugrohos-MacBook-Pro:Imaging-1.1.7 nugroho$ python setup.py install
running install
running build
running build_py
creating build
creating build/lib.macosx-10.6-intel-2.7
...
unable to execute gcc-4.2: No such file or directory
error: command 'gcc-4.2' failed with exit status 1
Nugrohos-MacBook-Pro:Imaging-1.1.7 nugroho$
Oops, it is failed to install, it tell me that there is no gcc-4.2 on my machine, and that's true. I've modified my /usr/bin/gcc to point /usr/local/bin/gcc.

I have gcc 4.2 from Xcode4.2, which actually llvm-gcc. My existing gcc is gcc-4.6.2 so I cheated… I created symlink named gcc-4.2 on /usr/bin pointing /usr/local/bin/gcc

Nugrohos-MacBook-Pro:Imaging-1.1.7 nugroho$ ln -s /usr/local/bin/gcc /usr/bin/gcc-4.2
ln: /usr/bin/gcc-4.2: Permission denied
Nugrohos-MacBook-Pro:Imaging-1.1.7 nugroho$ sudo ln -s /usr/local/bin/gcc /usr/bin/gcc-4.2
Nugrohos-MacBook-Pro:Imaging-1.1.7 nugroho$

Still error, :(

gcc-4.2: error: x86_64: No such file or directory
gcc-4.2: error: unrecognized option ‘-arch’
gcc-4.2: error: unrecognized option ‘-arch’
error: command 'gcc-4.2' failed with exit status 1

Hm, maybe if I'm linking /usr/bin/gcc-4.2 to /usr/bin/llvm-gcc-4-2; it's gcc-4.2 after all, if we ignore llvm (don't know what is it stand for). It doesn't hurt if I'm trying, so..
Nugrohos-MacBook-Pro:Imaging-1.1.7 nugroho$ sudo rm /usr/bin/gcc-4.2 
Password:
Nugrohos-MacBook-Pro:Imaging-1.1.7 nugroho$ sudo ln -s /usr/bin/llvm-gcc-4.2 /usr/bin/gcc-4.2
Nugrohos-MacBook-Pro:Imaging-1.1.7 nugroho$ python setup.py install
running install
running build
running build_py
running build_ext
-
--------------------------------------------------------------------
PIL 1.1.7 SETUP SUMMARY
--------------------------------------------------------------------
version 1.1.7
platform darwin 2.7.2 (v2.7.2:8527427914a2, Jun 11 2011, 15:22:34)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)]
--------------------------------------------------------------------
--- TKINTER support available
*** JPEG support not available
--- ZLIB (PNG/ZIP) support available
*** FREETYPE2 support not available
*** LITTLECMS support not available
--------------------------------------------------------------------
creating /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PIL.pth
Nugrohos-MacBook-Pro:Imaging-1.1.7 nugroho$

Wow, success 

Well, no need gcc4.6.2 afterall, just create symbolic link of llvm-gcc-4.2 named gcc-4.2,:)

test

Nugrohos-MacBook-Pro:Imaging-1.1.7 nugroho$ python
Python 2.7.2 (v2.7.2:8527427914a2, Jun 11 2011, 15:22:34)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import image
Traceback (most recent call last):
File "", line 1, in
ImportError: No module named image
>>> import Image
>>>

OK

Install GCC 4.6.2 on OS X Lion (success)

Still failed, for not able to access gcc-4.6.2 automatically (have to access ~/gcc462/bin), I install binary GCC from HPC. So I'm extracted gcc-lion.tar.gz. For my surprise, it's extracted with some hierarchy like usr/local/bin, usr/local/include, … and I supposed to copy it to root folder. In that case, my Xcode4.2's gcc would still intact because it's in /usr/bin .

 I wonder if all gcc compilation result'll stored to /usr/local if we didn't pass any parameter, so I checked my /usr/local/bin directory



Nugrohos-MacBook-Pro:/ nugroho$ cd usr/local/bin/
Nugrohos-MacBook-Pro:bin nugroho$ ls
2to3gfortran python-config smtpd.py
2to3-2.7 idle python2.7 smtpd2.7.py
c++ idle2.7 python2.7-32 x86_64-apple-darwin11.2.0-c++
cpp jcf-dump python2.7-config x86_64-apple-darwin11.2.0-g++
g++ pydoc pythonw x86_64-apple-darwin11.2.0-gcc
gcc pydoc2.7 pythonw-32 x86_64-apple-darwin11.2.0-gcc-4.6.2
gcj python pythonw2.7 x86_64-apple-darwin11.2.0-gcj
gcov python-32 pythonw2.7-32 x86_64-apple-darwin11.2.0-gfortran

There is gcc in it. Is in gcc-4.2?
Nugrohos-MacBook-Pro:bin nugroho$ ./gcc --version
gcc (GCC) 4.6.2
Copyright (C) 2011 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.

Yes, it is gcc-4.6.2? So, I replace gcc symlink previously  pointed to /usr/bin/llvm-gcc to /usr/local/bin/gcc

Nugrohos-MacBook-Pro:bin nugroho$ which gcc
/usr/bin/gcc
Nugrohos-MacBook-Pro:bin nugroho$ which llvm-gcc
/usr/bin/llvm-gcc
Nugrohos-MacBook-Pro:bin nugroho$ sudo ln -s gc
gcc gcj gcov
Nugrohos-MacBook-Pro:bin nugroho$ sudo ln -s gcc /usr/bin/gcc
Password:
ln: /usr/bin/gcc: File exists
Nugrohos-MacBook-Pro:bin nugroho$ sudo mv /usr/bin/gcc /usr/bin/gccOLD
Nugrohos-MacBook-Pro:bin nugroho$ sudo ln -s gcc /usr/bin/gcc
Nugrohos-MacBook-Pro:bin nugroho$ gcc
gcc: fatal error: no input files
compilation terminated.
Nugrohos-MacBook-Pro:bin nugroho$ gcc --version
gcc (GCC) 4.6.2
Copyright (C) 2011 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.

Nugrohos-MacBook-Pro:bin nugroho$
Hooray, HPC binary is left untouched, :)

Ubuntu 11.10 Oneiric Ocelot on OS X Lion via Virtual Box

It's long time since my MacBook Pro had ubuntu installed. Curious about new release of ubuntu, I decided to download .iso file via torrent network and installed it on my Mac via VirtualBox as I don't want to dual booting my Mac again (the way I did several years ago).



 I downloaded 64-bit version of Oneiric Ocelot and it's installed without problem.

 From screenshot below, we know ubuntu team has improved their installation method. While the system is busy copying file, we're prompted to fill our detail of instalation; keyboard, time zone, username. Such an efficient method.
From Blogsy Photos
From Blogsy Photos
From Blogsy Photos
From Blogsy Photos
From Blogsy Photos
From Blogsy Photos
From Blogsy Photos
From Blogsy Photos
From Blogsy Photos
From Blogsy Photos
From Blogsy Photos
From Blogsy Photos
From Blogsy Photos

Wednesday, December 14, 2011

Installing GCC 4.6.2 on OSX Lion

After searching how to's, compiling from source, installing Snow Leopard version of Xcode (on its DVD) and installing light alternate gcc 4.2 version without success (or success but not satisfied), I  installed Xcode 4.2 on my OS X Lion. Alas, Apple ship its own GCC compiler, llvm-gcc, instead GCC. So I download tar.gz version of GCC-4.6.2 from GNU and try to install it
From Blogsy Photos
From Blogsy Photos
check to know what dependencies I don't have by typing

./configure



the result is
 

configure: error: Building GCC requires GMP 4.2+, MPFR 2.3.1+ and MPC 0.8.0+.


So, I download it mpc (http://www.multiprecision.org/index.php?prog=mpc&page=download), mpfr(http://www.mpfr.org/mpfr-current/#download) and gmp(http://gmplib.org/). I don't know why gmp's download always ended by error, duh. Trying to 'torrenting' it via burnbit but still get error. I was forced to use ftp connection via Finder (Command-K) and done. Installing these dependencies is easy task, just unzip/untar these archive, cd to its directory and type three magical UNIX installation words.

$./configure
$make
$sudo make install

OK, now it's GCC time. Extract GCC zipped file, cd to its directory

./configure
make
sudo make install

You can add make command to make -j 4 if you have multicore processor and want to make process processed in parallel. "Make" process is very long time process.
Look at gnumake, cc1 , sh , and llvm-gcc-4.2 processes. They're processed in parallel.
From Blogsy Photos
From Blogsy Photos
From Blogsy Photos

 OMG, after long awaiting time, I got an error, something about libgfortran. (update: it's succeed indeed despite of error, it actually compiled gcc but not in Lion path, so Lion's still use llvm-gcc version , I post the update here) After a minute of thinking, I decide to compile just C for now, and build on separate directory and output-ed it on my home directory

Nugrohos-MacBook-Pro:gcc-4.6.2 nugroho$ mkdir build
Nugrohos-MacBook-Pro:gcc-4.6.2 nugroho$ cd build
Nugrohos-MacBook-Pro:build nugroho$ ../configure --prefix=$HOME/gcc462 --enable-languages=c

These command will build GCC on 'build' directory and store the compilation result on gcc462 directory on my home folder. If you are interested in building only a limited set of languages, just like me, you could also specify this option in the configure line. For example if you need only C, C++ and Fortran just append this to the above line: --enable-languages=c,c++,fortran
323f (5) amp (1) android (12) apple (7) arduino (18) art (1) assembler (21) astina (4) ATTiny (23) blackberry (4) camera (3) canon (2) cerita (2) computer (106) crazyness (11) debian (1) delphi (39) diary (286) flash (8) fortran (6) freebsd (6) google apps script (8) guitar (2) HTML5 (10) IFTTT (7) Instagram (7) internet (12) iOS (5) iPad (6) iPhone (5) java (1) javascript (1) keynote (2) LaTeX (6) lazarus (1) linux (29) lion (15) mac (28) macbook air (8) macbook pro (3) macOS (1) Math (3) mathematica (1) maverick (6) mazda (4) microcontroler (35) mountain lion (2) music (37) netbook (1) nugnux (6) os x (36) php (1) Physicist (29) Picture (3) programming (189) Python (109) S2 (13) software (7) Soliloquy (125) Ubuntu (5) unix (4) Video (8) wayang (3) yosemite (3)