OSX include problem

Hello,

I have searched far and wide for my problem, but have not really found
a solution.
I am making an application that needs to compile on both linux and
osx, so I installed the unix-style version of SDL on my iMac using
macports (http://www.macports.org/) (NOT the framework version).

everything seems to be installed, and following commands give this output:
sdl-config --libs ==> -L/opt/local/lib -lSDLmain -lSDL -Wl,-framework,Cocoa
sdl-config --cflags ==> -I/opt/local/include/SDL -D_GNU_SOURCE=1
-D_THREAD_SAFE

So I think there is no problem with the install itself. Anyway, I am
using a makefile to build the source, this is the part worth
mentioning:

CXXFLAGS = -Wall -g sdl-config --cflags
LDFLAGS = -shared sdl-config --libs -lSDL_gfx
g++ $(LDFLAGS) -o $(PROJECT).so $(OBJECTS)

This SHOULD work, but now the problems came: it could not find some of
the included SDL headers I used in the cpp file:
error: SDL/SDL_gfxPrimitives.h: No such file or directory

I checked if they existed, and there really is a
/opt/local/include/SDL/ folder containing all the headers it claims it
can not find.
After searching for a while, I found out there was also a
/Library/Frameworks/SDL.framework/ (maybe installed by an app i
previously installed?). After doing a test “delete” of the
SDL.framework folder, it gives me:
error: SDL/SDL.h: No such file or directory
error: SDL/SDL_gfxPrimitives.h: No such file or directory
Obviously this means g++ is using the SDL.framework folder to look for
its header files instead of the unix style /opt/local/include/
SDL_gfx is another lib I installed with macports, that was placed in
/opt/local/include/SDL/ and NOT in SDL.framework (hence the missing
SDL_gfxPrimitives.h).

So in short, the problem is that somehow g++ looks in the
SDL.framework folder for the includes, even though I SPECIFICLY
specified (or at least sdl-conf did) that the headers are in
/opt/local/include/ .

Does anyone have an idea of what is going wrong?

Reinout

sdl-config --cflags ==> -I/opt/local/include/SDL -D_GNU_SOURCE=1
Does anyone have an idea of what is going wrong?

You specified to look for headers in /opt/local/include/SDL, but not in
/opt/local/include.

Anyway the practice to include SDL with path is deprecated if I remember
correctly so the error is not in the sdl-config script but in your sources
where you should include:

#include “SDL.h”
#include “SDL_gfxPrimitives.h”

… and so on.On Thu, Oct 16, 2008 at 4:58 PM, Reinout Roels <reinout.roels at gmail.com>wrote:


Bye,
Gabry

You are right! Thanks a lot, it’s very stupid mistake :frowning:

BUT the problem does not seem to be fixed now, now it can’t find any
headers anymore. I’ll try to look further to see why (even eclipse
says it can’t find them although /opt/local/headers/SDL/ was specified
as include dir).

ReinoutOn Thu, Oct 16, 2008 at 5:02 PM, Gabriele Greco <gabriele.greco at darts.it> wrote:

On Thu, Oct 16, 2008 at 4:58 PM, Reinout Roels <@Reinout_Roels> wrote:

sdl-config --cflags ==> -I/opt/local/include/SDL -D_GNU_SOURCE=1
Does anyone have an idea of what is going wrong?

You specified to look for headers in /opt/local/include/SDL, but not in
/opt/local/include.

Anyway the practice to include SDL with path is deprecated if I remember
correctly so the error is not in the sdl-config script but in your sources
where you should include:

#include “SDL.h”
#include “SDL_gfxPrimitives.h”

… and so on.


Bye,
Gabry


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Sorry, I meant /opt/local/include/SDL (makefile nor eclipse can find
them, files are there though)On Thu, Oct 16, 2008 at 5:21 PM, Reinout Roels <@Reinout_Roels> wrote:

You are right! Thanks a lot, it’s very stupid mistake :frowning:

BUT the problem does not seem to be fixed now, now it can’t find any
headers anymore. I’ll try to look further to see why (even eclipse
says it can’t find them although /opt/local/headers/SDL/ was specified
as include dir).

Reinout

On Thu, Oct 16, 2008 at 5:02 PM, Gabriele Greco <gabriele.greco at darts.it> wrote:

On Thu, Oct 16, 2008 at 4:58 PM, Reinout Roels <@Reinout_Roels> wrote:

sdl-config --cflags ==> -I/opt/local/include/SDL -D_GNU_SOURCE=1
Does anyone have an idea of what is going wrong?

You specified to look for headers in /opt/local/include/SDL, but not in
/opt/local/include.

Anyway the practice to include SDL with path is deprecated if I remember
correctly so the error is not in the sdl-config script but in your sources
where you should include:

#include “SDL.h”
#include “SDL_gfxPrimitives.h”

… and so on.


Bye,
Gabry


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

You know what’s weird?
When I write my includes like so:

#include “/opt/local/include/SDL/SDL.h”

IT WORKS! but when I just write “SDL.h” it can’t find it (and i’m sure
sdl-config tells gcc it should look in /opt/local/include/SDL
Any idea why this happens? I would like my code to be compilable in
linux too, so writing the full path is not really a good solution

ReinoutOn Thu, Oct 16, 2008 at 5:23 PM, Reinout Roels <@Reinout_Roels> wrote:

Sorry, I meant /opt/local/include/SDL (makefile nor eclipse can find
them, files are there though)

On Thu, Oct 16, 2008 at 5:21 PM, Reinout Roels <@Reinout_Roels> wrote:

You are right! Thanks a lot, it’s very stupid mistake :frowning:

BUT the problem does not seem to be fixed now, now it can’t find any
headers anymore. I’ll try to look further to see why (even eclipse
says it can’t find them although /opt/local/headers/SDL/ was specified
as include dir).

Reinout

On Thu, Oct 16, 2008 at 5:02 PM, Gabriele Greco <gabriele.greco at darts.it> wrote:

On Thu, Oct 16, 2008 at 4:58 PM, Reinout Roels <@Reinout_Roels> wrote:

sdl-config --cflags ==> -I/opt/local/include/SDL -D_GNU_SOURCE=1
Does anyone have an idea of what is going wrong?

You specified to look for headers in /opt/local/include/SDL, but not in
/opt/local/include.

Anyway the practice to include SDL with path is deprecated if I remember
correctly so the error is not in the sdl-config script but in your sources
where you should include:

#include “SDL.h”
#include “SDL_gfxPrimitives.h”

… and so on.


Bye,
Gabry


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

You know what’s weird?
When I write my includes like so:

#include “/opt/local/include/SDL/SDL.h”

IT WORKS! but when I just write “SDL.h” it can’t find it (and i’m sure
sdl-config tells gcc it should look in /opt/local/include/SDL
Any idea why this happens? I would like my code to be compilable in
linux too, so writing the full path is not really a good solution

Maybe try setting your CFLAGS to include /opt/local/include/SDL?

For BASH something like:

export CFLAGS='-I/opt/local/include/SDL $CFLAGS"

Hope this helps,

Jeshua Lacock
Founder/Programmer
3DTOPO Incorporated
http://3DTOPO.com
Phone: 877.240.1364On Oct 18, 2008, at 1:33 AM, Reinout Roels wrote:

Good idea, but doesn’t seem to help :(On Sat, Oct 18, 2008 at 9:37 AM, Jeshua Lacock <jeshua at 3dtopo.com> wrote:

On Oct 18, 2008, at 1:33 AM, Reinout Roels wrote:

You know what’s weird?
When I write my includes like so:

#include “/opt/local/include/SDL/SDL.h”

IT WORKS! but when I just write “SDL.h” it can’t find it (and i’m sure
sdl-config tells gcc it should look in /opt/local/include/SDL
Any idea why this happens? I would like my code to be compilable in
linux too, so writing the full path is not really a good solution

Maybe try setting your CFLAGS to include /opt/local/include/SDL?

For BASH something like:

   export CFLAGS='-I/opt/local/include/SDL $CFLAGS"

Hope this helps,

Jeshua Lacock
Founder/Programmer
3DTOPO Incorporated
http://3DTOPO.com
Phone: 877.240.1364


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Good idea, but doesn’t seem to help :frowning:

You might have to change the CFLAGS in your Makefiles (using perl or
sed perhaps), or rerun configure after setting the CFLAGS…

Additionally, you may need to set CPPFLAGS and CXXFLAGS…

Regards,

Jeshua Lacock
Founder/Programmer
3DTOPO Incorporated
http://3DTOPO.com
Phone: 877.240.1364On Oct 18, 2008, at 1:46 AM, Reinout Roels wrote:

You know what’s weird?
When I write my includes like so:

#include “/opt/local/include/SDL/SDL.h”

IT WORKS! but when I just write “SDL.h” it can’t find it (and i’m sure
sdl-config tells gcc it should look in /opt/local/include/SDL
Any idea why this happens? I would like my code to be compilable in
linux too, so writing the full path is not really a good solution

Just an off-the-wall idea, what if you write your include as #include
<SDL.h>? I’m not an expert, and therefore don’t know how it’s
supposed to work, but I’ve observed that for headers used in the build
vid -I, I want to use the angle-brackets, and not quotes.

– ScottOn Oct 18, 2008, at 1:33 AM, Reinout Roels wrote: