How Do You Create Your Own RPM Package (Binary File) for Your Own C Program?

Problem scenario
You want to know more about RPM packaging so you can create your own .rpm file (a custom RPM package file).  In other words you want to create your own RPM package (a binary file).  You want it for installing an uncompiled C program you wrote.  The uncompiled C program is one .c file and very simple.  You don’t know how to use a spec (specification) file to create your own RPM package file. 

 » Read more..

How Do You Troubleshoot the C Compile-Time Error “gcc: error trying to exec ‘cc1plus’: execvp: No such file or directory”

Problem scenario
You run gcc to compile a C program, but you get this error:
“gcc: error trying to exec ‘cc1plus’: execvp: No such file or directory”

Solution
Install a C compiler.  If you do not know how, see this posting.

 » Read more..

How Do You Troubleshoot a C Program That Prints a Warning Message like “expects argument of type ‘char*’, but argument 2 has type ‘int’ [-Wformat=]”?

Problem scenario
You compile a C program (with gcc foobar.cc) and you get an error message like this:

“foofbar1.cc:71…: warning: format ‘%s’ expects argument of type ‘char*’, but argument 2 has type ‘int’ [-Wformat=]
   printf (“y is a %s\n”, y);
                           ^  “

What do you do to not get this error?

Solution
While the code compiles, the executable may not run. 

 » Read more..

How Do You Troubleshoot Sonarqube Not Starting with Log Messages about “failed to load plugin”?

Problem scenario
You are using SonarQube Community Edition.  SonarQube will not start.  You recently moved a .jar file into a plugins directory.  You want to use this plugin to analyze code.  

The SonarQube logs may register something like “Background initialization failed. Stopping SonarQube java.lang.IllegalStateException: Fail to load plugin C / C++ / Objective-C [cpp]”

The logs may also say something like this: “Unable to register extension com.A.A.A.B.F from plugin ‘cpp’ or “NoClassFoundError…PropertiesDao”.

 » Read more..

How Do You Troubleshoot a C Program Displaying the Error “Segmentation fault” at Run Time?

Problem scenario
Your C program compiles.  But you get the error “Segmentation fault.”  You expect the value of a variable to be printed.  How do you get the value to be printed without this error?

Solution
Does every print function print?  If one print function seems to be displaying the “Segmentation fault” error, look closely at the syntax thereof.  Here is a line that will produce this error:

  

 » Read more..

How Do You Create a Function in the C Programming Language?

Problem scenario
You are familiar with functions in programming languages (e.g., Python or SQL).  You like how you can create a modular program with a function.  Functions can allow you to reuse code and do data processing in a way that is readable.  Logic can be created rapidly when you know how to use a function.  How do you write a function in the C?

Solution

Prerequisites
Install the C compiler. 

 » Read more..

How Do You Troubleshoot the C Program Error “error: expected ‘;’ before string constant”?

Problem scenario
You try to compile a program with “gcc nameofprog.cc”.  You get this output: “foobar.cc.:55:error: expected ‘;’ before string constant”

What do you do to compile your program?

Solution
Go to line 55 of foobar.cc.  If there is a printf command, be sure that the thing to be printed is surrounded by parentheses.  Here is an example of a line that will cause the problem:
   printf “This is a test”;

 » Read more..

How Do You Troubleshoot the C Program Error “warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]”?

Problem scenario
You try to compile a program with “gcc nameofprog.cc”.  You get this output:

“warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]”

What do you do to compile your program?

Solution
The program may still compile and run.  Look for the a.out file to be created.  It may be a working C program.  Just run it like this:  ./a.out

To get rid of the error,

 » Read more..

How Do You Install a C Compiler on Linux?

Problem scenario
You want to program in the C programming language on a Linux server.  How do you code in C and test your programs?

Solution
Overview

Install the C compiler.

Procedures
1.  To find your distribution of Linux run this command:  cat /etc/*-release | grep -i pretty

2.  Find the one option of the below three that applies to your Linux:

  • For a Red Hat distribution (e.g.,

 » Read more..

How Do You Install Boost C++ Libraries and Related Development Files?

Problem scenario
You want to install Boost C++ libraries and related development files.  How do you do this?

Solution
Run this command:
sudo apt-get install automake bison flex g++ git libboost1.*-all-dev libevent-dev libssl-dev libtool make pkg-config

 » Read more..