Friday, February 26, 2016

Troubleshooting Compilations Problems for C/CIL Programs


I have recently encounter several issues when I try to compile some open-source C programs. I am able to resolve all of these issues by searching for solutions on technical forums. I have summarized the solution that I have for each error message that I have encountered for your reference. Note that I have tested all the mentioned solutions only on Ubuntu 14.04.

Problem: configure.ac:27: error: possibly undefined macro: AC_DEFINE
     If this token and others are legitimate, please use m4_pattern_allow.
     See the Autoconf documentation.
Solution: sudo apt-get install pkg-config

Problem: configure:11013: error: possibly undefined macro: gl_FEATURES_H
         If this token and others are legitimate, please use m4_pattern_allow.
         See the Autoconf documentation.
Solution 1: Replace m4/gnulib-common.m4 with latest version of m4/gnulib-common.m4 from master branch. e.g, http://fossies.org/linux/metalog/gnulib/m4/gnulib-common.m4.
Solution 2: Insert the following to m4/gnulib-common.m4
# Test whether <features.h> exists.
# Set HAVE_FEATURES_H.
AC_DEFUN([gl_FEATURES_H],
[
  AC_CHECK_HEADERS_ONCE([features.h])
  if test $ac_cv_header_features_h = yes; then
       HAVE_FEATURES_H=1
  else
       HAVE_FEATURES_H=0
  fi
  AC_SUBST([HAVE_FEATURES_H])
]) 
Source: https://redmine.lighttpd.net/issues/522

Problem: File be.po does not exist. If you are a translator, you can create it through 'msginit'.

Solution: make -k update

Problem: How to Install and update locale?
$ sudo locale-gen "en_US.UTF-8"
Generating locales...
 en_US.UTF-8... done
Generation complete.

sudo dpkg-reconfigure locales
Generating locales...
 en_US.UTF-8... up-to-date
Generation complete.


Problem: ja_JP.SJIS not found
Solution: Note that while the original solution was for debian, I have tested this on ubuntu 14.04 as well
sudo touch /var/lib/locales/supported.d/ja
sudo echo "ja_JP.UTF-8 UTF-8" >>/var/lib/locales/supported.d/ja sudo echo "ja_JP SJIS" >>/var/lib/locales/supported.d/ja sudo echo "ja_JP.EUC-JP EUC-JP" >>/var/lib/locales/supported.d/ja
sudo dpkg-reconfigure locales

Source: https://code.google.com/archive/p/winelocale/wikis/AddLocalesToDebian.wiki

CIL Compilations

Problem: cannot find -lstr
Solution:    

locate libcamlstr
cd /usr/lib/ocaml
sudo ln -s libcamlstr.a libstr.a

Source:http://stackoverflow.com/questions/13584629/ocaml-compile-error-usr-bin-ld-cannot-find-lstr


Scrapy Installation

Problem: Unable to install Scrapy: "error: command 'gcc' failed:

 c/_cffi_backend.c:2:20: fatal error: Python.h: No such file or directory

Source: http://stackoverflow.com/questions/33454808/unable-to-insall-scrapy-error-command-gcc-failed-with-exit-status-1

 Solution:     

1. Install the following dependency:
sudo apt-get install build-essential libssl-dev libffi-dev python-dev libxml2 python-lxml
2. Then install Scrapy using Pip:
sudo pip install Scrapy