How to Install 32-bit Wine on CentOS 7

Since version 7, RHEL has only x86-64 versions. The same thing happens to CentOS 7. In CentOS 7/EPEL, there is only package for Wine x86-64. However, many Windows .exe files are 32-bit. Even there are 64-bit versions for some software, their installation file is 32-bit. And for some certain software such as Office 2007, 32-bit wine is preferred. In this post, we will check how to install 32-bit Wine 1.8 on CentOS 7. » Read more

How to Statically Link C and C++ Programs on Linux with gcc

Before statically linking you C and C++ programs, you should be aware of the drawbacks of the static linking especially with glibc. There are some good discussions already: with glibc you’re linking static programs which are not really static and some others here and here. That said, you can choose to statically link C and C++ programs on Linux, only when you know what you are doing and why. » Read more

Measuring Time Accurately in Programs

It is quite common to measure the time in programs using APIs like clock() and gettimeofday(). We may also want to measure the time “accurately” for certain purposes, such as measuring a small piece of code’s execution time for performance analysis, or measuring the time in time-sensitive game software. It is hard to measure the time very accurately. But we surely can measure the time to the granularity that we can accept for our purpose. » Read more

Inline Assembly with GCC on Linux

One cool feature of gcc is that it can inline assembly into C code. With inline assembly, the programmer can precisely control the execution of the processor, such as forcing variables to use registers, getting special processor state efficiently, and writing critical efficient code in assembly by hand. I compile a list of tutorials from the Internet about inline assembly with gcc on Linux. » Read more

Generating Mixed Source and Assembly List using GCC

When debugging and optimizing programs, developers sometimes need to generate and investigate into the assembly generated by the compiler. Generating a mixed source and assembly list will help a lot for debugging and optimization. gcc can achieve this by working with the assembler. Generate assembly list mixed with the source code Just add these gcc compile options: -Wa,-adhln -g The command: $ gcc -Wa,-adhln -g source_code.c > assembly_list.s The options: -g: Produce debugging information -Wa,option: Pass option as an option to the assembler -adhln: a: turn on listings d: omit debugging directives; n: omit forms processing h: include high-level source l: include assembly One example The source code: helloworld.c: #include <stdio.h> int main() { printf("Hello world!\n"); return 0; } The command: $ gcc -Wa,-adhln -g helloworld.c > helloworld.s helloworld.s: ... » Read more