Set the C++ Default Include folder in code?
BlitzMax Forums/BlitzMax Programming/Set the C++ Default Include folder in code?
| ||
Is there some way to set the default include path in C++ imported into BMax? I'm wrapping some C++ code which has a lot #includes, but they all use the angular bracket convention, meaning that you need to set up an include folder where they're all stored. That's easy enough in C++ because you can set it in the project settings. But BlitzMax invokes GCC for us, so we can't do that. I'm guessing it't possible to set it on the command line too, but again, since BlitzMax invokes GCC, we don't get control over it. Is there some way to do it? I don't really want to edit all the header files to get them to point to the correct files if I can possibly help it. It just seems messy editing the header files. For one thing, you have to do it all over again every time the library is updated. |
| ||
A system path, or a path relative to the code you are compiling? If you are building a module, you might use CC_OPTS ? |
| ||
Relative to the code I'm compiling, ideally. It's a module, yes. I'm not sure how to use CC_OPTS. A google just came back with a lot of makefiles, which kinda brings me back where I started because it's BlitzMax intercepting the makefiles by calling GCC itself which has me confused. Is there one of your modules which uses it, that I could use as a reference? |
| ||
Is there one of your modules which uses it, that I could use as a reference? Pretty much all of them, I'd imagine ;-) CC_OPTS and LD_OPTS are one of those "mostly only ever used by me" additions I've made to bmk. A few random examples : BaH.cegui ModuleInfo "CC_OPTS: -fexceptions" ModuleInfo "CC_OPTS: -DPCRE_STATIC" ModuleInfo "CC_OPTS: -DCEGUI_STATIC -DCEGUI_FALAGARD_RENDERER -DCEGUI_WITH_TINYXML -DCEGUI_CODEC_FREEIMAGE" LD_OPTS from bah.crypto - ?win32 ModuleInfo "LD_OPTS: -L%PWD%/ssl/lib" ? where %PWD% is the path to the module. (without this, your libs would need to go into BlitzMax/lib). Plus, you can also import "includes" folders, which are added to the compiler options by bmk. One for each entry, all relative to the file they are imported from : again from BaH.CEGUI Import "../libxml.mod/src/*.h" Import "../../pub.mod/freetype.mod/include/*.h" Import "../regex.mod/src/*.h" Import "../freeimage.mod/src/*.h" ?macos Import "-framework CoreFoundation" Import "cegui/src/implementations/mac/*.h" ? ' Import "cegui/include/*.h" HTH. |
| ||
Thanks for the explanation and example, Brucey. That indeed looks very useful. I hope to become "second person to use it" then, because it looks ideal for modules, and I'm really hankering to write wrappers for Ogre and/or QT. Masochist, or what? :P I have a pretty strong inkling that this is only going to work in 1.32 or 1.33 though, isn't it? I've stuck with 1.30 up until now so that I can be sure I don't introduce any new bugs into my game so far into development. I know the new GC and threading stuff is optional, but there's always a risk of a minor bug somewhere. |
| ||
No. I believe 1.26 (or thereabouts) was minimum. It's been around for a while. |
| ||
Wow, that's incredibly easy and has removed an enormous list of errors I was getting compiling QT. Thanks man, that's brilliant stuff. |
| ||
Ok, I've resolved all the include problems, but having problems linking. There are a ton of libs with QT so putting them in the libs folder is not ideal. I tried your LD_OPTS example, but I'm not really sure what you're doing with %pwd%. Do you mean that I should physically write the full path the module where you've written that? That's what I did initially but the linker complains that all the extern'ed functions cannot be found. Or should it be a relative path from the blitzmax folder or the bin folder or something? If it's some other compiler mechanism, then I'm not clear on how to use it correctly. It sounds as if you're saying it does the entire folder of libs. So I split debug and release into two folders and did this in the module: SuperStrict Module latenight.qt ModuleInfo "CC_OPTS: -Iinclude/" ?Debug ModuleInfo "LD_OPTS: -Lc:/program files/blitzmax/mod/latenight.mod/qt.mod/lib/debug" ? ?Not Debug ModuleInfo "LD_OPTS: -Lc:/program files/blitzmax/mod/latenight.mod/qt.mod/lib/release" ? |
| ||
How's aboutModuleInfo "LD_OPTS: -L%PWD%/lib/debug" Of course, it all depends on how your libraries are configured too. There are a ton of libs with QT I've got a MaxGUI wrapper for QT lying around somewhere. |
| ||
Yep, I tried it with the %PWD%/lib/debug as well. I wasn't sure if you meant me to type it literally, but I gave it a go and didn't have any luck with it. The libs are all named correctly, they're all in the lib<blah>.a convention which GCC wants, and QT is only officially delivered in GCC form, you have to compile it for Visual Studio so I'm pretty sure it's not that. I'm still getting all the "undefined reference to `_imp___ZN12QApplicationC1ERiPPci'" linker errors. The name mangling makes it trickier than it should be, but I think that is the QApplication constructor that it cannot find. I'm not sure what else there is to do. With libraries I've wrapped before, I've always been able to put them in the libs folder and import them individually. It doesn't seem wise to do that with QT though. |
| ||
Having fiddled with this some more, I've found two things. Firstly, the libs import fine if I put in the BlitzMax/libs folder so I'm definitely doing something wrong with your LD_OPTS Secondly, it looks as though the version of GCC that was used to compile QT uses a different name mangling convention than the version of GCC that I have installed with BlitzMax. I'm not going to fiddle with BlitzMax to fix that when I'm developing a game, so QT will just have to wait. |
| ||
the version of GCC that was used to compile QT You might need to build it yourself. I'm definitely doing something wrong with your LD_OPTS Remember paths are relative to the module (in question) folder. Your mod is called gab.mod, which contains the lib folder, then -L%PWD%/lib... should work. %PWD% will expand to /path/to/blitzmax/mod/gabriel.mod/gab.mod HTH. btw, how are you going to handle slot/signal? |