Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[XForms] missing X11 library?

3 views
Skip to first unread message

Peter Rowat

unread,
Nov 17, 2015, 8:58:52 PM11/17/15
to xforms-de...@nongnu.org
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


Thanks for any help. I’m on OS X 10.11

Peter R


jon

unread,
Nov 17, 2015, 10:20:26 PM11/17/15
to Development with and of XForms
Last time I compiled on Macos X I used this:

gcc -Wall -I/usr/local/include -I/opt/X11/include -L/usr/local/lib
myfiles.c -l forms -o mybin

Try variations on this theme and see if that helps,
Jon




Jens Thoms Toerring

unread,
Nov 18, 2015, 5:57:11 AM11/18/15
to Development with and of XForms
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 ________ j...@toerring.de
\_______________________________ http://toerring.de

Peter Rowat

unread,
Nov 18, 2015, 2:37:43 PM11/18/15
to Development with and of XForms


gcc -v -Wall -I/usr/local/include -I/opt/X11/include -o XXX XXX.c -L/usr/local/lib -lforms



Hello Jens and Jon,

Thanks for your advice. I’ve tried several different orderings, as you both have suggested, but I still get the same effect:

Using this command, when XXX.c is an XForms program NOT using any Xlib calls, compilation is successful,
but when XXX.c has Xlib calls such as XDrawLines, compilation fails. (I changed my #include “forms.h” to <forms.h>)

Perhaps this is related to the presence of Apple's Xcode app, and I should try the compilation from inside Xcode.

I include below the “-v” output in case anyone can see some relevant info that I can’t.

Peter
=====
gcc -v -Wall -I/usr/local/include -I/opt/X11/include -o trime trime.c -L/usr/local/lib -lforms
Apple LLVM version 7.0.0 (clang-700.1.76)
Target: x86_64-apple-darwin15.0.0
Thread model: posix
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" -cc1 -triple x86_64-apple-macosx10.11.0 -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name trime.c -mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu core2 -target-linker-version 253.6 -v -dwarf-column-info -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/7.0.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -I /usr/local/include -I /opt/X11/include -Wall -fdebug-compilation-dir /Users/prowat/XFormsCode -ferror-limit 19 -fmessage-length 154 -stack-protector 1 -mstackrealign -fblocks -fobjc-runtime=macosx-10.11.0 -fencode-extended-block-signature -fmax-type-align=16 -fdiagnostics-show-option -fcolor-diagnostics -o /
var/folders/vd/_jgw9cc88xj09k001s729p500000gp/T/trime-c64e11.o -x c trime.c
clang -cc1 version 7.0.0 based upon LLVM 3.7.0svn default target x86_64-apple-darwin15.0.0
ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/local/include"
ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/Library/Frameworks"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/opt/X11/include
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/7.0.0/include
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks (framework directory)
End of search list.
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version_min 10.11.0 -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -o trime -L/usr/local/lib /var/folders/vd/_jgw9cc88xj09k001s729p500000gp/T/trime-c64e11.o -lforms -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/7.0.0/lib/darwin/libclang_rt.osx.a

**** FOLLOWING does not appear (obviously) if there are no XLib calls ****

Undefined symbols for architecture x86_64:
"_XDrawLines", referenced from:
_draw_triangle in trime-c64e11.o
"_XFillPolygon", referenced from:
_draw_triangle in trime-c64e11.o
"_XSetForeground", referenced from:
_draw_triangle in trime-c64e11.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [trime] Error 1



> Begin forwarded message:
> \ Jens Thoms Toerring ________ j...@toerring.de <mailto:j...@toerring.de>
> \_______________________________ http://toerring.de <http://toerring.de/>

jon

unread,
Nov 18, 2015, 2:48:18 PM11/18/15
to Development with and of XForms

<snip>
>gcc -v -Wall -I/usr/local/include -I/opt/X11/include -o trime trime.c -L/usr/local/lib -lforms


I don't quite following exactly what you are saying about xlib calls, but assuming you are making any don't you just need this ?

gcc -v -Wall -I/usr/local/include -I/opt/X11/include -o trime trime.c -L/usr/local/lib -lX11 -lforms

or possibly an extra
-L/usr/X11/lib <wherever it is hiding in the apple tree>

Jon




Jens Thoms Toerring

unread,
Nov 18, 2015, 2:49:44 PM11/18/15
to Development with and of XForms
Hi Peter,

On Wed, Nov 18, 2015 at 11:37:20AM -0800, Peter Rowat wrote:
>
> gcc -v -Wall -I/usr/local/include -I/opt/X11/include -o XXX XXX.c -L/usr/local/lib -lforms
>

> Using this command, when XXX.c is an XForms program NOT using any Xlib
> calls, compilation is successful, but when XXX.c has Xlib calls such as
> XDrawLines, compilation fails. (I changed my #include “forms.h” to
> <forms.h>)

> Perhaps this is related to the presence of Apple's Xcode app, and I should
> try the compilation from inside Xcode.

I have no experience at all With Apple and Xcode, so a lot of
the output is incomprehensible to me:-(

> Undefined symbols for architecture x86_64:
> "_XDrawLines", referenced from:
> _draw_triangle in trime-c64e11.o
> "_XFillPolygon", referenced from:
> _draw_triangle in trime-c64e11.o
> "_XSetForeground", referenced from:
> _draw_triangle in trime-c64e11.o
> ld: symbol(s) not found for architecture x86_64
> clang: error: linker command failed with exit code 1 (use -v to see invocation)
> make: *** [trime] Error 1

No idea if this will help, but have you tried to explicitly
link also against libX11? Under Linux it's enough that libforms
depends on it (since a few years, before you also had to add it),
but perhaps that's different on ypur platform. What happens if you
put a '-lX11' after '-lforms' (or before it or maybe have it before
and after it)?
Best regards, Jens
--
\ Jens Thoms Toerring ________ j...@toerring.de
\_______________________________ http://toerring.de

Peter Rowat

unread,
Nov 18, 2015, 4:04:33 PM11/18/15
to Development with and of XForms


Solved: both of these terms, in this order,

-L/opt/X11/lib -lX11

must be present at the end of the gcc command, before or after -lforms.

Thank you both, Jens and Jon, for the help. What trivia.

Peter

Peter Rowat

unread,
Dec 5, 2015, 6:26:42 PM12/5/15
to Development with and of XForms
myprogram: myprogram.c
gcc -I/usr/local/include -I/opt/local/include -o myprogram myprogram.c -L/usr/local/lib -L/opt/local/lib -lX11 -lforms


The previous command I posted invoked an older version of libX11.6.dylib which caused some demo programs to crash.
0 new messages