How to set up CHAI3D correctly with an SDL Project on Visual Studio 2013

438 views Asked by At

I am currently working on a project that uses the following libs: SDL2, SDL_ttf, SDL_image, SDL_mixer and CHAI3D. Using the libs separately, the code works perfectly on VS2013. However when I try to use both libs in the same project many errors arise. I managed to set up the SDL libs by adding their include& lib files to the VC++ directories. I try to add #include "chai3d.h" to this project that I placed under chai3d-3.1.0\examples....\Project\c++files. Which returns:

fatal error C1083: Cannot open include file: 'chai3d.h': No such file or directory

So I add to the Properties>Configuration Properties>VC++ directories>include directories the Path (../chai3d/src) of the folder that includes the "chai3d.h" file. This jumps to the 2 following errors:

fatal error C1083: Cannot open include file: 'Eigen/Eigen': No such file or directory

I find this file under chai3d/external/(Eigen/Eigen) and add it to the include directories and this comes:

fatal error C1083: Cannot open include file: 'GL/glew.h': No such file or directory

Notice that commenting the include lines or adding path from the external folder, would solve the C1083 but result in chai3d objects not being recognized such as the cHapticDeviceHandler. Here is part of my logs:

error C2062: type 'float' unexpected error C2146

error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

error C2086: 'int cVector3d' : redefinition see declaration of 'cVector3d'

error C2143: syntax error : missing ',' before '&'

error C2146: syntax error : missing ';' before identifier 'ch_computeForceSphere'

error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

error C2086: 'int cVector3d' : redefinition

error C2143: syntax error : missing ',' before '&'...

I would be very thankful for any hints on how to solve this.

1

There are 1 answers

0
SuperKogito On BEST ANSWER

So I am not sure about the usefulness of using both libs (SDL & CHAI3D) together, since combining them to come up with a useful code seems to be too complicated. However after some research I managed to find the way to do it:

  1. First you need to set up a chai3d project and not just use one from the examples folder, this can be done by following the instructions under this link: CHAI3D: creating an application.
  2. Then you need to set up your SDL libs the usual way by adding their include& lib files under Properties>Configuration Properties>VC++ directories>Include Directories /Library Directorie.

  3. Finally add the dependencies under Properties>Linker>Input>Additional Dependencies, for example in the case of SDL2 you will add the following:

SDL2.lib
SDL2Main.lib

Try to be careful about the SDL path and whether you need:

 #include <SDL.h>
 or
 #include <SDL2/SDL.h>