Results 1 to 3 of 3
When I try to link my code with a static library (libxxx.a), I encountered problems specifying the path.
The following works:
Code:
gcc -o myexe (path of libxxx.a)/libxxx.a mysrc.c
But ...
- 06-23-2008 #1Just Joined!
- Join Date
- Feb 2008
- Posts
- 21
Question linking to static library
When I try to link my code with a static library (libxxx.a), I encountered problems specifying the path.
The following works:
But it seems thatCode:gcc -o myexe (path of libxxx.a)/libxxx.a mysrc.c
doesn't work.Code:gcc -L(path of libxxx.a) -lxxx -o myexe mysrc.c
Does the -L,-l pair only apply in dynamic linking?
- 06-23-2008 #2
Try this:
You have to make sure your system supports dynamic linking of course.Code:gcc -static -L(path of libxxx.a) -lxxx -o myexe mysrc.c
- 06-23-2008 #3Just Joined!
- Join Date
- Feb 2008
- Posts
- 21
Merci beaucoup!
But it turns out that without -static it also works. The order of arguments should be changed:
gcc manual says that -L/-l pair takes effect only after a precedent source file.Code:gcc mysrc.c -L(path of libxxx.a) -lxxx -o myexe


Reply With Quote