Re: Compiling C applications

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"Marcus Carey" <marcuscarey@xxxxxxxxxxx> writes:

> I have an application that uses the Mysql C-API and another library.
>
> The application is on a remote host and I must compile it using the
> -shared flag to use the Mysql C-API.
>
> My problem is I need to use the static version of the second library.
>
> Is it possible to compile an application with gcc that uses both
> shared and static libraries? 

I'm not sure I really understand your question.

If you need to use the -shared flag, that implies that the MySQL C-API
does a dlopen of a shared library which you provide.  That is possible
but it doesn't seem very likely to me.

In any case, if you have a static library, and you need to link it
into a shared library, and the static library was not compiled with
-fPIC, then you are in trouble on some platforms.  On x86_64 in
particular, you can not link code compiled without -fPIC into a shared
library.  So if that is your platform, you need to recompile the
static library with -fPIC.  And compiling with -fPIC will be advisable
on any platform for code which goes into a shared library.

Ian

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux