[osg-users] MinGW and OpenSceneGraph

50 views
Skip to first unread message

Laurence Muller

unread,
Jan 11, 2010, 4:46:33 PM1/11/10
to osg-...@lists.openscenegraph.org
Hi all,

unfortunately the OSG server seems to be down, so hopefully I'm posting this on the right mailing list...

For my projects I'm using OpenSceneGraph with great pleasure. Recently I had to switch from Visual Studio (VS) to MinGW because of some incompatible libraries.
Compiling OpenSceneGraph in MSYS/MinGW is a bit less trivial compared to VS.
Since there isn't a lot of information online available (this page seem to be a bit outdated: http://www.openscenegraph.org/projects/osg/wiki/Support/PlatformSpecifics/Mingw) I created a brief tutorial (based on trial and error) to help fellow OSG users.

It should work for the stable release (2.8.x) and the development release (2.9.x):
http://www.multigesture.net/articles/how-to-compile-openscenegraph-2-x-using-mingw/
Stable and Development binaries can also be found on the page.

While creating this tutorial I found some minor issues (In the tutorial I explain how to patch it):
(1) osgPlugin: jpeg
Problem: boolean is not defined
Solution:
- Open C:\OpenSceneGraphSrc\OpenSceneGraph-2.8.2\src\osgPlugins\jpeg\ReaderWriterJPEG.cpp
- Goto line 78 and add:
/* Expanded data source object for stdio input */
typedef int boolean;
#define FALSE 0
#define TRUE 1

(2) osgPlugin: freetype
Problem: It can't find the freetype header files
Solution:
- In MinGW you will need to use freetype2/ instead of freetype/ as directory
- Open C:\OpenSceneGraph\OpenSceneGraph-2.8.2\src\osgPlugins\freetype\FreeTypeFont3D.cpp
- Change lines 32 and 33:
#include <freetype/ftoutln.h>
#include <freetype/ftbbox.h>
 to
#include <freetype2/ftoutln.h>
#include <freetype2/ftbbox.h>

(3) osgPlugin: curl
Including libcurl (include / lib) doesn't seem to be enough to build this project and will result in linking errors. It probably needs to link against libws2_32.a and libwinmm.a . I know how to link using a Makefile, but I got no clue on how to fix it in the CMake files...


Hopefully this helps other users as well :)

Kind Regards,
- Laurence Muller

Jean-Sébastien Guay

unread,
Jan 11, 2010, 7:35:43 PM1/11/10
to OpenSceneGraph Users
Hi Laurence,

Thanks for your tutorial, it's always useful to document things so new
users can get up and running as fast as possible.

Thanks also for your explanations for changes to make. Perhaps some can
be made to the baseline so MinGW users won't have to manually patch
things...

About this one:

> (3) osgPlugin: curl
> Including libcurl (include / lib) doesn't seem to be enough to build
> this project and will result in linking errors. It probably needs to
> link against libws2_32.a and libwinmm.a . I know how to link using a
> Makefile, but I got no clue on how to fix it in the CMake files...

libws2_32 was added already for the WIN32 case, if it's not being linked
in it's probably because it's not included in the MINGW case... Search
for that name in the CMakeLists.txt file in the src/osgPlugins/curl
directory, and you should see where it's added. Then search other
plugins for a MinGW specific path and that will tell you what to test
for to know you're on MinGW, and in that case add the library to be
linked against.

That should take care of that case. Once you've made the changes please
submit the modified file to osg-submissions so others will benefit :-)

Thanks,

J-S
--
______________________________________________________
Jean-Sebastien Guay jean-seba...@cm-labs.com
http://www.cm-labs.com/
http://whitestar02.webhop.org/
_______________________________________________
osg-users mailing list
osg-...@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Robert Osfield

unread,
Jan 12, 2010, 4:18:23 AM1/12/10
to OpenSceneGraph Users
Hi Laurence,

Thanks for the writing the tutorial. I'm with Jean-Sebastien in that
the best solution would be to get changes into svn/trunk that make the
OSG build out of the box with the present version of MingGW. Please
note that others before you have been building under MinGW and don't
recall any of them reporting these particular issues so I'd guess that
MinGW has been evolving, or perhaps that didn't attempt to compile the
components you have.

Which version of MinGW are you using? How are you obtaining the
dependencies? What version are the dependencies? Are they different
versions than you were using in VS?

The next step forward would to be get to the bottom of why these
changes are required, and then seek to resolve these external
dependencies or change the OSG's build and source files to fix things
in a way that builds correctly across all targets without
modifications. CMake itself can certainly help us out a lot with
providing paths and link lines for each dependency and target
platform. If we can we should strive to put the differences into the
build system rather than the source files.

Cheers,
Robert.

Jean-Sébastien Guay

unread,
Jan 13, 2010, 1:57:04 AM1/13/10
to OpenSceneGraph Users
Hi Laurence,

I investigated your issues a bit more. Here is what I found:

> (1) osgPlugin: jpeg
> Problem: boolean is not defined

This comes from the fact that the version of the jpeg headers included
in MinGW defines JPEG_boolean (and JPEG_FALSE/JPEG_TRUE) instead of
boolean (and FALSE/TRUE). I think this is a good idea as it avoids
possible name clashes, but in this case it causes problems.

What I find weird is that I looked at both the headers in the Win32 VC8
dependencies package (which is fairly old) and the headers on an
up-to-date Ubuntu install, and both define straight boolean (not
JPEG_boolean as the MinGW header defines). In both cases, the jmorecfg.h
header states:

Copyright (C) 1991-1997, Thomas G. Lane.

The MinGW header states:

Copyright (C) 1991-1997, Thomas G. Lane.
Modified 1997-2009 by Guido Vollbeding.

So it would seem the MinGW header is more recent, or just that it
includes changes that were not integrated into the baseline? That seems
a bit weird to me, that the MinGW header would be more recent than
what's on an up-to-date Ubuntu install...

Anyways, I'll see if I can code up a solution that will allow us to
compile in both cases.

> (2) osgPlugin: freetype
> Problem: It can't find the freetype header files

Actually, you could fix this without any code changes:
1. open an msys prompt
2. cd /mingw/include
3. ln -s freetype2 freetype

That way the include files will be found.

> (3) osgPlugin: curl

As I said, the required libraries are added at
src/osgPlugins/curl/CMakeLists.txt inside an IF(WIN32) which works for
VC++ builds. Seems the Msys build doesn't go into that IF, so I'll look
into adding the proper check (probably "|| MINGW" or something like
that. That should take care of it.

Stay tuned...

J-S
--
______________________________________________________
Jean-Sebastien Guay jean-seba...@cm-labs.com
http://www.cm-labs.com/
http://whitestar02.webhop.org/

Laurence Muller

unread,
Jan 14, 2010, 2:16:11 PM1/14/10
to osg-...@lists.openscenegraph.org
Hi Jean-Sébastien & Robert,

thanks for the feedback!

@Robert:
I've actually written a tutorial that describes how to setup a c/c++ development environment which I'm using to compile OpenSceneGraph. It also includes the version numbers.
http://www.multigesture.net/articles/how-to-install-mingw-msys-and-eclipse-on-windows/

@Jean-S

(1) libjpeg
That's strange, I don't know if mingw32 on ubuntu is using the same files as on windows. I'm currently not using the offical verison of MinGW (latest verison 5.1.6, http://sourceforge.net/projects/mingw/files/) because it is using a GCC compiler version 3.x. Instead I'm using a build from http://nuwen.net/mingw.html#download (currently using 4.3) which is bundled with a more recent GCC compiler (version 4.3.3). The package also includes libjpeg version 7.

(2) freetype
While this indeed solve the issue without modifying the code, it moves the problem to the shell. Since users still need to manually type this fix...

(3) curl
That should probably do the trick, I'll see if I can make it work.

Hopefully I have some more time next week to investigate the possible fixes and submit a patch.

Kind regards,
- Laurence

---

Jean-Sébastien Guay

unread,
Jan 14, 2010, 2:38:21 PM1/14/10
to OpenSceneGraph Users
Hi Laurence,

> @Jean-S
>
> (1) libjpeg
> That's strange, I don't know if mingw32 on ubuntu is using the same
> files as on windows. I'm currently not using the offical verison of
> MinGW (latest verison 5.1.6,
> http://sourceforge.net/projects/mingw/files/) because it is using a GCC
> compiler version 3.x. Instead I'm using a build from
> http://nuwen.net/mingw.html#download (currently using 4.3) which is
> bundled with a more recent GCC compiler (version 4.3.3). The package
> also includes libjpeg version 7.

Yes, and I'm using the same installer to test with. I actually started
with your tutorial on installing MinGW and MSYS, and then customized a
few things. :-)

> (2) freetype
> While this indeed solve the issue without modifying the code, it moves
> the problem to the shell. Since users still need to manually type this
> fix...

But I think it's better to make the code general and let links handle
the difference than the opposite. Else the code becomes a spaghetti of
#if(MINGW) #elsif(...) ...

A symlink is a simple and clean way to make your system's directory
structure look more standard. Since thousands of developers actively use
OSG on various flavors of Linux, and it uses <freetype/...>, I think
making MinGW follow this (even if by default it puts the headers in
<freetype2/...>) is a more general solution.

> (3) curl
> That should probably do the trick, I'll see if I can make it work.

I've actually fixed the problem in my local checkout at home, but I had
a few more tests to do yesterday and it was late so I opted to go sleep
and send the fixes tomorrow (today). So I will hopefully send the fixes
I needed to use to build OSG on MinGW/MSYS tonight. I had a few more
fixes to make than what you said, but perhaps they're in things you
didn't opt to compile, like osgmovie, osgviewerSDL, the TXP plugin, ...

Stay tuned,

J-S
--
______________________________________________________
Jean-Sebastien Guay jean-seba...@cm-labs.com
http://www.cm-labs.com/
http://whitestar02.webhop.org/

Jean-Sébastien Guay

unread,
Jan 14, 2010, 10:45:53 PM1/14/10
to OpenSceneGraph Users
Hi Laurence,

> While creating this tutorial I found some minor issues (In the tutorial
> I explain how to patch it):

I have just sent the fixes I could come up with to osg-submissions. You
can look at the message here:

http://thread.gmane.org/gmane.comp.graphics.openscenegraph.cvs/6738

You can also download the zip with the modified source files. If you
want to try, please download it and copy the unzipped directory
structure over a fresh SVN checkout of the OSG source and see if you
have less problems.

For now though I have opted to keep the solution I gave for the freetype
plugin, i.e.

cd /mingw/include
ln -s freetype2 freetype

We'll see what Robert says about that, but I personally think it's
better to have a standard path, and if one type of system has a
different path then use symlinks to make it conform to the standard.

Other than that, I had more issues than you apparently had, but I hope
most if not all of them are fixed by my changes. I tested what I could
and almost everything worked as it should (sound in osgmovie and the Qt
examples being the only exceptions).

Hope this helps,

Laurence Muller

unread,
Jan 22, 2010, 5:14:49 PM1/22/10
to osg-...@lists.openscenegraph.org
Hi Jean-Sebastien,

I checked your comments from this thread http://thread.gmane.org/gmane.comp.graphics.openscenegraph.cvs/6738 and decided to try it out. I noticed that some of the fixes were submitted to the SVN trunk, so first thing I did was a checkout of http://www.openscenegraph.org/svn/osg/OpenSceneGraph/trunk (rev 10983)

Below an overview of my settings (just in case somebody wants to confirm the results)


Compiler
========
MinGW (Nuwen 5.0)
http://nuwen.net/files/mingw/mingw-5.0.zip

$ g++ --version
g++.exe (GCC) 4.4.1-nuwen
Copyright (C) 2009 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

3rd Party Dependencies
======================

(1) Libtiff (3.4-1)
Download: http://sourceforge.net/projects/mingwrep/files/libtiff-devel/3.4-1/libtiff-devel-3.4-1.zip/download

(2) Libxml2 (2.7.6)
Download: http://xmlsoft.org/sources/win32/libxml2-2.7.6.win32.zip

(3) Curl (7.17.1)
Download: http://curl.haxx.se/latest.cgi?curl=win32-devel

(4) FFmpeg (not official, precompiled mingw binary)
http://mingw-w64-dgn.googlecode.com/files/ffmpeg-w32-bin-i686-20100108.7z

(5) Qt libraries 4.6.1 for Windows (minGW 4.4, 277 MB)
Download: http://qt.nokia.com/downloads/windows-cpp
Install: just run the setup and use the default location (C:\Qt\4.6.1)

OpenSceneGraph-SVN-r10983-3rdParty.7z  (this package includes everything above except the Qt SDK)
http://www.multigesture.net/wp-content/plugins/download-monitor/download.php?id=28


CMAKE
=====
Where is the source code: C:/OpenSceneGraphSrc/OpenSceneGraphSVN
Where to build the binaries: C:/OpenSceneGraphBuild/OpenSceneGraph-SVN

ACTUAL_3DPARTY_DIR: C:/MinGW
CMAKE_BUILD_TYPE: Release
CMAKE_INSTALL_PREFIX: C:/OpenSceneGraph/OpenSceneGraph-SVN

FFMPEG_ROOT: C:/OpenSceneGraphSrc/3rdParty/ffmpeg (after hitting configure it will find all files automatically)

SDL_INCLUDE_DIR: C:/MinGW/include/SDL
SDL_LIBRARY: C:/MinGW/lib/libSDL.a
SDLMAIN:_LIBRARY: C:/MinGW/lib/libSDLmain.a

CURL_INCLUDE_DIR: C:/OpenSceneGraphSrc/3rdParty/libcurl-7.17.1/include
CURL_LIBRARY: C:/OpenSceneGraphSrc/3rdParty/libcurl-7.17.1/lib/libcurl.a

TIFF_INCLUDE_DIR: C:/OpenSceneGraphSrc/3rdParty/libtiff-devel-3.4-1/include
TIFF_LIBRARY: C:/OpenSceneGraphSrc/3rdParty/libtiff-devel-3.4-1/lib/libtiff.a

LIBXML2_INCLUDE_DIR: C:/OpenSceneGraphSrc/3rdParty/libxml2-2.7.6.win32/include
LIBXML2_LIBRARIES: C:/OpenSceneGraphSrc/3rdParty/libxml2-2.7.6.win32/lib/libxml2.lib

QT4: This is not so trivial, I don't remember how I got it working. I just filled out a few of the entries with the appropiate values and kept hitting configure. After getting a few messages about Qt3 and Qt4 it found most of the locations automatically.
QT_QT_LIBRARY: Didn't know what to put in here, so I kept it empty.

Building
========

In MSYS (create a symlink as Jean-Sebastien Guay suggests on the OSG mailinglist):
# cd /mingw/include
# ln -s freetype2 freetype

Change to your build directory and build!
# cd /c/C:/OpenSceneGraphBuild/OpenSceneGraph-SVN
# make
# make install


List of issues:
===============

Unlike what Jean-Sebastien Guay reports here http://thread.gmane.org/gmane.comp.graphics.openscenegraph.cvs/6738 I don't have any problems (might already been fixed):
osgviewerQT - no issues
osgviewerQtWidget - no issues

The only application that does not wants to build is osgQtBrowser (error message below)

The fix is simple:
The missing header files should be here: C:\Qt\4.6.1\include\QtCore

Seems like the CMakeList.txt files doesn't include the QTCORE header files.

Patch: C:\OpenSceneGraphSrc\OpenSceneGraphSVN\examples\osgQtBrowser\CMakeLists.txt
from: INCLUDE_DIRECTORIES(${QT_INCLUDE_DIR} )
to: INCLUDE_DIRECTORIES(${QT_INCLUDE_DIR} ${QT_QTCORE_INCLUDE_DIR})

It should now compile just fine.

=====================================================================================================================================================================

[100%] Built target example_osgviewerQtWidget
[100%] Generating moc_QGraphicsViewAdapter.cxx
Scanning dependencies of target example_osgQtBrowser
[100%] Building CXX object examples/osgQtBrowser/CMakeFiles/example_osgQtBrowser
.dir/moc_QGraphicsViewAdapter.obj
In file included from c:/Qt/4.6.1/include/QtWebKit/qwebelement.h:1,
                 from c:/Qt/4.6.1/include/QtWebKit/QtWebKit:7,
                 from C:/OpenSceneGraphSrc/OpenSceneGraphSVN/examples/osgQtBrowser/QGraphicsViewAdapter.h:21,
                 from c:/OpenSceneGraphBuild/OpenSceneGraph-SVN/examples/osgQtBrowser/moc_QGraphicsViewAdapter.cxx:10:
c:/Qt/4.6.1/include/QtWebKit/../../src/3rdparty/webkit/WebCore/../WebKit/qt/Api/qwebelement.h:23:19: error: QString: No such file or directory
c:/Qt/4.6.1/include/QtWebKit/../../src/3rdparty/webkit/WebCore/../WebKit/qt/Api/qwebelement.h:24:23: error: QStringList: No such file or directory
c:/Qt/4.6.1/include/QtWebKit/../../src/3rdparty/webkit/WebCore/../WebKit/qt/Api/qwebelement.h:25:17: error: QRect: No such file or directory
c:/Qt/4.6.1/include/QtWebKit/../../src/3rdparty/webkit/WebCore/../WebKit/qt/Api/qwebelement.h:26:20: error: QVariant: No such file or directory
c:/Qt/4.6.1/include/QtWebKit/../../src/3rdparty/webkit/WebCore/../WebKit/qt/Api/qwebelement.h:27:40: error: QExplicitlySharedDataPointer: No such file or directory

In file included from c:/Qt/4.6.1/include/QtWebKit/qwebkitversion.h:1,
                 from c:/Qt/4.6.1/include/QtWebKit/QtWebKit:13,
                 from C:/OpenSceneGraphSrc/OpenSceneGraphSVN/examples/osgQtBrowser/QGraphicsViewAdapter.h:21,
                 from c:/OpenSceneGraphBuild/OpenSceneGraph-SVN/examples/osgQtBrowser/moc_QGraphicsViewAdapter.cxx:10:
c:/Qt/4.6.1/include/QtWebKit/../../src/3rdparty/webkit/WebCore/../WebKit/qt/Api/qwebkitversion.h:20:21: error: qstring.h: No such file or directory

In file included from c:/Qt/4.6.1/include/QtWebKit/qwebelement.h:1,
                 from c:/Qt/4.6.1/include/QtWebKit/QtWebKit:7,
                 from C:/OpenSceneGraphSrc/OpenSceneGraphSVN/examples/osgQtBrowser/QGraphicsViewAdapter.h:21,
                 from c:/OpenSceneGraphBuild/OpenSceneGraph-SVN/examples/osgQtBrowser/moc_QGraphicsViewAdapter.cxx:10:
c:/Qt/4.6.1/include/QtWebKit/../../src/3rdparty/webkit/WebCore/../WebKit/qt/Api/qwebelement.h:138: warning: comma at end of enumerator list

make[2]: *** [examples/osgQtBrowser/CMakeFiles/example_osgQtBrowser.dir/moc_QGraphicsViewAdapter.obj] Error 1
make[1]: *** [examples/osgQtBrowser/CMakeFiles/example_osgQtBrowser.dir/all] Error 2
make: *** [all] Error 2

=====================================================================================================================================================================

Summary
=======

It almost compiles out of the box, great job :) ! Only one CMakeList.txt file needs to be patched and perhaps users should be made aware about the symlink (to fix the freetype issue).


I've posted the binaries here (OpenSceneGraph-SVN-r10983-bin-dev.7z):
http://www.multigesture.net/wp-content/plugins/download-monitor/download.php?id=27

This includes the header, lib files and demo applications.


Kind regards,
- Laurence Muller

------------------------------------------
Laurence Muller (M.Sc.)
Fellow @ SDR Lab (IIC/SEAS, Harvard University)
Office: Maxwell Dworkin 136 (33 Oxford Street, Cambridge, MA 02138)
Lab website: http://sdr.seas.harvard.edu/people#laurence_muller

Website/Blog/Portfolio:
http://www.multigesture.net/

Jean-Sébastien Guay

unread,
Jan 22, 2010, 7:43:18 PM1/22/10
to OpenSceneGraph Users
Hello Laurence,

> Below an overview of my settings (just in case somebody wants to confirm
> the results)

Thanks a lot for testing and for reporting your findings!

I'll just comment on one thing:

> (5) Qt libraries 4.6.1 for Windows (minGW 4.4, 277 MB)
> Download: http://qt.nokia.com/downloads/windows-cpp
> Install: just run the setup and use the default location (C:\Qt\4.6.1)

...

> Unlike what Jean-Sebastien Guay reports here
> http://thread.gmane.org/gmane.comp.graphics.openscenegraph.cvs/6738 I
> don't have any problems (might already been fixed):
> osgviewerQT - no issues
> osgviewerQtWidget - no issues

Excellent, note that I had a preinstalled Qt 4.4.3 (because that's the
version we use in our software at work) for Windows / Visual Studio,
which is probably what was picked up by CMake, and that's probably the
reason I had problems. Anyways, I didn't really want to test that many
optional compiles (I had already tested Curl, FFMPEG, etc so I think it
was enough for most uses). ;-)

> The only application that does not wants to build is osgQtBrowser (error
> message below)
>
> The fix is simple:
> The missing header files should be here: C:\Qt\4.6.1\include\QtCore
>
> Seems like the CMakeList.txt files doesn't include the QTCORE header files.
>
> Patch:
> C:\OpenSceneGraphSrc\OpenSceneGraphSVN\examples\osgQtBrowser\CMakeLists.txt
> from: INCLUDE_DIRECTORIES(${QT_INCLUDE_DIR} )
> to: INCLUDE_DIRECTORIES(${QT_INCLUDE_DIR} ${QT_QTCORE_INCLUDE_DIR})
>
> It should now compile just fine.

Please send the whole modified CMakeLists.txt file to osg-submissions.
That's the way to submit fixes to OSG.

> It almost compiles out of the box, great job :) ! Only one CMakeList.txt
> file needs to be patched and perhaps users should be made aware about
> the symlink (to fix the freetype issue).

Yeah, that could be documented (where? Perhaps a message in CMake if
MinGW is detected?)

Thanks again,

J-S
--
______________________________________________________
Jean-Sebastien Guay jean-seba...@cm-labs.com
http://www.cm-labs.com/
http://whitestar02.webhop.org/

Reply all
Reply to author
Forward
0 new messages