xforms-development
[Top][All Lists]
Advanced

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

[XForms] Fwd: missing X11 library?


From: Peter Rowat
Subject: [XForms] Fwd: missing X11 library?
Date: Wed, 18 Nov 2015 11:37:20 -0800



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:

From: Jens Thoms Toerring <address@hidden>
Date: November 18, 2015 at 2:56:56 AM PST
To: Development with and of XForms <address@hidden>
Subject: Re: [XForms] missing X11 library?

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]