tags:

views:

142

answers:

4

I use gcc.

Can someone provide a tutorial or reference for linking external libraries.

A: 

There's a number of hits out there, but this was the first one google returned.

kidjan
A: 

These were the first two links that appeared in Google for "gcc linking".

mingos
+1  A: 

What is the problem you're facing? Are you running Linux?

For linking against dynamically linked libraries:

gcc ... -L/where/library/is -llibname-less-lib

For linking against my libmylib:

gcc ... -L/opt/libmylib/lib -lmylib

Or if using static libraries:

gcc ... /opt/libmylib/lib/libmylib.a
Vitor Py
The libraries should be the last thing on the gcc command line, not the first.
anon
@Neil Butterworth Yes, but adding ... to the command line was an after thought :) Anyway, I corrected it.
Vitor Py
And if it's C++, then use `g++` instead of `gcc` to link with the C++ runtime library.
Mike Seymour