How to Compile CCFinderX Under Ubuntu Linux

Nicolas Bettenburg bio photo By Nicolas Bettenburg

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.

$ wget

In addition, Toshihiro Kamiya, the maker of CCFinderX provides additional sources and makefiles for Linux in a second archive.

$ wget

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:

$ mkdir karmicmakefileetc
$ mv karmicmakefileetc.7z karmicmakefileetc
$ cd karmicmakefileetc
[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.

$ mkdir ccfinder-src
$ mv ccfinder-src
$ cd ccfinder-src
[ccfinder-src] $ unzip

Step 4: Copy the contents from the support files to the CCFinder source folder

$ 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

$ sudo apt-get install build-essential

CCFinderX makes extensive use of the boost-libraries, so we need to install them first.

$ sudo apt-get install libboost-dev

Step 6: Compile the ccfx binary

$ cd ccfinder-src/ccfx
[ccfinder-src/ccfx] $ mv Makefile
[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.

$ cd ccfinder-src/picosel
[ccfinder-src/picosel] $ mv Makefile
[ccfinder-src/picosel] $ make

Again we will ignore the warnings.

Step 8: Compile the pyeasytorq module

$ cd ccfinder-src/torq/pyeasytorq
[ccfinder-src/torq/pyeasytorq] $ mv Makefile
[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):

[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:

$ sudo apt-get install openjdk-6-jdk

Then we prepare the makefile for picoselib.

$ cd ccfinder-src/utility/picoselib
[ccfinder-src/utility/picoselib] $  mv Makefile
[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):

[ccfinder-src/utility/picoselib] $ make

Step 10: Compile the CCFinderXLib module

$ cd ccfinder-src/ccfx/CCFinderXLib
[ccfinder-src/ccfx/CCFinderXLib] $ mv Makefile
[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:

[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.

/ubuntu32$ ./ccfx d cpp ../ccfinder-src/ccfx/rawclonepairdata.cpp
/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!