Binary installers for Coin3d and SoQt on MinGW

From ASCEND
Revision as of 13:25, 13 May 2010 by UploadBot (talk | contribs) (Restored page from Google Cache, uploaded by John Pye *** existing text overwritten ***)
Jump to navigation Jump to search

Here are some binary installers for Coin (aka Coin3d) and SoQt for use with the MinGW GCC 3.4.5 compiler. In order to use these, you will first need to install the open source version of Qt 4.3.3:

  • <a href="/images/a/af/Coin3d-2.5.0.exe" class="internal" title="Coin3d-2.5.0.exe">coin3d-2.5.0.exe</a> (6M binary installer)
  • <a href="/images/b/bd/Soqt-1.4.1.exe" class="internal" title="Soqt-1.4.1.exe">soqt-1.4.1.exe</a> (1.4M binary installer)

These installers were created with NSIS. I can provide the installer scripts to anyone who's interested.

Using SoQt with MinGW

To demonstrate the use of the above binaries, you can compile the following simple example:


//SoQt example

#include &lt;Inventor/Qt/SoQt.h&gt;
#include &lt;Inventor/Qt/viewers/SoQtExaminerViewer.h&gt;
#include &lt;Inventor/nodes/SoCube.h&gt;

 int

 main(int argc, char **argv)
 {

   // Initialize SoQt and Open Inventor libraries. This returns a main
   // window to use.
   QWidget * mainwin = SoQt::init(argv[0]);

    // Make a dead simple scene graph, only containing a single cube.
   SoCube * cube = new SoCube;

   // Use one of the convenient viewer classes.
   SoQtExaminerViewer * eviewer = new SoQtExaminerViewer(mainwin);

   eviewer-&gt;setSceneGraph(cube);
   eviewer-&gt;setTitle(&quot;SoQt example&quot;);

   eviewer-&gt;show();

   SoQt::show(mainwin);
   SoQt::mainLoop();

   return 0;
 }

This may be compiled using the following commands, using the MSYS command-line:

export QTDIR=/c/Qt/4.3.3
export PATH=$PATH/c/PROGRA~1/Coin-2.5.0/bin:/c/Program Files/SoQt-1.4.1/bin:/c/Qt/4.3.3/bin
g++ soqtexample.cpp -I/c/Progra~1/SoQt-1.4.1/include -DSOQT_DLL -DCOIN_DLL -I/c/PROGRA~1/Coin-2.5.0/include \

-I/c/PROGRA~1/Coin-2.5.0/include/Inventor/annex -I/c/Qt/4.3.3//include -I/c/Qt/4.3.3//include/Qt -DSOQT_DLL \

-L/c/Progra~1/SoQt-1.4.1/bin -L/c/PROGRA~1/Coin-2.5.0/bin -L/c/Qt/4.3.3/bin \

-lSoQt -lQtOpenGL4 -lQtGui4 -lQtCore4 -lQt3Support4 -lCoin -lopengl32 -lgdi32 -lwinmm -luser32

Note that it should be possible to do the above using just g++ soqtexample.cpp `soqt-config --libs --cppflags --ldflags`, however a problem with the presence of spaces in the output from the soqt-config script causes problems.

You can then run the resulting ./a.exe program, which will appear as shown below.


Cross-platform build script

Here is a minimal build script that allows the above program to be build on both Windows and Linux using the Scons build tool. Note that on Linux, we can make use of the 'soqt-config' script to detect compile-time settings for this library.

import platform
if platform.system()==&quot;Windows&quot;:

	t=['mingw']
else:
	t=['default']

env = Environment(tools=t)

if platform.system()==&quot;Windows&quot;:
	env.Append(
		LIBS = ['SoQt','Coin']

		,CPPPATH = ['c:/Qt/4.3.3/include'
			,'c:/Qt/4.3.3/include/Qt'
			,'c:/PROGRA~1/Coin-2.5.0/include'
			,'c:/PROGRA~1/SoQt-1.4.1/include'

			,'c:/PROGRA~1/Coin-2.5.0/include/Inventor/annex'
		]
		,LIBPATH = ['c:/PROGRA~1/SoQt-1.4.1/lib','c:/PROGRA~1/Coin-2.5.0/lib'
			,'c:/Qt/4.3.3/lib'

		]
		,CPPDEFINES = ['COIN_DLL','SOQT_DLL']
	)
else:

	env.ParseConfig(['soqt-config --cppflags --ldflags --libs'])

env.Program('soqtexample',['soqtexample.cpp'])

SCons 'tool' for detecting SoQt/Coin

The following rather more rigorous detection script works on Windows with the above MinGW binaries for SoQt/Coin3D as well as on Linux. Note that on Windows, it will happily detect if you installed SoQt or Coin3D in non-standard locations by using the Windows registry, but that it is hard-wired for the c:\Qt\4.3.3 folder in the case of Qt.

import os, platform
from SCons.Script import *

def generate(env):
	&quot;&quot;&quot;
	Detect SOQT settings and add them to the environment.
	&quot;&quot;&quot;
	try:

		if platform.system()==&quot;Windows&quot;:
			import _winreg
			x=_winreg.ConnectRegistry(None,_winreg.HKEY_LOCAL_MACHINE)

			y= _winreg.OpenKey(x,r&quot;SOFTWARE\soqt&quot;)
			LIB,t = _winreg.QueryValueEx(y,&quot;INSTALL_LIB&quot;)

			BIN,t = _winreg.QueryValueEx(y,&quot;INSTALL_BIN&quot;)
			INCLUDE,t = _winreg.QueryValueEx(y,&quot;INSTALL_INCLUDE&quot;)

			env['SOQT_CPPPATH'] = [INCLUDE]
			env['SOQT_LIBPATH'] = [LIB]

			env['SOQT_LIBS'] = ['SoQt']
			env['SOQT_CPPDEFINES'] = ['SOQT_DLL']

			x=_winreg.ConnectRegistry(None,_winreg.HKEY_LOCAL_MACHINE)
			y= _winreg.OpenKey(x,r&quot;SOFTWARE\coin3d&quot;)

			LIB,t = _winreg.QueryValueEx(y,&quot;INSTALL_LIB&quot;)
			BIN,t = _winreg.QueryValueEx(y,&quot;INSTALL_BIN&quot;)

			INCLUDE,t = _winreg.QueryValueEx(y,&quot;INSTALL_INCLUDE&quot;)

			env.AppendUnique(

				SOQT_CPPPATH = [INCLUDE]
				,SOQT_LIBPATH = [LIB]
				,SOQT_LIBS = ['Coin']

				,SOQT_CPPDEFINES = ['COIN_DLL']
			)

			env.AppendUnique(

				QT_PREFIX = r'c:/Qt/4.3.3'
				,SOQT_CPPPATH = [&quot;$QT_PREFIX/include&quot;,&quot;$QT_PREFIX/include/Qt&quot;]
				,SOQT_LIBPATH = [&quot;$QT_PREFIX/lib&quot;]

			)

		else:
			cmd = ['soqt-config','--cppflags','--ldflags','--libs']

			env1 = env.Copy()
			env1.ParseConfig(cmd)

			env['SOQT_CPPPATH'] = env1.get('CPPPATH')
			env['SOQT_LIBPATH'] = env1.get('LIBPATH')

			env['SOQT_LIBS'] = env1.get('LIBS')

		print &quot;SOQT_LIBS =&quot;,env.get('SOQT_LIBS')

		print &quot;SOQT_LIBPATH =&quot;,env.get('SOQT_LIBPATH')
		print &quot;SOQT_CPPPATH =&quot;,env.get('SOQT_CPPPATH')

	except:
		print &quot;FAILED TO SET UP SOQT&quot;
		pass

def exists(env):

	&quot;&quot;&quot;
	Make sure this tool exists.
	&quot;&quot;&quot;
	if platform.system()==&quot;Windows&quot;:

		try:
			import _winreg
			x=_winreg.ConnectRegistry(None,_winreg.HKEY_LOCAL_MACHINE)

			y= _winreg.OpenKey(x,r&quot;SOFTWARE\soqt&quot;)
			INCLUDE,t = _winreg.QueryValueEx(y,'INSTALL_INCLUDE')

			return True
		except:
			return False
	else:
		if env.Which('soqt-config'):

			return True
		return False

Here is an example of how to use the 'soqt.py' tool with SCons to build a simple SoQt app:

ctools=['default']
if platform.system()==&quot;Windows&quot;:

	ctools=['mingw']

env = Environment(
	, toolpath=['.']

	, tools=ctools+['soqt']
)

env.AppendUnique(

	LIBS = env.get('SOQT_LIBS')
	,CPPPATH = env.get('SOQT_CPPPATH')

	,LIBPATH = env.get('SOQT_LIBPATH')
	,CPPDEFINES = env.get('SOQT_CPPDEFINES')

)

env.Program('mysoqtapp',['mysoqtapp.cpp'])