What is CCFinder?
CCFinderX is a code-clone detector, which detects code clones (duplicated code fragments) from source files written in Java, C/C++, COBOL, VB, C#. The new CCFinderX is a major version up of CCFinder, and it has been totally re-designed and re-implemented from scratch. Its new design and technologies aim at improving performance, enabling a user-side customization of a preprocessor, and providing an interactive analysis based on metrics.
Where can I get CCFinderX?
You can download CCFinderX sources and binaries from the official CCFinderX website. However, at the moment of this writing, there are no pre-compiled binaries available. Good new is that you can follow some simple steps to compile the sources yourself.
How to compile CCFinderX
In the following I will describe step-by-step how to compile the CCFinderX under Ubuntu 9.10 Karmic Koala.
Note: Even though the sources are supposed to be used under the 32bit version of Ubuntu, I was able to successfully compile the tool under Ubuntu 9.10 amd64 without modifications of the source files. Ok! Let’s get going!
Step 1: Download the sources
To compile CCFinderX under Ubuntu you need two separate sets of files.
The actual ccfinder sources that contain the clone detection tool, shared libraries and the GUI.
pinky@brain:/sandbox$ wget http://www.ccfinder.net/download/ccfx-src.zip
In addition, Toshihiro Kamiya, the maker of CCFinderX provides additional sources and makefiles for Linux in a second archive.
pinky@brain:/sandbox$ wget http://www.ccfinder.net/download/karmicmakefileetc.7z
Step 2: Install p7zip and unzip source archives
If you have not already install p7zip for Linux you need to do so now by issuing
sudo apt-get install p7zip
Afterwards, we first move the supporting files into a new directory and unpack them:
pinky@brain:/sandbox$ mkdir karmicmakefileetc
pinky@brain:/sandbox$ mv karmicmakefileetc.7z karmicmakefileetc
pinky@brain:/sandbox$ cd karmicmakefileetc
pinky@brain:/sandbox/karmicmakefileetc$ p7zip -d karmicmakefiles.7z
Step 3: Unzip ccfinder sources
The ccfinder sources will unpack into the current directory. We will keep things clean and create a directory first, which we move the source in and unpack them there.
pinky@brain:/sandbox$ mkdir ccfinder-src
pinky@brain:/sandbox$ mv ccfx-src.zip ccfinder-src
pinky@brain:/sandbox$ cd ccfinder-src
pinky@brain:/sandbox/ccfinder-src$ unzip ccfx-src.zip
Step 4: Copy the contents from the support files to the CCFinder source folder
pinky@brain:/sandbox$ for i in karmicmakefileetc/*; do cp -Ru $i ccfinder-src/; done
Step 5: Install development tools and required libraries
If you haven’t installed the glibc and C++ compiler yet, do so by issuing
pinky@brain:/sandbox$ sudo apt-get install build-essential
CCFinderX makes extensive use of the boost-libraries, so we need to install them first.
pinky@brain:/sandbox$ sudo apt-get install libboost-dev
Step 6: Compile the ccfx binary
pinky@brain:/sandbox$ cd ccfinder-src/ccfx
pinky@brain:/sandbox/ccfinder-src/ccfx$ mv karmic.mk Makefile
pinky@brain:/sandbox/ccfinder-src/ccfx$ make
This will produce numerous warnings that we ignore for now.
Step 7: Compile the picosel module
CCFinderX uses various modules and additional tools to work. The first one is the picosel module.
pinky@brain:/sandbox$ cd ccfinder-src/picosel
pinky@brain:/sandbox/ccfinder-src/picosel$ mv karmic.mk Makefile
pinky@brain:/sandbox/ccfinder-src/picosel$ make
Again we will ignore the warnings.
Step 8: Compile the pyeasytorq module
pinky@brain:/sandbox$ cd ccfinder-src/torq/pyeasytorq
pinky@brain:/sandbox/ccfinder-src/torq/pyeasytorq$ mv karmic.mk Makefile
pinky@brain:/sandbox/ccfinder-src/torq/pyeasytorq$ vim Makefile
There we need to append the -fPIC parameter to the gcc compiler opts to make this work. After adding this
parameter the OPTS line should now read:
OPTS = -O2 -fpermissive -fPIC -I/usr/include/python2.6/
Now we can compile the module (ignore the warnings):
pinky@brain:/sandbox/ccfinder-src/torq/pyeasytorq$ make
Step 9: Compile the picoselib module
We will first need to install the open java 6 jdk if it is not already installed:
pinky@brain:/sandbox$ sudo apt-get install openjdk-6-jdk
Then we prepare the makefile for picoselib.
pinky@brain:/sandbox$ cd ccfinder-src/utility/picoselib
pinky@brain:/sandbox/ccfinder-src/utility/picoselib$ mv karmic.mk Makefile
pinky@brain:/sandbox/ccfinder-src/utility/picoselib$ vim Makefile
Again we need to append the -fPIC parameter to the compiler flags, add it to
the OPTS line, which afterwards should read:
OPTS = -O2 -fpermissive -fPIC -I/usr/lib/jvm/java-6-openjdk/include/
Save the makefile and start compilation (ignore warnings):
pinky@brain:/sandbox/ccfinder-src/utility/picoselib$ make
Step 10: Compile the CCFinderXLib module
pinky@brain:/sandbox$ cd ccfinder-src/ccfx/CCFinderXLib
pinky@brain:/sandbox/ccfinder-src/ccfx/CCFinderXLib$ mv karmic.mk Makefile
pinky@brain:/sandbox/ccfinder-src/ccfx/CCFinderXLib$ vim Makefile
Again append the -fPIC parameter to the compiler flags similar to step 8 and step 9.
Then we compile the code
pinky@brain:/sandbox/ccfinder-src/ccfx/CCFinderXLib$ make
Step 11: Test the installation
If everything worked out without errors, you should find the ccfx binary and all required modules
in the ubuntu32 directory. We run a short test to see if CCFinderX works as expected.
pinky@brain:/sandbox/ubuntu32$ ./ccfx d cpp ../ccfinder-src/ccfx/rawclonepairdata.cpp
pinky@brain:/sandbox/ubuntu32$ ./ccfx p a.ccfxd
The console output should read:
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 ../../ubuntu_9_10/ccfx/rawclonepairdata.cpp 249
}
source_file_remarks {
}
clone_pairs {
}
clone_set_remarks {
}
Congratulations! You successfully compiled CCFinderX for Ubuntu 9.10!

Comments on this entry are closed.