Binary installers for Coin3d and SoQt on MinGW: Difference between revisions

From ASCEND
Jump to navigation Jump to search
Restored page from Google Cache, uploaded by John Pye
 
Restored page from Google Cache, uploaded by John Pye *** existing text overwritten ***
Line 10: Line 10:




<src lang="a4c">//SoQt example
<source lang="a4c">//SoQt example


#include &lt;Inventor/Qt/SoQt.h&gt;
#include &lt;Inventor/Qt/SoQt.h&gt;
Line 40: Line 40:


   return 0;
   return 0;
  }</src>
  }</source>


This may be compiled using the following commands, using the [http://www.mingw.org/msys.shtml MSYS] command-line:
This may be compiled using the following commands, using the [http://www.mingw.org/msys.shtml MSYS] command-line:


<src lang="a4c">export QTDIR=/c/Qt/4.3.3
<source lang="a4c">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
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 \
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 \
Line 52: Line 52:
-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 \
-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</src>
-lSoQt -lQtOpenGL4 -lQtGui4 -lQtCore4 -lQt3Support4 -lCoin -lopengl32 -lgdi32 -lwinmm -luser32</source>


Note that it '''should''' be possible to do the above using just <tt>g++ soqtexample.cpp `soqt-config --libs --cppflags --ldflags`</tt>, however a problem with the presence of spaces in the output from the soqt-config script causes problems.
Note that it '''should''' be possible to do the above using just <tt>g++ soqtexample.cpp `soqt-config --libs --cppflags --ldflags`</tt>, however a problem with the presence of spaces in the output from the soqt-config script causes problems.
Line 65: Line 65:
Here is a minimal build script that allows the above program to be build on both Windows and Linux using the [http://www.scons.org/ Scons] build tool. Note that on Linux, we can make use of the 'soqt-config' script to detect compile-time settings for this library.
Here is a minimal build script that allows the above program to be build on both Windows and Linux using the [http://www.scons.org/ Scons] build tool. Note that on Linux, we can make use of the 'soqt-config' script to detect compile-time settings for this library.


<src lang="a4c">import platform
<source lang="a4c">import platform
if platform.system()==&quot;Windows&quot;:
if platform.system()==&quot;Windows&quot;:


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


env.Program('soqtexample',['soqtexample.cpp'])</src>
env.Program('soqtexample',['soqtexample.cpp'])</source>


== SCons 'tool' for detecting SoQt/Coin ==
== SCons 'tool' for detecting SoQt/Coin ==
Line 101: Line 101:
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.
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.


<src lang="a4c">import os, platform
<source lang="a4c">import os, platform
from SCons.Script import *
from SCons.Script import *


Line 192: Line 192:


return True
return True
return False</src>
return False</source>


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


<src lang="a4c">ctools=['default']
<source lang="a4c">ctools=['default']
if platform.system()==&quot;Windows&quot;:
if platform.system()==&quot;Windows&quot;:


Line 217: Line 217:
)
)


env.Program('mysoqtapp',['mysoqtapp.cpp'])</src>
env.Program('mysoqtapp',['mysoqtapp.cpp'])</source>




Line 223: Line 223:
  [[Category:Miscellany]]
  [[Category:Miscellany]]
[[Category:MinGW]]
[[Category:MinGW]]
PAGEENDslkfjsldkfjskldfjskljfsghwuewrweorswnmbrwewemwr

Revision as of 13:25, 13 May 2010

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'])