Building C Examples

84 views
Skip to first unread message

pmog...@gmail.com

unread,
Oct 1, 2015, 7:53:26 PM10/1/15
to GLG Toolkit Community Edition
I am trying to build the animation C example, based on the makefile given in src.  Still can't seem to find the right combination of libraries and source code to make it go on a Raspberry Pi, Raspian Linux.  I either get Motif errors, or X-window opening errors (Bad Window).  I installed Lesstif2, but it seems to want Motif, which apparently I have to compile from source code.  Baffled at this point by all of the options given in the documentation.

glg_support

unread,
Oct 2, 2015, 2:07:43 PM10/2/15
to GLG Toolkit Community Edition
GLG libraries are built with OpenMotif libraries, so a GLG program should use Motif libraries as well, since Lesstif libraries are not completely binary compatible with OpenMotif. Motif libraries, both static and dynamic, are provided in the glg/lib directory in case if the OpenMotif package is not available in the system's distribution.

Sample GLG makefile may be found in the glg/src/makefile, please use this file to build GLG examples, and modify it to set GLG_DIR to correspond to your GLG installation directory. The makefile will use Motif libraries from the <GLG_DIR>/lib directory.

By default, the dynamic Motif library will be used for linking. If lesstif is installed on the system, the executable may pick up the lesstif's dynamic library from the system directory at run time, causing errors. In this case, the LD_LIBRARY_PATH environment variable may be used to refer to the different directory to search for the matching Motif library at run time.

Alternatively, the makefile can be modified to link with the static Motif library provided in <GLG_DIR>/lib/libXm.a,
in which case LD_LIBRARY_PATH will not be needed.



pmog...@gmail.com

unread,
Oct 4, 2015, 6:35:36 PM10/4/15
to GLG Toolkit Community Edition
I am  still stuck.  If I build for example, GlgAnimationG with the  -lglg_x11 and -ldl linker options, I produce an executable which pops up a blank unnamed window when run from the terminal.  If I try the same build with GlgAnimationX, it gives me a BadWindow error, and no window.  If I don't use the -ldl dynamic linking option, then it gives me a libc2.4 symbol error.  The same result is seen with both the animation and the process control demo, so it is something I am doing generically wrong with the build.  The demos in the DEMO directory work ok, so it is a build issue on my part.  It would be helpful if I got just a simple compile and link line without all of the options listed in the sample makefile.  Since what I am doing actually builds and executable in at least one case, I must be close.

I have tried this on both a Raspberry Pi B+, and a Model 2, working with the common image from the Spring that has had the normal upgrade/update.  The B+ did not have Lesstif installed, so that is not the issue.

pmog...@gmail.com

unread,
Oct 5, 2015, 11:37:20 AM10/5/15
to GLG Toolkit Community Edition
Are you guys cross-compiling your demos and then porting them to the RPi, or have you actually tried building them using a B+ or a Model 2 with a recent Raspian Image?

The GLG Toolkit looks great, but so far I have not got any replies on RPi forums from anyone using it, even though it is a Pi Store download.  If others are having my issues I think it will have limited appeal.  I am a teacher at a College, and am using the RPi with my computer technology students in several courses.  I would love to introduce them to a tool like this, but I have to be able to build it and use the tools on the RPi.

I guarantee that if I can get it going, that I will publish a how-to article on this to the RPi user population.

Paul Moggach,
Professor
School of Applied Technology
Humber College
Toronto, Ontario
Canada

glg_support

unread,
Oct 5, 2015, 9:05:29 PM10/5/15
to GLG Toolkit Community Edition
If you use a makefile to build any of the examples, it will generate an output in the terminal window with the compile/link command.  A sample compile/link line is also included below.

 -lglg library should be used as opposed to -lglg_x11, and the BadWindow error you are receiving is related to incorrect use of the -lglg_x11 library.

-lglg_x11 is used only for applications such as Qt or GTK where a top level window is created using native Qt/GTK calls, and  a GlgWrapper widget  is added as  a child to a native container.

However, the GLG examples located in the examples_c_cpp directory use a cross platform GLG Generic API where a top level window is created by GLG in a cross platform way. These examples should be linked with -lglg library, not -lglg_x11.

Sample compile/link commands to build GlgAnimationG.c example if you don't want to use the sample makefile:

gcc -c -g -I/usr/local/glg/include   GlgAnimationG.c  -o GlgAnimationG.o
gcc -g -L/usr/local/glg/lib  -L. -o GlgAnimationG GlgAnimationG.o -lglg -lglg_map_stub -lXm -lXt -lX11 -lz -ltiff -ljpeg -lpng -lfreetype -lm -ldl -lpthread

In the above command, you can use /usr/local/glg/lib/libXm.a to link with the static Motif library provided in the GLG directory.

GLG library, as well as GLG demos were built natively on Raspberry Pi, they were not cross-compiled. They are compatible with all Raspberry Pi Models.

glg_support

unread,
Oct 5, 2015, 9:06:27 PM10/5/15
to GLG Toolkit Community Edition
Please refer to reply to the previous posting for linking instructions.  The GLG library, as well as GLG demos were built natively on Raspberry Pi, they were not cross-compiled. They are compatible with all RPi Models.

pmog...@gmail.com

unread,
Oct 6, 2015, 11:36:25 AM10/6/15
to GLG Toolkit Community Edition
Here is my makefile, and the errors I get on linking.  This has been my issue all along,  and I don't seem to be able to pick up the static Motif library and/or get the options right to use it, if it is the solution to these errors.
 
Paul Moggach
makefile
myerror.txt

glg_support

unread,
Oct 6, 2015, 1:05:30 PM10/6/15
to GLG Toolkit Community Edition
Please use the following line to link the GlgAnimationG example with a static Motif library:

gcc -L/usr/local/glg/lib  -L. -o demo GlgAnimationG.o  \
     -lglg_int -lglg -lglg_map_stub \
     -lXm -lXt -lX11 -lXmu -lXft -lXext -lXp  \
     -lz -ljpeg -lpng -lfreetype -lm -ldl -lpthread

It includes additional libraries necessary to link Motif library statically:
-lXmu -lXft -lXext -lXp

pmog...@gmail.com

unread,
Oct 6, 2015, 9:38:32 PM10/6/15
to GLG Toolkit Community Edition
I tried your example, and first it could not find the Xmu lib.  I then did a sudo apt-get install libxmu-dev and then I re-ran the makefile with the attached result.  Some sort of reference to FCPatternAddInteger still not resolved.
myerrorb.txt

glg_support

unread,
Oct 7, 2015, 10:51:54 AM10/7/15
to GLG Toolkit Community Edition
The output from the link command indicates that libfontconfig.so is missing, so you need to -lfontconfig to link line. Due to some differences in system libs, we didn't need it on our Raspberry Pi system (some other dynamic library brought it in).

Please use the following link command:

gcc -L/usr/local/glg/lib  -L. -o demo GlgAnimationG.o -lglg_int -lglg -lglg_map_stub -lXm -lXt -lX11 -lXmu -lXft -lXext -lXp  -lz -ljpeg -lpng -lfreetype -lfontconfig -lm -ldl -lpthread

pmog...@gmail.com

unread,
Oct 7, 2015, 2:37:55 PM10/7/15
to GLG Toolkit Community Edition
Success!  Thank you.  Just so you know, I started again with a fresh install of my Model 2 with the latest NOOBS system.  I then installed Glg with files downloaded directly from your website, as the PiStore is dysfunctional.  With the stock Raspian I had to further install:  libxmu-dev, libx11-dev, libxpm-dev, xorg-dev, Libjpeg-dev, LibXp-dev, which are not on the current image.  At least that's as far as my notes indicate, as I iteratively did builds and added the missing pieces one at a time, and it was a long session.  I think I have the details straight.

Paul Moggach
Reply all
Reply to author
Forward
0 new messages