Currently there is no distribution of CCFinder for Mac OS. However, we can download the existing source code of CCFinder for Ubuntu, and modify it as necessary to successfully compile it on Mac. In the next following steps, I will describe how to create the working environment of CCFinder and make the necessary modifications.

Getting CCFinder
You can download the source code of CCFinder from the official CCFinderX website. Download both the ccfx-src.zip and karmicmakefileetc.7z. The first zip archive is the source code of CCFinder clone detection tool, while the second 7z archive provides you the necessary Makefiles to compile CCFinder on Ubuntu OS. You will need 7-Zip file archiver to decompress karmicmakefileetc.7z.

Installing Prerequisite Libraries
You need two external libraries to successfully compile CCFinder: Boost and ICU. You can use MacPorts to download and install these libraries. If you do not have MacPorts already installed in your computer, you can follow the detail instructions in MacPorts Guide to install it. After successfully install MacPorts, type "sudo port install boost" and "sudo port install boost" in terminal to install Boost and ICU. You will need to have an administrative privilege to install these libraries.

Preparing CCFinder Source Code
  • Create a directory named CCFinder at anywhere in your computer. We will call this directory as HOME.
  • Copy the ccfx-src.zip into HOME and unzip over there.
  • Decompress the karmicmakefileetc.7z archive and copy the content in HOME.






Prerequisite Installation



0. Xcode



Click => App Store => Find ‘XCode” => Install


1. Xcode Command Line Tools



* Open Xcode => Click “Xcode” Menu in the top left of the screen near the Apple logo

* Click the “Downloads” tab => Click the “install” button (See the following figure.)

external image xPtQ6jiSk7w7i8pnHFnHO5CWL04GDBPO5cGSVzmPVG8rTDNqHoOZAQbXd9FyMg8k9Mszi8YSTUNhBQXIqkYW79BF9Uz9TdHE0IawqnisI2-XBnx3fm8sgLYx

3. Homebrew



> $ ruby -e "$(curl -fsSL __https://raw.github.com/mxcl/homebrew/go__)"
> $ brew doctor
Your system is ready to brew.


4. Install wget



> $ brew install wget


5. 7z Archive Tool



> $ brew install p7zp


* GUI Tool
Visit the website: __http://www.kekaosx.com/en/__
Download to install Keka to handle “7z files”


6. Boost C++ Lib



> $ brew install boost


7. ICU



> $ wget http://download.icu-project.org/files/icu4c/51.2/icu4c-51_2-src.tgz
> $ tar xzvf icu4c-51_2-src.tgz
> $ cd icu/source
> $ chmod +x runConfigureICU configure install-sh
> $ ./runConfigureICU MacOSX
...
ICU for C/C++ 51.2 is ready to be built.
> $ make
...
> $ sudo make install


How to Compile CCFinder



(Written reffering to __http://nicolas-bettenburg.com/?p=290__ and in the presence of Na Meng’s help.)


0.1 Download ccfx-src and an additional file



> $ mkdir ccfinder-src; cd ccfinder-src
> $ wget http://www.ccfinder.net/download/ccfx-src.zip
> $ wget http://www.ccfinder.net/download/karmicmakefileetc.7z


0.2 Uncompress the files



> $ unzip ccfx-src.zip
> $ 7z x karmicmakefileetc.7z


Step 1: compile ccfx



> $ cd ccfx
> $ vi ../common/ffuncrenamer.h


49 #define FTELL64 ftello ftello64
50 #define FTELL ftell
51 #define FSEEK64 fseek fseeko64
52 #define FSEEK fseek


> $ vi karmic.mk


Add “-lboost_system-mt” in the following line in Makefile
LIBS = -licule -licutu -licuio -licuuc -liculx -licudata -licui18n -lboost_thread-mt -lboost_system-mt
#LIBS = -licule -licutu -licuio -licuuc -liculx -licudata -licui18n -lboost_thread-mt


> $ make -f karmic.mk


Step 2: compile picosel



> $ cd ../picosel
> $ make -f karmic.mk


Step 3: compile pyeasytorq



> $ cd ../torq/pyeasytorq
> $ vi karmic.mk


Replace “-I/usr/include/python2.6/” with “/Library/Frameworks/Python.framework/Headers”
Add “-fPIC” at the following line:


OPTS = -O2 -fpermissive -fPIC -I/Library/Frameworks/Python.framework/Headers
#OPTS = -O2 -fpermissive -I/usr/include/python2.6/


Add “-lboost_system-mt” and “-lpython” in the following line in Makefile


LIBS = -licule -licutu -licuio -licuuc -liculx -licudata -licui18n -lboost_thread-mt -lboost_system-mt -lpython
#LIBS = -licule -licutu -licuio -licuuc -liculx -licudata -licui18n -lboost_thread-mt


> $ make -f karmic.mk


Step 4: picoselib



> $ cd ../../utility/picosellib/
> $ vi karmic.mk


OPTS = -O2 -fpermissive -I/System/Library/Frameworks/JavaVM.framework/Headers
#OPTS = -O2 -fpermissive -I/usr/lib/jvm/java-6-openjdk/include/


$(CC) $(LIBS) -shared -undefined dynamic_lookup -o $@ $(OBJS)
#$(CC) $(LIBS) -shared -o $@ $(OBJS)


> $ make -f karmic.mk


Step 5 CCFinderXLib:



> $ cd ../../ccfx/CCFinderXLib/
> $ vi karmic.mk


OPTS = -O2 -fpermissive -fPIC -I/System/Library/Frameworks/JavaVM.framework/Headers
#OPTS = -O2 -fpermissive -I/usr/lib/jvm/java-6-openjdk/include/


> $ make -f karmic.mk


Step 6: Test the installation



> $ cd ../../ubuntu32
> $ ./ccfx d cpp ../ccfx/rawclonepairdata.cpp
> $ ./ccfx p a.ccfxd
version: ccfx 10.2.7
format: pair_diploid
option: -b 50
option: -s 2
option: -u +
option: -t 12
option: -w f+g+w+
option: -j +
option: -k 60m
option: -preprocessed_file_postfix .cpp.2_0_0_2.default.ccfxprep
option: -pp +
preprocess_script: cpp
source_files {
1../ccfx/rawclonepairdata.cpp249
}
source_file_remarks {
}
clone_pairs {
}
clone_set_remarks {
}


Congratulations! You successfully compiled CCFinderX for Mac OSX!


Step 7: Set Path



> $ vi ~/.profile


export PATH=$CCFINDER_COMPILED_PATH/ubuntu32:$PATH




Please see the following cases to catch the compile errors.

ERROR 1


../common/datastructureonfile.h:87: error: ‘fseeko64’ was not declared in this scope


FIX


> $ vi ../common/ffuncrenamer.h
#define FTELL64 ftell ftello64
#define FSEEK64 fseek fseeko64
> $ make -f karmic.mk


ERROR 2


Undefined symbols for architecture x86_64:
"boost::system::system_category()", referenced from:


FIX


> $ vi karmic.mk
Add “-lboost_system-mt” in the following line in Makefile
LIBS = -licule -licutu -licuio -licuuc -liculx -licudata -licui18n -lboost_thread-mt -lboost_system-mt
#LIBS = -licule -licutu -licuio -licuuc -liculx -licudata -licui18n -lboost_thread-mt
> $ make -f karmic.mk



ERROR 3


/usr/include/c++/4.2.1/bits/localefwd.h:58:34: error: macro "isspace" passed 2 arguments, but takes just 1


FIX


> $ vi karmic.mk
Replace “-I/usr/include/python2.6/” with “/Library/Frameworks/Python.framework/Headers”
OPTS = -O2 -fpermissive -fPIC -I/Library/Frameworks/Python.framework/Headers
#OPTS = -O2 -fpermissive -fPIC -I/usr/include/python2.6/
> $ make -f karmic.mk


ERROR 4


"boost::system::system_category()", referenced from:
global constructors keyed to _ZN8easytorq4TreeC2ERKSsin easytorq.o


See ERROR 2


ERROR 5


Undefined symbols for architecture x86_64:
"_PyArg_ParseTuple", referenced from:


FIX


> $ vi karmic.mk
Add “-lpython” at the following line
LIBS = -licule -licutu -licuio -licuuc -liculx -licudata -licui18n -lboost_thread-mt -lboost_system-mt -lpython
#LIBS = -licule -licutu -licuio -licuuc -liculx -licudata -licui18n -lboost_thread-mt
> $ make -f karmic.mk


ERROR 6


Undefined symbols for architecture x86_64:
"make_temp_file_on_the_same_directory(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)", referenced from:


FIX
$(CC) $(LIBS) -shared -undefined dynamic_lookup -o $@ $(OBJS)
#$(CC) $(LIBS) -shared -o $@ $(OBJS)
> $ make -f karmic.mk



If you conflict with MacPorts using Brew, remove MacPorts

__http://deephill.com/macports-vs-homebrew/__


> $ sudo port -fp uninstall installed


> $ sudo rm -rf \


/opt/local \


/Applications/DarwinPorts \


/Applications/MacPorts \


/Library/LaunchDaemons/org.macports.* \


/Library/Receipts/DarwinPorts*.pkg \


/Library/Receipts/MacPorts*.pkg \


/Library/StartupItems/DarwinPortsStartup \


/Library/Tcl/darwinports1.0 \


/Library/Tcl/macports1.0 \


~/.macports