help-gplusplus
[Top][All Lists]
Advanced

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

Re: Problems linking together gtk and openssl on F7


From: Bernd Strieder
Subject: Re: Problems linking together gtk and openssl on F7
Date: Mon, 02 Jul 2007 19:23:04 +0200
User-agent: KNode/0.10.4

Hello,

Robert Cahn wrote:

> I've just going up the learning curve on gtk.  I've been compiling
> code using the line
> 
> gcc sv.c -o sv `pkg-config --cflags --libs gtk+-2.0`

In general options are used on files coming later. You mix compiler
options and linker options. You'd better separate the steps. First
producing sv.o with the the right compiler options, then sv from sv.o
with the right linker options with the libraries after the files
needing them.

> 
> This sucks in all the libraries I need for the gtk widgets and events.
>  I've now added
> 
> #include <openssl/md5.h>
> 
> to the code since I need to compute a MD5 hash.   When I do I get hit
> by
> 
> /tmp/ccMdgAXK.o: In function `callback':
> sv.c:(.text+0x1c4): undefined reference to `MD5_Init'
> collect2: ld returned 1 exit status
> 
> How to I keep pkg-config linking the libraries I need for the gtk but
> add the library for the openssl code?

Add several pairs of back-quotes each calling pkg-config once within.
And call those commands in backquotes by hand to see their effect.

Not all libraries are supported by pkg-config. If those libraries and
their header files are installed in default locations with default
names, pkg-config might be of no much use. Consult the documentation of
the libraries you use. In the case of openssl only linker options
should suffice, all in default paths "-lssl -lcrypto -ldl -lz". Run ldd
on the .so files to see their dependencies.

In the end it could be like the following.

CFLAGS=`pkg-config --cflags gtk+-2.0` `pkg-config --cflags openssl`
LDOPTIONS=`pkg-config --libs openssl` `pkg-config --libs gtk+-2.0`

gcc $CFLAGS -c sv.c
gcc sv.o $LDOPTIONS -o sv

Perhaps you'd better start using some build system like automake, cmake,
cook or whatever. They often provide easier ways to get this stuff done
much more portable. Using Makefiles themselves might be helpful in the
beginning. They all have some learning curve and lots of docs to read.

Bernd Strieder



reply via email to

[Prev in Thread] Current Thread [Next in Thread]