Linker problems when using Framework... and Import
BlitzMax Forums/BlitzMax Beginners Area/Linker problems when using Framework... and Import
| ||
Hi, I wanted to give a try to limiting the imported modules to the ones I need. So I put at the beginning of my program: Framework BRL.Graphics Import BRL.Max2D Import BRL.EventQueue It compiles, but the linker fails with several errors like: Building draw_main Compiling:draw_main.bmx flat assembler version 1.64 3 passes, 2180 bytes. Linking:draw_main /home/jean-marie/apps/BlitzMax/mod/brl.mod/math.mod/math.release.linux.x86.a(math.c.release.linux.x86.o): In function `bbSqr': math.c:(.text+0x50): undefined reference to `sqrt' ... a lot more in math.c... /home/jean-marie/apps/BlitzMax/mod/brl.mod/blitz.mod/blitz.release.linux.x86.a(blitz_cclib.c.release.linux.x86.o): In function `bbFloatPow': blitz_cclib.c:(.text+0xab): undefined reference to `pow' ... collect2: ld returned 1 exit status Build Error: Failed to link ... I am running BlitzMax 1.30 on Ubuntu 9.04. How can I get this fixed? Jean-Marie. |
| ||
You're using the wrong module for Framework, try using brl.max2d. |
| ||
You need to re-build your app with "Quick Build" disabled. |
| ||
You're using the wrong module for Framework, try using brl.max2d. That makes no difference at all, as long as you Framework one, and Import the rest. |
| ||
Oh that's right, sorry. |
| ||
I tried with the QuickBuild tip; it was already disabled. To be sure, I went to the shell, deleted everything in .bmx/ and run the compiler-linker from hand: rm .bmx/* bmk MakeApp draw_main.bmx with the same failure. Can someone help further? Thanks. Jean-Marie. |
| ||
I checked my libc; have both libc and libc-dev installed, version 2.9-4ubuntu6 |
| ||
I made a try on windows. On windows XP, it compiles and links, but running the program does nothing. Not even a graphic windows displays. am i doing st wrong? |
| ||
Try using Framework brl.basic which imports brl.math, and try running the sample apps to see if they work. |
| ||
I tried with Firepaint. After removing the Rem...End Rem and adding some missing imports (Import BRL.Max2D in firepaint.bmx and Import BRL.Math in color.bmx) I get the same kind of linker errors, in math and other libs: |
| ||
Okay... with those kind of errors, you need to consider re-building all of the modules to work with your current version of GCC. It's quite possible that you also don't have all the required dev libraries installed on your system. There's a good post HERE which details what libraries you should have for building apps with BlitzMax on Ubuntu 9.04. |
| ||
Another note (and this is unlikely), if you happen to have the blitzmax/lib folder symlinked to a Windows installation of BlitzMax and that folder happens to have libstdc, gcc, or somesuch, you may encounter errors like this. Always check for things like that, update GCC (to a compatible version) and rebuild mods |
| ||
ok, i tried to install packages, as proposed in the post mentioned by Brucey; didn't help. Anyway, as it works properly if I don't use Framework/Import, I would have supposed that necessary libs are there - or am I missing st here? so I downloaded 1.33rc5, bmk makemods and built my app. It compiles and links without error. But... it crashes on run: ~>Unhandled Exception:Attempt to access field or method of Null object ~> (same code compiles, links and runs fine when using bmk 1.30 or 1.33rc5, as long as I don't use Framework and Import directives). |
| ||
Your errors are a bit vague. Unhandled Exception:Attempt to access field or method of Null object For image loading, you need to import all the image loader modules for the image types you expect to use. (eg. BRL.PNGLoader) |
| ||
@Brucey: Sorry, but I don't have something more precise :-( This is all I get. If you can tell me how I can get more, I would be glad! I don't load images. And in this case, wouldn't the compiler or linker complain about missing dependencies? |
| ||
Since you are running it in debug mode. When you get that error above, type T and Enter. It will output a stack trace, which should help understand better the nature of the error in its context. |
| ||
Stack is:Function draw_main Function Cls I have following Fw/Imports: Framework BRL.Basic Import BRL.Graphics Import BRL.Max2D commenting out the Cls directives produces following: . no segmentation fault . no visible window . but a running draw_main process, consuming a full processor resource |
| ||
Cls is failing because there is no valid Graphics context. You need to Import BRL.GLMax2D (which will also import BRL.GLGraphics). The two modules you are currently importing are generic. GLMax2D is an actual implementation - which you need one of in order to do anything with graphic. On Windows there's also a direct x module which you can use instead. |
| ||
Thanks Brucey, that made it! Question: why doesn't the compiler or linker complain about missing dependencies? Another: if the compiler or linker doesn't warn, by which means can I find out which mods I should import, other than experience and intuition? Thanks again, Jean-Marie. |
| ||
The dependencies are missing really. Some modules are designed generically so that you can swap out the different "backend" implementations. If you forget to include an implementation, it won't know. The same goes for the image/pixmap loaders. You can build an app with LoadImage() / LoadPixmap() functionality but without any loaders compiled in. When it comes to loading the image at runtime, it will simply return Null from the function. By Importing a loader module, when the app starts up, the loader module informs the framework that it is available to load images. When you call the function, each registered loader module is called in turn until one returns a valid image. It's great for supporting expandability, because you aren't hard-coding support for specific graphics/image/etc handling. But of course, you need to remember to import the correct things in the first place... |
| ||
ok, i understand this pattern. Wouldn't some kind of runtime reporting help here? (exception, displayed warning or st like that)? |
| ||
Wouldn't some kind of runtime reporting help here Probably :-) |