include files on gcc

wyrmmage
Posts: 4
Joined: Fri Feb 01, 2008 3:23 am

include files on gcc

Post by wyrmmage »

Hello again everyone :)

I'm trying to build bullet using the GNU mingw tool-set and it's presenting me with a rather time-consuming problem (which I fixed, but I thought I'd bring it to light int he hopes that it would be fixed in the main source so that I don't have to make the modification again when another version comes out).

Basically none of the include paths specified in header files (and quite a few of the .cpp files) work correctly when building with mingw, although they work fine on MSVC; this is because mingw handles paths differently than MSVC does. Fixing the include paths so that they work on mingw means that they still work on MSVC, but not vice versa.

Let's take a look at the file BulletCollision\BroadphaseCollision\btAxisSweep3.h . This file includes btPoint3.h, found in LinearMath, like so:

Code: Select all

#include "LinearMath/btPoint3.h"
MSVC looks for header files in the top level directory, so it will successfully find the folder LinearMath; mingw looks for folders relative to where the file was included, so it's going to look only for folder in BulletCollision\BroadphaseCollision\ . Since LinearMath isn't present in BulletCollision\BroadphaseCollision\ , mingw can not find the necessary include files.

For mingw to successfully find the include file, the include statement must look like this:

Code: Select all

#include "../../LinearMath/btPoint3.h"
I thought that perhaps telling the compiler to look in every directory where include files are would help, but it didn't, so I ended up spending about three hours editing the majority of the .h and .cpp files so that I could compile my program with mingw :(

Any chance of changing how include files are specified in the main trunk? The process could be done slowly, because MSVC will recognize relative paths and the way paths are specified now, so it's not like progress would have to be halted in order to make this change...if every developer just specified paths this way when they re-wrote a bit of code, then I think the change would be done fairly quickly with little effort ;)

Thanks in advance...any comments are appreciated :)
-wyrmmage
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: include files on gcc

Post by Erwin Coumans »

It should not be necessary to modify any Bullet source/header files to get the project to compile under MinGW.

How do you exactly build under MinGW? Do you use CMake to generate Makefiles?

In any case, you should include the current directory (.) and the src folder in your include path.
If the Makefile is located in Bullet root folder, it would be -I. and -Isrc

Hope this helps,
Erwin
wyrmmage
Posts: 4
Joined: Fri Feb 01, 2008 3:23 am

Re: include files on gcc

Post by wyrmmage »

yes, I'm using CMake to generate the files specifying MingW Makefiles as the makefile option the makefile is located in the src/ directory. I've tried putting the makefile in the top level directory (the one right above src/, I mean), but that just gives me the error:

Code: Select all

  [Linker error] undefined reference to `WinMain@16' 
If I put the makefiles in src/, I get the errors about not being able to find the include files. Do I have to manually specify any include paths? I would think that CMake would automatically generate those, wouldn't it? Besides, since the makefile is in the src/ directory, it shouldn't need to have any include paths specified, should it? :\

I'm compiling on Vista Home Premium 32-bit SP 2, in case that helps.

Thanks for the help so far :)
-wyrmmage
chunky
Posts: 145
Joined: Tue Oct 30, 2007 9:23 pm

Re: include files on gcc

Post by chunky »

For mingw to successfully find the include file, the include statement must look like this:
You need to pass gcc the -I flag [that's a capital i, not a little L] with the path to the top level bullet source. It adds that to the search path, and then trying to #include "LinearMath/whatever.h" will correctly find it.

Gary (-;
wyrmmage
Posts: 4
Joined: Fri Feb 01, 2008 3:23 am

Re: include files on gcc

Post by wyrmmage »

I'll have to try that out, thanks :)
-wyrmmage