Hi...
I have a static library, libxbgi.a. When I want to properly link a program with this library I have to write: gcc prog.c -o prog -lm -L /usr/X11R6/lib -lX11 -L. -lxbgi It is cumbersome to write such a long command line. Is it possible to pre-link the libX11.a and libm.a with libxbgi.a, so that the command line will read: gcc prog.c -o prog -L. -lxbgi.a

You're getting into the realm of needing a makefile. Ask man about the make utility.

Heard of Unix aliases ?!
If you don't wanna do that, you can also say x="that whole command"
and then
$x

@thekashap and Narue:

I know both are acceptable solutions, but what I'm looking is for the library libxbgi.a itself to contain the linked object codes from libX11.a and libm.a

Kinda something like this: gcc -<the magic flag> -c *.c -L /usr/X11R6/lib -lX11 -lm (*.c contain codes for libxbgi.a) ar rc libxbgi.a *.o Then users can link their files using just: gcc prog.c -o prog -L -lxbgi I know it seems impossible, and maybe is too, but I thought if it is possible someone here would know it...

>I know it seems impossible
What it seems is stupid. But since you insist on doing something stupid, for probably a stupid reason, you can unpack both libraries and repack them using ar.

you can unpack both libraries and repack them using ar.

How do you unpack? I know that my compiler doesn't allow archiving archive files.

>I know it seems impossible
What it seems is stupid. But since you insist on doing something stupid, for probably a stupid reason, you can unpack both libraries and repack them using ar.

Well the reason is that I want "users" to be able to compile their code with my library without needing lots of compiler options... yeah, thats stupid. Another reason is that the location of libX11.a is not standard.

Anyway I think I can use ar to unpack and repack the libraries :$.
Thanks and cheers!!

>yeah, thats stupid.
I'm glad we agree.

>Another reason is that the location of libX11.a is not standard.
...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.