[comp.windows.x] SunView and XView code possible in same process?

scott@talarian.UUCP (Scott Weitzenkamp) (01/09/91)

  I am trying to write a program that has both a SunView and XView
user interface compiled into the *same* program.  This is on a
SPARCstation 1 with SunOS 4.0.3c and OpenWindows 2.0.  My main program
looks something like this:

main()
{
  if (getenv("DISPLAY")) {
    do_xview_stuff();
  } /* if */
  else {
    do_sunview_stuff();
  } /* else */
} /* main */

  The function do_xview_stuff calls XView functions (xv_create, etc),
and do_sunview_stuff calls SunView functions (window_create, etc).  The
problem is when I try to link and run this program.  

  I tried the following libraries first: 

-lxview -lolgx -lX11 -lsuntool -lsunwindow -lpixrect

  This gave me an executable where the XView UI worked, but the SunView
one just hung.  I also tried the following link order.

-lsuntool -lsunwindow -lpixrect -lxview -lolgx -lX11 

  This caused the SunView interface to work, but the XView interface
bombs with "SunDefaults Error" messages.  Looking at libxview.a with
nm, I see that libxview.a has a window_create function.  While I guess
I should not be too surprised, I am disappointed.  Now I have to
create two different executables, which IMHO is a waste of disk space.
  
  I guess I could also compile my own XView library that had
window_create (and the other SunView functions) renamed, but this is
rather unattractive.  Yet another alternative is to scrap the XView
interface, and use Motif instead :-).

  Can anyone out there think of any way to get a SunView and XView interface
in the same executable?
-- 
Thanks in advance...
Scott Weitzenkamp, Talarian Corporation, Mountain View, CA
uunet!talarian!scott             (415) 965-8050
"Welcome to the late show, starring NULL and void" -- Men At Work

jcb@frisbee.Eng.Sun.COM (Jim Becker) (01/10/91)

scott@talarian.UUCP (Scott Weitzenkamp) writes:

    Can anyone out there think of any way to get a SunView  and  XView
    interface in the same executable?


An  interesting  proposition,  for sure. One thing that you might have
problems with is global variables that are shared between both SunView
and  XView.  Although  I don't know for a fact there will be problems,
since XView is effectively the next generation of  SunView  (from  the
same source base way back when) there are potential conflicts in terms
of global data being of the same names between the two.

We cleaned up and changed many of the names within  XView,  but  there
could be something in there that would bite you.

My recommendation is to replace your main code  with  either  a  shell
script that starts up the correct program or a true program that forks
the  correct  child.  This  would  always work correctly, and not have
builtin headaches.


-Jim Becker
 XView Group


--
--    
	 Jim Becker / jcb%frisbee@sun.com  / Sun Microsystems