xforms-development
[Top][All Lists]
Advanced

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

Re: [XForms] missing X11 library?


From: Jens Thoms Toerring
Subject: Re: [XForms] missing X11 library?
Date: Wed, 18 Nov 2015 11:56:56 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

On Tue, Nov 17, 2015 at 05:58:15PM -0800, Peter Rowat wrote:
> I have what must be a trivial problem compiling a simple program:
> 
> I’ve written and compiled a few XForms programs successfully, and now I’m 
> using some X library calls as used, e.g., in the triangle routine in 
> “freedraw.c” demo. 
> However it seems I’m missing a library since I get the following errors:
> This command compiles my programs without the X library calls:
> 
> gcc -g  -I/opt/X11/include -o trime 
> -I/Users/prowat/XFormsCode/xforms-1.2.4/lib -L/opt/X11/lib -L/usr/local/lib 
> -lforms trime.c
> 
> Undefined symbols for architecture x86_64:
>   "_XDrawLines", referenced from:
>       _draw_triangle in trime-f577d6.o
>   "_XFillPolygon", referenced from:
>       _draw_triangle in trime-f577d6.o
>   "_XSetForeground", referenced from:
>       _draw_triangle in trime-f577d6.o
> 

s Jon already wrote I'd also recommend to always have the
libraries at the very end of the compile command - as far
as I know many linkers typically only do a single pass and
only link in from libraries what is at the moment already
is known to be needed. And here the '-forms' bit pulls in
libX11 and you may end up with only functions needed from
libforms getting picked from libX11. And when the linker
then gets to trime.o it has forgotten about everything
from libX11 that wasn't used from anywhere else. An alter-
native might be to explicitely specify '-lX11' after
'trime.c', but simply moving the '-lforms' bit to the
end is probably simpler and more efficient.

BTW, if you have XForms installed - which it looks like from
the '-L/usr/local/lib -lforms' bit - then the forms.h header
file should also be installed in '/usr/local/include'. So
instead of the '-I/Users/prowat/XFormsCode/xforms-1.2.4/lib'
bit you should be able to use '-I/usr/local/include' and
use

#include <forms.h>

in your code - I suspect that you, like it's done in the
demo programs, are using

#include "include/forms.h"

But the demo programs only do that since they must be
compilable in theur location without an installed XForms
library, i.e. before the forms.h header file has been
copied to its final location.

                     Best regards, Jens
-- 
  \   Jens Thoms Toerring  ________      address@hidden
   \_______________________________      http://toerring.de



reply via email to

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