Source Compilation
Source compilation is tricky, and requires an in-depth knowledge of both C++ programming and the internals of your computer's software. It is fraught with cryptic peril; you have been warned. If you are not familiar with the concept of source compilation, or software development in general, this procedure may prove very difficult. Some help is available on the forums, but this is a limited and typically slow method of communication.Looking for an easier install? Check to see if your platform is supported. If it is not supported, you can contact the author for other options.
Getting started
This project uses autotools to manage system configuration and program
dependency information, so if you know what that means and you are
running Linux, just do as per normal after installing dependencies
(./configure && make && make install). Due to a missing build environment, building under windows is highly complicated, and more throughly documented below.
Direct Dependencies:
- ftgl
- freetype2
- libxml2
- mathgl
- wxwidgets
- setting up your computer to be able to build, and
- actually building the program.
If there are any problems or flaws with the instructions, please contact the author
Setting up
Either Download the source code, or grab the mercurial respository using this clone command, or by opening the URL in your graphical mercurial client (the URL is the bit at the right)$ hg clone http://threedepict.hg.sourceforge.net:8000/hgroot/threedepict/threedepict
You should then install the following packages (this requires administrative rights to your machine).:
Debian/Ubuntu:
- build-essential
- libwxgtk2.8-dev
- libmgl-dev
- libxml2-dev
- libftgl-dev
$ sudo aptitude install build-essential libwxgtk2.8-dev libmgl-dev libxml2-dev libftgl-dev)
Fedora/RedHat:
- "Development Tools" group package
- mathgl-devel
- libxml2-devel
- ftgl-devel
- wxgtk-devel
$ yum groupinstall "Development Tools"
$ yum install mathgl-devel libxml2-devel ftgl-devel wxgtk-devel
OpenSuse:
- wxGTK-devel
- libxml2-devel
- ftgl-devel
$ zypper install -t devel_C_C++
$ zypper install wxGTK-devel libxml2-devel ftgl-devel
Unfortunately, mathgl is not available as a pre-built package for Suse. You must therefore download and install it manually from the mathgl website:
Mac OS X
Mac OS does not have a proper package management system. You need XCode installed (here). Note that at time of writing the wxWidgets version provided with XCode are several years out of date and cannot be guaranteed function correctly (though it may). There are some post-compile notes, which must be followed to build a usable program.There is an automatic dependency grabbing script in the 3Depict source code under the "deps" folder. Run that (ensure you are connected to the internet) to automatically download, build and install all the software dependencies. If it does not work, this is a bug, so let me know.
To run the script, simply type:
$ ./getDeps
From the getDeps folder after extracting the source code
From Source (All other platforms)
For platforms not listed above (including windows), dependency source compiling is the way to go if you don't have prebuilt versions available. Compiling from source is tricky, can fail due to version mismatch, can break your current computer install, and is only recommended for advanced users with a programming background.You must first install GCC for your platform, and be able to compile a basic "hello world" program. Other compilers might work, but I cannot tell you how to do this. If you don't know what that means, you may need to seek assistance from someone who does. Ask your local computer-y person.
If your platform provides any of the following libraries in an easy to install fashion, use that, but don't forget to install the development components, if you choose this route. Otherwise, just follow the below instructions.
Install the development headers for your platform. Windows needs MinGW/MSYS (unless you know better), some instructions are here, and my notes are below. Otherwise, you are largely on your own. Cygwin is not recommended, as OpenGL may not work in the final program (without X11). Feel free to ask for help.
wxWidgets
- Download the latest wxWidgets source code from http://www.wxwidgets.org/
- Then extract the tarball/zip/whatever
- Compile this with the following console command:
- $ ./configure --with-opengl --enable-unicode
- $ make
- Install (as administrator)
- # make install
LibPNG
- Download the latest libPNG (Unless running mac) http://www.libpng.org/pub/png/libpng.html
- Copy the correct makefile to the base directory
- Mac OSX : move scripts/makefile.darwin to the libpng dir, and rename it makefile
- Windows: Not sure. I had to do a lot of fiddling to get this to work. Essentially I pulled a makefile from the msysPORT code, and then converted it from patch format to a usable makefile. I suggest looking on the interwebs for instructions.
- Other platforms: move scripts/makefile.gcc to the libpng dir and rename it makefile
- Compile it with $ make
- Install it with # make install
Freetype
- Download the latest freetype source code: http://www.freetype.org/
- Compile with
- $ ./configure
- $ make
- Install (as administrator)
- # make install
FTGL
- Download the latest FTGL source code from http://sourceforge.net/projects/ftgl/
- Compile with
- $ ./configure
- $ make
- Install (as administrator)
- # make install
libxml2
- Download the latest libxml2 http://www.xmlsoft.org/
- Compile with
- $ ./configure
- $ make
- Install (as administrator)
- # make install
MathGL
- Download the latest mathgl http://mathgl.sourceforge.net/
- Compile this with:
- $ ./configure --disable-gsl
- $ make
- Install with
- # make install
3Depict Compilation
Run the "configure" script (as a normal user) with:$ ./configure
This script works out some of the specifics of your system. If it fails, saying that it cannot locate ftgl, and you know you have the headers and libraries installed, simply pass the directory for ftgl with --with-ftgl-prefix=(wherever, for example /usr/ if ftgl is installed in /usr/include and /usr/libs). A full list of possible options (there are many) is available with:
$ ./configure --help
build the project (again normal user) with:
$ make
to run the program:
$ ./src/3Depict
you can optionally install it (Excluding mac OS) with:
# make install
Extra notes for Mac OSX
To build a .app package (required to interact with the program), you need to run $ makeMacOSXPackage
You can even move this ".app" package to other computers (with the same OSX version), and it should work there.
Compile notes for windows
Before I post the full notes, this is very, very detailed and technical. But it means I have this working, and down to a fine art. So buckle your seatbelt Dorothy.
You will need the 7zip file manager program or winrar to be able to open tar/gz files, as windows does not support this filetype, nor recognises it in the "web search" facility. (Its a standard gzip + archive file, see wikipedia on tar-gz)
This worked under windows 7.
Files required to set up dependencies:
- MSYS-1.0.11.exe
- tdm-gcc-4.5.1.exe
- lpng143.zip
- freetype-2.3.12.tar.gz
- gsl-1.14.tar.gz
- zlib-1.2.5.tar.gz
- libxml2-2.7.7.tar.gz
- ftgl-2.1.3~rc5.tar.gz
- mathgl-1.10.2.1.tar.gz
- wxMSW-2.8.11.zip
Setting up dependencies
- Installed TDM-GCC-4.51 (32bit) (all defaults +openmp)
-
Installed MSYS-1.0.11
- - Said "yes" to "have mingw installed (c:/MinGW32/)
- Use console provided by the big blue "m(sys)" shortcut now on desktop to do most of the following
- Checked thatgcc --version worked (should now spit out something like "gcc.exe (tdm-1) 4.5.1")
wxWidgets
- Extracted wxMSW-2.8.11.zip to C:
- ran ./configure --with-opengl --enable-unicode inside c:\wxMSW-2.8.11\
- ran make. This will take a long time to run. (make can of course be sped up on multi-cpu systems with make -j(#CPU) (eg make -j4) to enable parallel compilation
-
Checked that the openGL wxWidgets sample works.
- cd samples/opengl
- make
- Ran samples/opengl/cube/cube.exe
- Copied dlls that it complained about when double clicking the icon to the exe folder. (wxbase28u_gcc_custom.dll,wxmsw28u_core_gcc_custom.dll,wxmsw28u_gl_gcc_custom.dll)
- Ran samples/opengl/cube/cube.exe
- Saw cube. OpenGL must therefore work.
- Ran make install
zlib
- ran make -f win32/Makefile.gcc
- Copied .h to C:\MinGW32\include\
- Copied zlib1.dll,libz.a,libzdll.a to C:\MinGW32\lib\
libpng
- depends upon zlib, so do zlib first
- ran make-f scripts/makefile.gcc
- Copied .h to C:\MinGW32\include\
- Copied libpng.a to c:\MinGW32\lib\
libxml2
- Ran ./configure
- -- Failure on libtoolT (I ignored this).
- Ran make
- - Failed on testThreads.c line 110: tid[i]= (pthread_t)-1; should be tid[i].p= NULL; tid[i].x=-1; as pthread_t is a struct under windows ( see http://sourceware.org/pthreads-win32/faq.html, Q11) looking in pthread.h: typedef struct { void p; / Pointer to actual object / unsigned int x; / Extra information - reuse count etc / } ptw32_handle_t;
- Ranmake install
libfreetype
- Ran ./configure
- Ran make
- Ran make install
ftgl
-
Edited configure
- --found "-lgl" replaced with "-lopengl32".
- -- found "-lGLU" replaced with "-lGLU32"
- --openGL and GLU tests are broken. in "configure" replace char glBegin() with #include <GL/gl.h> and char gluNewTess (); with #include <GL/glu.h>, then remove the "return" specification from the function call. This will allow the GL and GLU tests to succeed
- Ran ./configure
- Make
- make install (this installs into /usr/local/, which is not preferable, really)
GSL
- Ran ./configure
- Ran make
- ran make install
Mathgl
- (Depends GSL, do that before this) Ran ./configure
-
Ran Make
- -- This failed in the utils dir. libpng is unable to see libz for whatever reason. Does not bode well, but it was in the utils sectio, which I don't need, so I ignored it.
- Entered the "mgl" directory & ran make install
- Entered the "include" directory & ran make install
3Depict
- Had to override glu (gluSphere) check (this appears to be broken?)
-
Ran export CFLAGS="-I/c/msys/1.0/local/include" && LDFLAGS="-I/c/msys/1.0/local/lib" && ./configure
- -- For an explanation for why this is needed, see this mingw faq. I can only describe this decision as "insane", and "guaranteed to annoy everyone who attempts to use the system by simply not doing what it is supposed to do"; I am sure there must be a good reason for this seemingly crazy decision, but damned if I know what it is.
- Ran make
- Modified pngread.h to remove windows specific path
- Modified c:\msys\1.0\include\mgl\mgl_data.h to add #undef NO_GSL immediately before #ifndef NO_GSL
-
Re-ran make
- --windres failed due to include directory error
- -- Manually ran windres, after locating wx RC file
-
re-ran make
- --Failed during link "undefined reference" errors
- Used faulty link output and re-ordered libs by hand: g++ -I/c/msys/1.0/local/include -I/usr/local/include/freetype2 -I/usr/local/include -I/usr/local/lib/wx/include/msw-unicode-release-2.8 -I/usr/local/include/wx-2.8 -DWXUSINGDLL -D__WXMSW__ -I/usr/local/include/libxml2 -DDEBUG -I/c/msys/1.0/local/include -L/c/msys/1.0/local/lib -L/C/MinGW32/lib/ -o 3Depict.exe 3Depict-quat.o 3Depict-pngread.o 3Depict-glPane.o 3Depict-basics.o 3Depict-cameras.o 3Depict-drawables.o 3Depict-lights.o 3Depict-3Depict.o 3Depict-scene.o 3Depict-mathglPane.o 3Depict-plot.o 3Depict-APTClasses.o 3Depict-filter.o 3Depict-viscontrol.o 3Depict-mathfuncs.o 3Depict-wxcomponents.o 3Depict-colourmap.o 3Depict-select.o 3Depict-common.o 3Depict-XMLHelper.o 3Depict-ResDialog.o 3Depict-ExportPos.o 3Depict-ExportRngDialog.o 3Depict-StashDialog.o 3Depict-textures.o 3Depict-configFile.o 3Depict-K3DTree.o 3Depict-effect.o 3Depict-mesh.o 3Depict-IsoSurface.o 3Depict-winconsole.o 3Depict.o -L/usr/local/lib -mthreads -Wl,--subsystem,windows -mwindows -lwx_mswu_richtext-2.8 -lwx_mswu_aui-2.8 -lwx_mswu_xrc-2.8 -lwx_mswu_qa-2.8 -lwx_mswu_html-2.8 -lwx_mswu_adv-2.8 -lwx_mswu_core-2.8 -lwx_baseu_xml-2.8 -lwx_baseu_net-2.8 -lwx_baseu-2.8 -lwx_mswu_gl-2.8 -L/usr/local/lib -lxml2 -lpthread -lws2_32 -lmgl `gsl-config --libs` -lftgl -lfreetype -lglu32 -lopengl32 -lxml2 -lpng -lz
-
Double clicked program
- -- Put missing DLL it complained about in the same dir. Kept doing this until it stopped whinging about dlls