Register
Site Login
Site Search
Forums
Advertisement
Welcome to PocketMatrix. PocketMatrix is dedicated to providing the best online community for mobile device developers and enthusiests. What's new?

Building for DLL use?


Building for DLL use?

Postby InexorableTash » Nov 23, 2005 @ 7:23am

I finally decided to port my hobby project from GD3.01 to GD3.5 and ran into an issue.

If I build using the statically linked LIB everything is fine - but I want to build using the dynamically linked lib (LIB/DLL).

Here's what I'm seeing, with a repro for one of the samples:

* Copy the win32\Simple project
* Open it up in VS2003
* In the project properties, set Linker:General:Additional Library Directories to dll\vs2003-debug
* Copy the GapiDraw.DLL from that folder into the project folder
* Compile and run

The app runs fine until you exit

Unhandled exception at 0x7c901230 in simple.exe: User breakpoint.

The callstack is:

ntdll.dll!7c901230()
ntdll.dll!7c96c943()
ntdll.dll!7c96cd80()
ntdll.dll!7c960af8()
kernel32.dll!7c85e7af()
msvcr71d.dll!_CrtIsValidHeapPointer(const void * pUserData=0x00a34f68) Line 1807 C
msvcr71d.dll!_free_dbg_lk(void * pUserData=0x00a34f68, int nBlockUse=1) Line 1132 + 0x9 C
msvcr71d.dll!_free_dbg(void * pUserData=0x00a34f68, int nBlockUse=1) Line 1070 + 0xd C
msvcr71d.dll!operator delete(void * pUserData=0x00a34f68) Line 54 + 0x10 C++
GapiDraw.dll!10005685()
> simple.exe!CMyApplication::~CMyApplication() Line 72 + 0x38 C++
simple.exe!CMyApplication::`scalar deleting destructor'() + 0x2b C++
simple.exe!WinMain(HINSTANCE__ * hInst=0x00400000, HINSTANCE__ * hPrevInst=0x00000000, char * pCmdLine=0x00141f23, int nCmdShow=1) Line 55 + 0x33 C++
simple.exe!WinMainCRTStartup() Line 251 + 0x30 C
kernel32.dll!7c816d4f()
ntdll.dll!7c915b4f()
kernel32.dll!7c8399f3()

In other words, it's puking in the delete operator of the first CGapiSurface it tries to tear down.

Are there additional steps needed to get the use of the DLL working? Did I miss the docs somewhere?
User avatar
InexorableTash
pm Member
 
Posts: 99
Joined: Sep 13, 2002 @ 6:14am


Postby InexorableTash » Feb 15, 2006 @ 6:33am

Bump - any ideas?
User avatar
InexorableTash
pm Member
 
Posts: 99
Joined: Sep 13, 2002 @ 6:14am


Postby Antony » Feb 28, 2006 @ 12:22am

I am getting the same problem I guess. It is very easy to reproduce. Take the simple sample demo.

Change "Additional Library Directories" to use the DLL folder rather than LIB. Place the DLL with the exe. Run the app. When you attempt to exit the application it blows up on the delete for font.

Are we missing a preprocessor flag? What else is necessary to use the DLL rather than the static lib.

FYI, it doesn't matter when the delete is called. Within a function you can new a CGapiSurface and the try to delete it. It will bang straight away.

Slightly puzzled.
Ant.
User avatar
Antony
pm Member
 
Posts: 39
Joined: Jun 8, 2004 @ 10:43pm
Location: Hitchin, UK


Postby Johan » Feb 28, 2006 @ 9:52am

Strange, I have not experienced this issue with the debug version. Can you try to check your C++ settings for Runtime library and change that? I.e. if it's now "Multi-threaded Debug" then change it into "Multi-threaded Debug DLL" etc.. Try some changes and see what happens. I'll also investigate on my part.

Sincerely
Johan
Johan Sanneblad, M.Sc, Ph.D
GapiDraw Systems Architect
[http://www.gapidraw.com]
User avatar
Johan
pm Member
 
Posts: 1843
Joined: Jan 12, 2002 @ 12:38pm
Location: Sweden


Postby Antony » Feb 28, 2006 @ 6:02pm

Yes that is it Johan, Runtime was set to Multithreaded-Debug. :roll: Changing to Multithreaded-Debug DLL works fine. :D

Many Thanks.
Ant.
User avatar
Antony
pm Member
 
Posts: 39
Joined: Jun 8, 2004 @ 10:43pm
Location: Hitchin, UK


Postby Johan » Feb 28, 2006 @ 11:30pm

Great! I'll add it to the FAQ!

//Johan
Johan Sanneblad, M.Sc, Ph.D
GapiDraw Systems Architect
[http://www.gapidraw.com]
User avatar
Johan
pm Member
 
Posts: 1843
Joined: Jan 12, 2002 @ 12:38pm
Location: Sweden


Postby InexorableTash » Mar 1, 2006 @ 6:35am

Confirmed, that did it, both with the sample and with my XP and PocketPC builds of my hobby project.

Thanks, Johan!
User avatar
InexorableTash
pm Member
 
Posts: 99
Joined: Sep 13, 2002 @ 6:14am


Postby InexorableTash » May 15, 2006 @ 6:34am

For posterity, note that when you switch to VS2005 you run into a little bit of fun: Microsoft's Visual C++ Runtime (MSVCRT) was updated in VS8, so it is not longer "automagically present" on devices.

See http://msdn2.microsoft.com/en-US/library/c5fc53wa.aspx for instructions on how to deploy the MSVCRT80[d].DLL to your device when building in VS2005.[/url]
User avatar
InexorableTash
pm Member
 
Posts: 99
Joined: Sep 13, 2002 @ 6:14am


Postby nraf » Sep 18, 2007 @ 8:01am

I am using VS2003.net for C++ and have the same problem.

My project setting is already in /MDd

ntdll.dll!_DbgBreakPoint@0()
ntdll.dll!_RtlpBreakPointHeap@4() + 0x28
ntdll.dll!_RtlpValidateHeapEntry@12() + 0x113
ntdll.dll!_RtlValidateHeap@12() + 0xe0
kernel32.dll!7c85e9cf()
> msvcr71d.dll!_CrtIsValidHeapPointer(const void * pUserData=0x011b4f88) Line 1807 C
msvcr71d.dll!_free_dbg_lk(void * pUserData=0x011b4f88, int nBlockUse=1) Line 1132 + 0x9 C
msvcr71d.dll!_free_dbg(void * pUserData=0x011b4f88, int nBlockUse=1) Line 1070 + 0xd C
mfc71d.dll!operator delete(void * p=0x011b4f88) Line 369 + 0xc C++
SCC-COM.exe!SCCCOM::CSccIop::Run(int argc=4, char * * argv=0x00d86108) Line 3131 + 0x17 C++
SCC-COM.exe!SCCCOM::CSccCom::Run(int argc=4, char * * argv=0x00d86108) Line 3808 + 0x10 C++
SCC-COM.exe!main(int argc=4, char * * argv=0x00d86108) Line 3881 + 0x13 C++
SCC-COM.exe!mainCRTStartup() Line 398 + 0x11 C
kernel32.dll!7c816fd7()
nraf
pm Member
 
Posts: 1
Joined: Sep 18, 2007 @ 7:55am


Return to GapiDraw


Sort


Forum Description

The Cross-platform Graphics SDK for Palms, Pocket PCs, Symbian Devices, and Stationary PCs.

Moderators:

sponge, Johan

Forum permissions

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

cron