compiling interview questions

Top 15 compiling interview questions

Type of code conversion used in Linux executable files

I want to ask that what type of encoding is used to make linux executable files e.g. hexadecemal, binary or anything else. how is it converted ? Is there any way to get back the original code from this executable file?

Here's a bit of code I have:

ELF���������>�����%|�����@�������������������@�8��@���������������������@�������@�����7<�����7<������� ������������������f�����f���������������������� ������[�UPX!L
h�h�8����������?�E�h=��ڊ̓�N�    4���9ISloB�q�w�]ȉ.��,ς��Q䝦����#e��-�N����/�b,���d<��'��-E��6E�s�/�U���ly�V�Y2]"a��S�.�hU�|�S�J�I�2���X}

what is it suppose to mean?

Source: (StackOverflow)

How to properly update / install / compile ibus on 14.04, dconf problems?

I updated recently to phpstorm 9.5 and it says I should update ibus to 1.5.11 or newer (which at this point the current one).

Ok. I downloaded 1.5.11 from source and try to install it. I got some dependencies solved, but at one point I have a strange configuration error, that Package requirements (dconf >= 0.7.5) were not met.

after installing dconf-tools and other parts of the dconf package I still get this massage. Than I did sudo apt-cache show dconf-tools and found in the output that libdconf0 (<< 0.7.3-2) is causing problems, as libdconf1 is 0.20.0-1 which seems to be newer.

Assuming that on 14.04 libconfd0 is not used anymore this information is obsolete for the compiling ibus.

How can I solve this?

Edit 1:

  • installed dconf-tools, dconf-cli, dconf-editor as dconf package is not present in the packages.
  • checked the /etc directory there is dconf related stuff there
  • checked ibus/configure mechanism for dconf:

    if test x"$enable_dconf" = x"yes"; then
        # check dconf
            [dconf >= 0.7.5],
        PKG_CHECK_EXISTS([dconf >= 0.13.4],
            [AC_DEFINE(DCONF_0_13_4, TRUE, [dconf is 0.13.4 or later])],
        # check glib-compile-schemas
        enable_dconf="yes (enabled, use --disable-dconf to disable)"

Edit 2:

libdconf0 was misleading

Source: (StackOverflow)

Installing packages into local directory?

I'd like to install software packages, similar to apt-get install <foo> but:

  1. Without sudo, and
  2. Into a local directory

The purpose of this exercise is to isolate independent builds in my continuous integration server.

I don't mind compiling from source, if that's what it takes, but obviously I'd prefer the simplest approach possible. I tried apt-get source --compile <foo> as mentioned here but I can't get it working for packages like autoconf. I get the following error:

dpkg-checkbuilddeps: Unmet build dependencies: help2man

I've got help2man compiled in a local directory, but I don't know how to inform apt-get of that. Any ideas?

UPDATE: I found an answer that almost works at http://askubuntu.com/a/350/23678. The problem with chroot is that it requires sudo. The problem with apt-get source is that I don't know how to resolve dependencies. I must say, chroot looks very appealing. Is there an equivalent command that doesn't require sudo?

Source: (StackOverflow)

What's the Linux equivalent to Windows batch files?

I have a batch file which I use to create an .apk file on my Windows machine. Now I need to be able to create the .apk file in Ubuntu but I don't know how translate my .bat file to a script to be able to run it on Ubuntu.

Below is the batch file which works fine on Windows. Will you please give me some hints on how I can run it on Ubuntu?

@echo off

:: Path to Flex SDK 
set FLEX_SDK=C:\sdk\flex_sdk_4.5.1.21328

:: Path to Android SDK
set ANDROID_SDK=C:\sdk\android

if not exist "%FLEX_SDK%\bin" goto flexsdk
if not exist "%ANDROID_SDK%\platform-tools" goto androidsdk
goto succeed

if not exist "%FLEX_SDK%\bin" goto flexsdk
if not exist "%ANDROID_SDK%\platform-tools" goto androidsdk
goto succeed

echo ERROR: incorrect path to Flex SDK
if %PAUSE_ERRORS%==1 pause

echo ERROR: incorrect path to Android SDK in 'bat\SetupSDK.bat'

if %PAUSE_ERRORS%==1 pause

set PATH=%PATH%;%FLEX_SDK%\bin
set PATH=%PATH%;%ANDROID_SDK%\platform-tools

:: Android packaging
set AND_CERT_NAME="PeymanApp"
set AND_CERT_FILE=cert\SampleApp.p12
set AND_ICONS=icons/android

set AND_SIGNING_OPTIONS=-storetype pkcs12 -keystore "%AND_CERT_FILE%" -storepass     %AND_CERT_PASS%

:: Application descriptor
set APP_XML=application.xml

:: Files to package
set APP_DIR=bin

:: Your application ID (must match <id> of Application descriptor)
set APP_ID=air.com.doitflash.SampleApp

:: Output packages
set DIST_PATH=dist
set DIST_NAME=PeymanApp

%SystemRoot%\System32\find /C "<id>%APP_ID%</id>" "%APP_XML%" > NUL
if errorlevel 1 goto badid
goto end_validation

echo ERROR: Application ID (APP_ID) does NOT match Application descriptor '%APP_XML%'     (id)



set PLATFORM=android

::call bat\Packager.bat
if "%PLATFORM%"=="android" goto android-config

set DIST_EXT=apk
set TYPE=apk
goto start

if not exist "%CERT_FILE%" goto certificate
:: Output file
if not exist "%DIST_PATH%" md "%DIST_PATH%"
:: Package

echo true
call adt -package -target %TYPE%%TARGET% %OPTIONS% %SIGNING_OPTIONS% "%OUTPUT%"     "%APP_XML%" %FILE_OR_DIR% -extdir lib/
if errorlevel 1 goto failed
goto end

echo Certificate not found: %CERT_FILE%

if %PAUSE_ERRORS%==1 pause

echo APK setup creation FAILED.

if %PAUSE_ERRORS%==1 pause


Source: (StackOverflow)

How do I set up ccache?

I want to use ccache to speed up compilation. I came across how do I enable ccache

This is what I have done so far:

$ sudo apt-get install -y ccache
$ dpkg -l ccache
ii  ccache  3.1.6-1   Compiler cache for fast recompilation of C/C++ code
$ whereis ccache
ccache: /usr/bin/ccache /usr/lib/ccache /usr/bin/X11/ccache /usr/share/man/man1/ccache.1.gz

I appended ccache to path by adding to my ~/.bashrc

$ export PATH="/usr/lib/ccache:$PATH"
$ source ~/.bashrc
$ echo $PATH 

The symbolic links looks fine:

$ ll /usr/lib/ccache/
total 76
drwxr-xr-x   2 root root  4096 mai   22 10:48 ./
drwxr-xr-x 253 root root 69632 mai   22 10:48 ../
lrwxrwxrwx   1 root root    16 mai   22 10:48 avr-g++ -> ../../bin/ccache*
lrwxrwxrwx   1 root root    16 mai   22 10:48 avr-gcc -> ../../bin/ccache*
lrwxrwxrwx   1 root root    16 mai   22 10:48 avr-gcc-4.5.3 -> ../../bin/ccache*
lrwxrwxrwx   1 root root    16 mai   22 10:48 c++ -> ../../bin/ccache*
lrwxrwxrwx   1 root root    16 mai   22 10:48 c89-gcc -> ../../bin/ccache*
lrwxrwxrwx   1 root root    16 mai   22 10:48 c99-gcc -> ../../bin/ccache*
lrwxrwxrwx   1 root root    16 mai   22 10:48 cc -> ../../bin/ccache*
lrwxrwxrwx   1 root root    16 mai   22 10:48 g++ -> ../../bin/ccache*
lrwxrwxrwx   1 root root    16 mai   22 10:48 g++-4.6 -> ../../bin/ccache*
lrwxrwxrwx   1 root root    16 mai   22 10:48 gcc -> ../../bin/ccache*
lrwxrwxrwx   1 root root    16 mai   22 10:48 gcc-4.6 -> ../../bin/ccache*
lrwxrwxrwx   1 root root    16 mai   22 10:48 x86_64-linux-gnu-g++ -> ../../bin/ccache*
lrwxrwxrwx   1 root root    16 mai   22 10:48 x86_64-linux-gnu-g++-4.6 -> ../../bin/ccache*
lrwxrwxrwx   1 root root    16 mai   22 10:48 x86_64-linux-gnu-gcc -> ../../bin/ccache*
lrwxrwxrwx   1 root root    16 mai   22 10:48 x86_64-linux-gnu-gcc-4.6 -> ../../bin/ccache*

The link looks good:

$ which g++

$ make
g++ -o affine_euler affine_euler.cpp -O3 -DEIGEN_NO_DEBUG -I/usr/include/eigen3
g++ -o test_eigen test_eigen.cpp -O3 -DEIGEN_NO_DEBUG -I/usr/include/eigen3

But the cache is empty:

$ ccache -s
cache directory                     /home/dell/.ccache
cache hit (direct)                     0
cache hit (preprocessed)               0
cache miss                             0
files in cache                         0
cache size                             0 Kbytes
max cache size                       1.0 Gbytes

Where am I wrong ?

Source: (StackOverflow)

Build 32-bit on 64-bit Ubuntu: installing ia32-libs does not include libstdc++

Googled for a while but drawn a blank.

Need to build 32-bit app on 64-bit Ubuntu.

Realise that I need to install ia32-libs. I have done this and apt-get tells me it's already at the latest version.

This link: http://packages.debian.org/squeeze/amd64/ia32-libs/filelist says that libstdc++ should be in /usr/lib32

It's not there!

I have uninstalled, reinstalled (with force) ia32-libs.

Any ideas? How can I get this critter on my box?

Ta, Ben

Source: (StackOverflow)

Can I rebuild a package without recompiling the source?

I am building a new .deb and want to fix lintian errors in the packaging. However, every time I rebuild, the rules file does a 'make clean' and thus starts compiling again.

Is there a way to instruct the build process that I do not want to recompile, that I'm just altering the packaging, and using the last set of binaries will be fine for now?

Source: (StackOverflow)

How to compile C++ source code ("iostream.h not found" error)?

I do not want to discuss about C++ or any programming language!I just want to know what am i doing wrong with linux ubuntu about compiling helloworld.cpp!

I am learning C++ so my steps are:

open hello.cpp in vim and write this

#include <iostream.h>
int main()
    cout << "Hello World!\n";`
    return 0;

So, after that i tried in the terminal this

g++ hello.cpp

AND the output is

hello.cpp:1:22: fatal error: iostream.h: No such file or directory
compilation terminated.

What do you suggest? Any useful step by step guide for me?Thanks!

Source: (StackOverflow)

How (recipe) to build only one kernel module?

I have a bug in a Linux kernel module that causes the stock Ubuntu 14.04 kernel to oops (crash).

That is why I want to edit/patch the source of only that single kernel module to add some extra debug output. The kernel module in question is mvsas and not necessary to boot. For that reason I don't see any need to update any initrd images.

I have read a lot of information (as shown below) and find the setup and build process confusion. I need two recipes:

  1. to setup/configure the build environment once
  2. steps to do after editing any source file of this kernel module (.c and .h) and converting that edit into a new kernel module (.ko)

The sources that have been used are:

Source: (StackOverflow)

No acceptable C compiler found in $PATH

I want to install one package named speech_tools-2.1-release.tar.gz. After I run command ./configure in this package, it show me a message:

Configure: error: no acceptable C compiler found in $PATH  
See 'config.log' for more details  

What do I do?

Source: (StackOverflow)

How to solve configure: error: readline library not found?

I have an Ubuntu 10.04 LTS server with a minimal install that I want to compile postgres on. With the minimal install the server did not have gcc so I had to do an apt-get install gcc but now I keep getting this error from the postgres ./configure.

configure: error: readline library not found

I can't seem to find the name of the package that contains the readline library. So I have two questions.

  1. What is the name of the package that contains readline?
  2. Is there some way given the error message above for me to find the associated package from its standard name?

Source: (StackOverflow)

How to build all my installed package from sources?

I've read about how source-based linux distros like Gentoo can have considerable performance increases when compared to pre-built distros like Ubuntu because they install from source with optimizations for your particular system. Is is possible to build Ubuntu from source to get the same kind of benefit?

Source: (StackOverflow)

Compile OpenGL Program (Missing GL/gl.h)

I am a complete Linux/Ubuntu noob, so I apologize for any dumb portions of this question or follow up ones.

I am trying to get a program that my software engineering class's group wrote onto my home computer. At school, we have Linux, and it will compile and run fine there. I downloaded VMWare, installed Ubuntu on a virtual machine, and now am trying to get my program to open.

When ever I try to run my make file however, I get an error that says

gcc -I../include -pthread -O1 -c rain.c
In file included from rain.c:19:0:
../include/GL/glfw.h:176:21: fatal error: GL/gl.h: No such file or directory
compilation terminated.
make: *** [rain.o] Error 1

Would anyone happen to know why it can't find this file, when it can on my school computers? And what I'd need to do to download it or get it in the right spot?

Source: (StackOverflow)

Cross-Compile for ARM?

How do I set up GCC for cross compiling for the ARM processor? The host would be on x68 ( AMD64 - Ubuntu 12.04 ) and the target would be ARM ( Raspberry Pi as well as Pandaboard - will do separate compilations for each )?

Source: (StackOverflow)

cmake fails with "CMake Error: your CXX compiler: "CMAKE_CXX_COMPILER-NOTFOUND" was not found."

jonquil@jonquil-Satellite-L755D:~/Downloads/akonadi-googledata-1.2.0/build$ cmake ..
-- The C compiler identification is GNU
-- The CXX compiler identification is unknown
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
CMake Error: your CXX compiler: "CMAKE_CXX_COMPILER-NOTFOUND" was not found.   Please set CMAKE_CXX_COMPILER to a valid compiler path or name.
CMake Error at /usr/share/cmake-2.8/Modules/FindKDE4.cmake:98 (MESSAGE):
  ERROR: cmake/modules/FindKDE4Internal.cmake not found in
Call Stack (most recent call first):
  CMakeLists.txt:6 (find_package)

CMake Warning (dev) in CMakeLists.txt:
  No cmake_minimum_required command is present.  A line of code such as

    cmake_minimum_required(VERSION 2.8)

  should be added at the top of the file.  The version specified may be lower
  if you wish to support older CMake versions for this project.  For more
  information run "cmake --help-policy CMP0000".
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Configuring incomplete, errors occurred!

With autotools I get this:

jonquil@jonquil-Satellite-L755D:~/Downloads/akonadi-googledata-1.2.0/build/build$ autoreconf -i -f
Can't exec "libtoolize": No such file or directory at /usr/bin/autoreconf line 196.
Use of uninitialized value in pattern match (m//) at /usr/bin/autoreconf line 196.
autoreconf: `configure.ac' or `configure.in' is required

Source: (StackOverflow)