help-gplusplus
[Top][All Lists]
Advanced

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

Problems linking together gtk and openssl on F7 SOLVED


From: Robert Cahn
Subject: Problems linking together gtk and openssl on F7 SOLVED
Date: Thu, 5 Jul 2007 10:39:15 -0400

It turns out that the suggested fix didn't work.  What I finally did was to grab all the dependencies out of the openssl.pc and created the following little script:

gcc sv.c -c `pkg-config --cflags gtk+-2.0`
gcc sv.o -o sv -lssl -lcrypto -L/usr/kerberos/lib -ldl -lz `pkg-config --libs gtk+-2.0`

It now links.

/Bob Cahn

---------- Forwarded message ----------
From: Robert Cahn <robertscahn@gmail.com>
Date: Jul 2, 2007 6:22 PM
Subject: Re: Problems linking together gtk and openssl on F7
To: Bernd Strieder < strieder@informatik.uni-kl.de>

Thanks so much for your response.  I'll see if I can get it to work.

/Bob Cahn


On 7/2/07, Bernd Strieder < strieder@informatik.uni-kl.de> wrote:
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

_______________________________________________
help-gplusplus mailing list
help-gplusplus@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gplusplus


reply via email to

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