Hi Karlos,
I came across the same problem. It is unbelievably annoying and should never have been allowed to happen, but there it is. I worked around it by declaring GfxBase as 'struct Library *' and not including graphics/gfxbase.h in the source file that opens/closes the library base. When the library was opened the GfxBase variable was copied to another variable with a different name.
All functions that needed access to a variable stored in GfxBase were placed in a different source file that did have graphics/gfxbase.h included.
In the second source file, I declared 'struct GfxBase *gfx' variable and copied the GfxBase pointer from the variable with a different name like so:
gfx = (struct GfxBase *)(sim.gfxLibPtr);
Then I could use gfx as GfxBase in that source file.
It might have been a round-about way to get past this and it might be done slightly easier, but it was just driving me insane at the time so when it worked I left it.