Archive for the ‘GCC’ Category

C/C++ – GCC create a static library

September 1, 2006

You can create a static library from object files using the following command:

ar rcs libfunc.a func1.o func2.o func3.o

To link the libary to your code you can use use:

g++ -o exe_file exe_file.o -L. -lfunc


Unused dependencies in binaries

July 20, 2006

Unused libraries:
ldd -u -r BINARY

Compile RPM From Source

July 20, 2006

To compile rpms from the src.rpm:

rpmbuild –rebuild –target i686 <src.rpm file>

Profiling with gprof

July 20, 2006

How to profile with gprof:

Compile with -pg:

gcc -pg -o <program> program.c

Run program normally:


Get profile statistics:

gprof <program> gmon.out > profile.txt
more profile.txt

Compile GCC for SimpleScalar

July 20, 2006

How to compile gcc- for SimpleScalar-pisa:

First, get:


Unpack all, you should have at least these 3 directories:


and other directories (but these are important).

Choose the prefix directory (destination, where to install the binaries).
I chose ~/opt/gcc-ss

Copy ssbig-na-sstrix to your prefix directory.

Create another two directories, e.g. build1, build2

To compile, do:

> cd build1
>../simpleutils-990811/configure --target=sslittle-na-sstrix --with-gnu-as
--with-gnu-ld --prefix=$HOME/opt/gcc-ss
> make
> make install

Comment out the following line in gcc-

#if defined(bsd4_4)
extern const char *const sys_errlist[];
//extern char *sys_errlist[]; <--

> cd ../build2
>../gcc- --target=sslittle-na-sstrix --with-gnu-as --with-gnu-ld
>make LANGUAGES="c" CFLAGS="-O3" CC="gcc"
>make install LANGUAGES="c" CFLAGS="-O3" CC="gcc"


Dynamic Section of a Binary

July 20, 2006

Find info from the dynamic section of a binary:

dump -Lv <binary>

xlib annoying messages

July 20, 2006

To remove annoying messages from xlib, like:

/opt/X11R6.3/include/X11/Xutil.h:879: ISO C++ forbids declaration of
`XUnionRegion’ with no type
/opt/X11R6.3/include/X11/Xutil.h:903: ISO C++ forbids declaration of
`XXorRegion’ with no type

x_includes = -isystem /opt/X11R6.3/include

dynamic libraries

July 20, 2006

To create dynamic libraries and to work with dlopen

host:~/test> gcc -g -o testdl testdl.c -ldl
host:~/test> gcc -shared -o hello -fPIC hello.c