Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DLL Talk / Need help getting this plugin to work...

Author
Message
WLGfx
11
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 21st May 2012 18:17
Plugin problem:

I've been working on my procedural 3D level generator for a long time now and just recently got it to work perfect with Dark GDK (V1.0). So, once it was working in Dark GDK, it was time to turn it into a plugin for the Dark Basic Pro community.

The Visual Studio 2008 Express C++ setup for a DLL with the default project settings I used, with the Multi-Byte settings changed and also attached the lib and the include dirs for the DBP plugin header files from IanM.

At first, when writing a sample dba file to test the plugin I'd immediatly hit 'Error 501: Something about an image'. So I put checks in my code to test the stages it was running at and it got past the first function, the setup. I also took out a vector with held an array of objects for the plugin for future use. I even ditched the lot and started the DLL plugin project another 2 times.

What is actually happening now is the when I go to compile a project from the DBP IDE (default editor), it will freeze and then complain it cannot write the exe file. So I loaded up some old DBP projects and they compile and run just fine.

In case the problem can be spotted from here I'll post some of the source files. If not I can email the project over for someone to take a look at. I'm pulling my hair out again and really want to release this plugin as soon as but I'm flummoxed.

stdafx.h


Standard.cpp


dllmain.cpp


resource.h


resource.rc


PROC_MAP.ini


DBP_functions


The other four files are the main PROC_MAP code with all the GDK function calls changed to DBP calls, ie from _GDK_PM.cpp


I've also checked many times that #include "DarkGDK.h" is not there and it isn't...

Please someone help me get this finished.

I'll email the entire project if anyone would like to check it out.

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
Diggsey
13
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 21st May 2012 19:24 Edited at: 21st May 2012 19:25
That error usually means that the old version of the .exe DBPro is trying to create is locked for some reason. Have you tried manually deleting the .exe file before compiling? You could also try compiling to a different place in case it is some protection feature (the "My Documents" folder is a pretty safe bet).

The only other alternative I can think of is that the DLL is failing to load (the compiler loads all DLLs used by a program it is compiling) but I'm fairly sure that generates a different error message.

[b]
WLGfx
11
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 21st May 2012 19:36
I've tried moving the sample DBP project files to My Documents, I've even switched off the internet and then disabled the firewall and anti virus. I'm running on Win XP SP3. First time I've ever come across this. I've also un-hidden system files in case there's a locked file somewhere, cleaned out the DBP temp dir.

Still, other projects are compiling and running. Just not the one using this plugin so far, just freezes and then complains that the exe cannot be written. The next thing to try (which I doubt will make a difference) is to re-install DBPro.

If my laptop had a neck it would have probably been throttled a long time ago...

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
WLGfx
11
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 22nd May 2012 02:04
Nope, a fresh install of Dark Basic Pro hasn't resolved it. It may just be a silly mistake but I'm almost ready to give up with it. :-(

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
Diggsey
13
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 22nd May 2012 04:27
What happens if you try compiling a simple program that uses commands from your plugin?

[b]
WLGfx
11
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 22nd May 2012 05:29 Edited at: 22nd May 2012 05:39
The compiler will just get to 25% on a simple program, does nothing else for about another minute then says it cannot create the exe. My other plugins are still working 100% and everything is still compiling and running. The plugin for this PROC_MAP is now at 75Kb which should be getting bigger soon with a few more ideas I've got in mind, if I can get it working. At first I thought that it might have been because I was using STL but I've used that in another plugin.

I've attached the current plugin with two very basic samples. (At the moment I'll only email or drop box link the source code, not post it just yet.)

EDIT: Error message - Compilation Failed (No exe created)

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!

Attachments

Login to view attachments
Diggsey
13
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 25th May 2012 03:42
It's getting stuck inside "GetDependencyID()". Somehow it keeps recursively calling into itself, I'm not sure how yet. If you want to email me the debug symbols and source code I may be able to take a look at what it's actually doing.

[b]
WLGfx
11
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 25th May 2012 05:52
Email sent... The entire project with the extras for plugins from IanM sometime ago... Let me know if you need the GDK version of the source. (you shouldn't need it though)

Fingers crossed... Thanks...

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
MrValentine
AGK Backer
8
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 27th May 2012 05:03
Diggsey any luck?

I really want to see this plugin progressing its showing so much potential!

Duffer
16
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 27th May 2012 17:53
@ WLGfx,

IanM has offered help as well if you can send him project, code and version of Visual Studio you're working with?

http://forum.thegamecreators.com/?m=forum_view&t=197121&b=18

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...
Diggsey
13
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 27th May 2012 20:11
Sorry I've been kinda busy atm, got exams in a week so trying to spend more time revising...

[b]
Diggsey
13
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 28th May 2012 01:24 Edited at: 28th May 2012 02:11
OK, I found the problem You have a static instance "_GDK_PM MAP;" in your code. I haven't quite worked out where yet but somewhere the constructor for that type, it's base type, or one if its fields is trying to access DBPro stuff which obviously fails at compile time. If I change it to "_GDK_PM* MAP;" instead it compiles fine.

edit:
Found it. It wasn't in the constructor it was in the destructor, one of the reasons it was hard to track down! When the compiler tried to unload all the DLLs it had loaded to move onto stage 2 of the compilation process, the destructor of that static instance called a DBPro function causing it to load DBProCore.dll and get stuck in a loop.

You should always perform initialisation in the "Constructor" function and deinitialisation in the "Destructor" function. Static instances will have a much longer lifetime than they should and will be constructed and destructed when the DLL is loaded for any reason, such as by the compiler.

[b]
WLGfx
11
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 28th May 2012 03:18
@Diggsey - It's finally compiling and almost finished, just got to fix the returning of float values. I've now moved most of the destructor code elsewhere. I remember also why I put the PreDestructor function in but I never used it to shut down PROC_MAP. DBP dumps images and objects on shut-down anyway, but I've also move the clean-up code so it doesn't interfere with the unloading of the DLL's.

At the end of writing the code for the PROC MAP plugin I was getting very weary and completely missed the destruction code.

Many, many thanks for spotting something that would have had me going bald.

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
Diggsey
13
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 28th May 2012 04:49
No problem , it wasn't really the fact that the code was in the destructor that was the problem (ideally that's how it should work) it's just that the lifetime of the object shouldn't be bound to the lifetime of the .dll, instead it should be "new"ed and "delete"d in the Constructor and PreDestructor functions. It doesn't really matter but it's just nice to keep using the standard constructor/destructor semantics of C++.

[b]
WLGfx
11
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 28th May 2012 18:46
Yeah, the calling of the DBPro functions in the destructor was the problem which I couldn't see at the time. Again huge thanks for spotting it.

It's finally finished and working and I'm about to post it up for anyone who wants to use it now...

+

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!

Login to post a reply

Server time is: 2019-06-15 21:32:00
Your offset time is: 2019-06-15 21:32:00