Author Topic: Invalid Handle errors?  (Read 4069 times)

0 Members and 1 Guest are viewing this topic.

Offline cr0sh

  • Newbie
  • Posts: 10
    • View Profile
Invalid Handle errors?
« on: September 16, 2018, 06:14:19 pm »
Hey guys, it's been ages since I last posted, back on the (I guess?) old .net forum (I've been away so long I don't even know what happened there, etc).

Anyhow, today I needed to run a simple QB program and found my old install (v1.0 - yay) of QB64 wasn't working right (it gave a compile error on even the simplest of code), so I installed the latest version of QB64 (after a lot of trials of issues where I had to modify the g++ command to load missing libs on the command line). Once I got past that, it installed fine.

BTW - I am doing all this on a very customized and munged up version of Ubuntu 14.04 LTS - long in the tooth, and beat to within an inch of it's life - mainly just to keep it up-to-date enough to continue to compile and run stuff (someday, hopefully soon, I'm going to wipe this system and start fresh with something more recent; until then, I work with what I got).

So once I got things installed, I tried to compile a simple program (nothing more than CLS: PRINT "Hello World") - which also failed - had to make a similar mod as before to the command line libraries, to include glibc - something like "-lstdc++" or something like that).

Once that was in place, I could compile the simple hello world test case. So then I jumped into the deep end and decided to try out one of the OpenGL examples - that worked ok. I tried a few other examples - games, old-skool stuff, just various junk for the samples folders. Everything was compiling and working fine.

So then I decided to try one of my old pieces of code. I don't know if any of you were around back in the day or recall - but for a little bit I was playing around with QB64, updating it's IDE to fix some quirks (many of which are still there, btw - sigh) - and this was all prior to OpenGL integration, at least for Linux. So - I took one of my old QB4.5 demos I had, messed around with _MAPTRIANGLE - and came up with a rotating cube demo, and posted it on the (old?) forum.

Actually - I think I may have a copy on my github - yeah, here it is:

https://github.com/andrew-ayers/qb64/tree/master/mt_cube_v2

But when I run it, it throws a "Invalid Handle" error - and I don't know why. So - just so I didn't think I was crazy, I decided to try out this 3D engine code I had found on a thread on the old forum, I don't recall who wrote it (they were a genius tho!) - called "portals" - it was basically a simple "portal style" rendering engine. It does something similar in that it loads up various images for "texture files", then uses that data via the handle it has assigned - for instance, something like:

Code: QB64: [Select]
  1. handle = _LOADIMAGE("filename.bmp", 32)
  2. _SOURCE handle

Where it would die would be in the "_SOURCE handle" part, throwing the "Invalid Handle" error on that line (in my cube demo case, it throws it on the _MAPTRIANGLE line). I thought maybe - at least in the case of the portal engine (because my cube demo explicitly defines the variables properly) - because it didn't define the handle variable as a long, it needed that; so I threw in a "DIM handle AS LONG" - but the error persists.

As far as I can tell, all of this code is written properly, and there shouldn't be any errors. At this point, I don't know if I should suspect my system, my code (or the "portal code"), or QB64 - or some strange combo of "all of the above" as to causing this error.

Again, I note that I had to make modifications to the install script to pass in "-lstdc++ -lm" on the g++ command line in the installer (for QB64 compilation), and I had to do the same within "makeline_lnx.txt" just to get programs to compile and run.

But all the other examples run correctly - including the OpenGL examples (which of all I would expect them first to fail, being the most likely complex?).

So - I know I've written a book here - but does anyone have any idea what the problem could be? Has this been encountered before?

BTW - if a copy of the portal engine is wanted for testing, and it wasn't carried over to this new forum - I can possibly supply it too.

Thank you guy's for any help or insights!

EDIT: I just wanted to post the kind of errors I was getting that made me change the g++ compile options:

Code: QB64: [Select]
  1. /usr/bin/ld: libqb/os/lnx/libqb_setup.o: undefined reference to symbol '_ZNSi5tellgEv@@GLIBCXX_3.4'
  2. //usr/lib/x86_64-linux-gnu/libstdc++.so.6: error adding symbols: DSO missing from command line

They were all similar to the above - again, this happened during the time when I was installing QB64, and then once I updated the command line options and got it installed (and the IDE popped up and ran), then on compiling a simple example, I got similar errors that were only correct by making the same modification.
« Last Edit: September 16, 2018, 06:20:47 pm by cr0sh »

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: Invalid Handle errors?
« Reply #1 on: September 18, 2018, 01:06:15 pm »
Hi crOsh. What the characters in file name. Linux is sensitive for them. Then - when you print the pointer to this image, returns a value less than -1?

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Invalid Handle errors?
« Reply #2 on: September 18, 2018, 01:25:46 pm »
Yep, Linux systems are case sensitive. I use a Linux server and have been bitten by file not found because I uploaded something like my.JPG and forgot that the url to it on my html page was: my.jpg

Also, the _loadimage as written presumes the bmp you want to access is in the same folder as the program you are running. If it isn't, you need to include the directory path to the bmp like: _LOADIMAGE("c:\my-images\filename.bmp", 32) for example.

If none of these suggestions help. tell us and maybe others can offer more insight. TOSHIBA, but I work on a Windows system.

Pete

- TOSHIBA, Japanese for, "I'm sorry!"
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline cr0sh

  • Newbie
  • Posts: 10
    • View Profile
Re: Invalid Handle errors?
« Reply #3 on: September 18, 2018, 09:43:07 pm »
All, thank you for your help - I got it sorted, and I feel kinda dumb for why:

1) Greatest issue was that I forgot that by default QB64 compiles to its own directory - but in the IDE there's an option to make it compile to the source's directory. So - what was happening was that it compiled the project, executed it - and the files weren't in the same spot. Switching that compile option on fixed it - at least for my cube demo...

2) But the portals demo was still failing, even with this switched on! I found out that because the folder I had the portals.bas source code in had a portals folder inside (which held the textures for the demo), when it tried to compile portals.bas -> portals (binary), it couldn't - because "portals" was already a directory. This is a limitation of linux; I believe windows (and probably dos) allow you to have both an executable and a folder named identically. So - I changed the name of the folder to "textures", updated the code to point to that folder for the loading routines, recompiled - and it all worked properly!

So - all's good now, and everything ran right. I'm going to go look in the archive section of the forum to see if the portals demo is already around, and if not, I'll upload it for others - it's really a fun little demo (though a bit slow) - I just wish I could remember who created it (if I find the post, then I'll know).

Thanks again everyone!

Offline cr0sh

  • Newbie
  • Posts: 10
    • View Profile
Re: Invalid Handle errors?
« Reply #4 on: September 18, 2018, 09:46:28 pm »
Ah - I guess Galleon did it!

https://www.qb64.org/forum/index.php?topic=449.msg3941#msg3941

There's a posting there for it - I assume it's the same code (sans my mods to get it to work on my box)...