Nov 10, 2009
Nov 5, 2009
Image Magick: 32bit MacOSX installation
Mac OS X-specific Build instructions
Perform these steps as an administrator or with the sudo command:
* Install Fink. The default setup creates a /sw folder on your main hard
* drive. Make sure /sw/bin is in your path.
* Install the latest Xcode from Apple.
* Create a symbolic link in /Developer/SDKs/MacOSX10.4u.sdk/ to /sw:
cd /Developer/SDKs/MacOSX10.4u.sdk
ln -s sw /sw
* Use Fink, or FinkCommander to install any delegate libraries you
* require, for example:
fink install libjpeg
As a regular user or administrator:
* Download the ImageMagick source distribution.
* Unpack and change into the top-level ImageMagick directory:
tar xvfz ImageMagick-6.3.3-0.tar.gz
cd ImageMagick-6.3.3
* Choose an architecture and set your CFLAGS environment variable. Here we
* set CFLAGS for an Intel build:
export CFLAGS="-O -g -isysroot /Developer/SDKs/MacOSX10.4u.sdk/ -arch i386 -I/sw/include/"
* Set your LDFLAGS environment variable to:
export
LDFLAGS="-Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk/,-L/sw/lib/"
* Configure ImageMagick:
./configure --prefix=/sw --with-quantum-depth=16 \
--disable-dependency-tracking --with-x=yes \
--x-includes=/usr/X11R6/include --x-libraries=/usr/X11R6/lib \
--without-perl
* Build ImageMagick:
make
* Install ImageMagick:
sudo make install
* To test the ImageMagick GUI, start X11 and in a new shell and type:
display -display :0
Perform these steps as an administrator or with the sudo command:
* Install Fink. The default setup creates a /sw folder on your main hard
* drive. Make sure /sw/bin is in your path.
* Install the latest Xcode from Apple.
* Create a symbolic link in /Developer/SDKs/MacOSX10.4u.sdk/ to /sw:
cd /Developer/SDKs/MacOSX10.4u.sdk
ln -s sw /sw
* Use Fink, or FinkCommander to install any delegate libraries you
* require, for example:
fink install libjpeg
As a regular user or administrator:
* Download the ImageMagick source distribution.
* Unpack and change into the top-level ImageMagick directory:
tar xvfz ImageMagick-6.3.3-0.tar.gz
cd ImageMagick-6.3.3
* Choose an architecture and set your CFLAGS environment variable. Here we
* set CFLAGS for an Intel build:
export CFLAGS="-O -g -isysroot /Developer/SDKs/MacOSX10.4u.sdk/ -arch i386 -I/sw/include/"
* Set your LDFLAGS environment variable to:
export
LDFLAGS="-Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk/,-L/sw/lib/"
* Configure ImageMagick:
./configure --prefix=/sw --with-quantum-depth=16 \
--disable-dependency-tracking --with-x=yes \
--x-includes=/usr/X11R6/include --x-libraries=/usr/X11R6/lib \
--without-perl
* Build ImageMagick:
make
* Install ImageMagick:
sudo make install
* To test the ImageMagick GUI, start X11 and in a new shell and type:
display -display :0
Nov 3, 2009
Running shell command from Java program
Following program runs the shell copy command "cp" from a java program:
import java.util.regex.*;
import java.io.*;
class ExecDemo {
public static void main(String args[]) {
Runtime r = Runtime.getRuntime();
Process p = null;
try {
File fin = new File("sampleNames.txt");
FileInputStream fis = new FileInputStream(fin);
BufferedReader in = new BufferedReader(new InputStreamReader(fis));
String aLine = = null;
String destinationPath = "output/" + "ls_log_untruncated_reshape" + "/";
System.out.println(destinationPath);
while((aLine = in.readLine()) != null) {
String filePath = "input/" +aLine + "/"+ aLine + "_"+"ls_log_untruncated_reshape.txt";
System.out.println(aLine);
String command = "cp " + filePath + " " + destinationPath;
System.out.println(command);
p = r.exec(command);
}
}catch (FileNotFoundException e) {
System.out.println("Cannot find the input file.");
}
catch (Exception e) {
System.out.println("Error running the command.");
}
}
}
References :
Reference 1
Reference 2
import java.util.regex.*;
import java.io.*;
class ExecDemo {
public static void main(String args[]) {
Runtime r = Runtime.getRuntime();
Process p = null;
try {
File fin = new File("sampleNames.txt");
FileInputStream fis = new FileInputStream(fin);
BufferedReader in = new BufferedReader(new InputStreamReader(fis));
String aLine = = null;
String destinationPath = "output/" + "ls_log_untruncated_reshape" + "/";
System.out.println(destinationPath);
while((aLine = in.readLine()) != null) {
String filePath = "input/" +aLine + "/"+ aLine + "_"+"ls_log_untruncated_reshape.txt";
System.out.println(aLine);
String command = "cp " + filePath + " " + destinationPath;
System.out.println(command);
p = r.exec(command);
}
}catch (FileNotFoundException e) {
System.out.println("Cannot find the input file.");
}
catch (Exception e) {
System.out.println("Error running the command.");
}
}
}
References :
Reference 1
Reference 2
Oct 15, 2009
Java 1.6 for Mac OSX
Java 1.6 is not installed as default. You can download it from the
Apple Developer Connection (ADC) from the download section(if you are a member of ADC).
when you type java at the command line, it invokes /usr/bin/java which is really a link to the Java Framework.
Java Link
cmar$ ls -la /usr/bin/java
lrwxr-xr-x 1 root wheel 74 Apr 30 08:41 /usr/bin/java -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java
Switching you default
If you want to switch your default then you need to either modify the link /usr/java/bin
sudo ln -s /System/Library/Frameworks/JavaVM.framework/Versions/1.6/Commands/java /usr/bin/java
You might have to do "rm /usr/java/bin" first to remove the link before creating a new one.
Or you can just create an alias in your ~/.bash_login
alias java=/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Commands/java
Reference
Apple Developer Connection (ADC) from the download section(if you are a member of ADC).
when you type java at the command line, it invokes /usr/bin/java which is really a link to the Java Framework.
Java Link
cmar$ ls -la /usr/bin/java
lrwxr-xr-x 1 root wheel 74 Apr 30 08:41 /usr/bin/java -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java
Switching you default
If you want to switch your default then you need to either modify the link /usr/java/bin
sudo ln -s /System/Library/Frameworks/JavaVM.framework/Versions/1.6/Commands/java /usr/bin/java
You might have to do "rm /usr/java/bin" first to remove the link before creating a new one.
Or you can just create an alias in your ~/.bash_login
alias java=/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Commands/java
Reference
Oct 3, 2009
Sep 29, 2009
Parsing a comma separated string in C++
int split(const string& s, char c, vector& v) {
string::size_type i = 0;
string::size_type j = s.find(c);
while (j != string::npos) {
v.push_back(s.substr(i, j-i));
i = ++j;
j = s.find(c, j);
if (j == string::npos)
v.push_back(s.substr(i, s.length( )));
}
return v.size();
}
reference
string::size_type i = 0;
string::size_type j = s.find(c);
while (j != string::npos) {
v.push_back(s.substr(i, j-i));
i = ++j;
j = s.find(c, j);
if (j == string::npos)
v.push_back(s.substr(i, s.length( )));
}
return v.size();
}
reference
Sep 27, 2009
Subscribe to:
Posts (Atom)
