Good morning!
I'll soon have to decide whether to use BlitzMAX or PureBasic for my developments. The most important aspect will be whether I will be able to produce dynamically loadable libraries for all supported platforms (i.e., DLLs, DyLibs, Shared Objects)
I would really prefer to use BlitzMAX, but
- I managed to build and use a DLL under Windows (XP)
- when I try the same under Mac OS X, the application crashes
- I have not yet tried the same under Linux (as Mac OS X is more important)
Has anybody managed to build DyLibs and Shared Objects?
Here is my approach for Mac OS X:
- the library (DLLTest_DLL.bmx):
- the definition file (DLLTest_DLL.def, bmk did not complain - it might therefore be correct)
- the command to build the library
- the test program (DLLTest.bmx)
This test is a modification of what I found in this forum and by looking into the file "/usr/include/dlfcn.h"
If I start the test, the application crashes and I get the following dump
Does anybody have a clue what is going wrong here?
Thanks in advance for any help!
I'll soon have to decide whether to use BlitzMAX or PureBasic for my developments. The most important aspect will be whether I will be able to produce dynamically loadable libraries for all supported platforms (i.e., DLLs, DyLibs, Shared Objects)
I would really prefer to use BlitzMAX, but
- I managed to build and use a DLL under Windows (XP)
- when I try the same under Mac OS X, the application crashes
- I have not yet tried the same under Linux (as Mac OS X is more important)
Has anybody managed to build DyLibs and Shared Objects?
Here is my approach for Mac OS X:
- the library (DLLTest_DLL.bmx):
strict framework brl.blitz function DoubleIt:int (Value:int) ' GCEnter() return 2*Value end function
- the definition file (DLLTest_DLL.def, bmk did not complain - it might therefore be correct)
EXPORTS DoubleIt=bb_DoubleIt
- the command to build the library
/Applications/BlitzMax/bin/bmk makelib DLLTest_DLL.bmx
- the test program (DLLTest.bmx)
Strict Framework brl.blitz Extern "C" ' see /usr/include/dlfcn.h, POSIX part only function dlclose:byte ptr (Handle:byte ptr) function dlerror$z () function dlopen:byte ptr (Path$z, Mode:int) function dlsym:byte ptr (Handle:byte ptr, Symbol$z) End Extern Const RTLD_LAZY = $01 ' lazy function call binding Const RTLD_NOW = $02 ' immediate function call binding Const RTLD_LOCAL = $04 Const RTLD_GLOBAL = $08 Local Library:Byte Ptr = dlopen("DLLTest_DLL", RTLD_GLOBAL | RTLD_NOW) If (Not Library) Then WriteStdout "Library could not be loaded~n" Throw "library not found" Else WriteStdout "Library loaded~n" End If WriteStdout "dlerror() = " + dlerror() + "~n" Local DoubleIt:Int (Value:Int) DoubleIt = dlsym(Library,"DoubleIt") If (Not DoubleIt) Then WriteStdout "unable to obtain symbol 'DoubleIt'~n" End If WriteStdout "DoubleIt(10) = " + DoubleIt(10) WriteStdout "Yippee!~n" dlclose(Library)
This test is a modification of what I found in this forum and by looking into the file "/usr/include/dlfcn.h"
If I start the test, the application crashes and I get the following dump
Date/Time: 2008-12-04 09:36:14.554 +0100 OS Version: 10.4.11 (Build 8S2167) Report Version: 4 Command: DLLTest.debug Path: /Users/rozek/BlitzMax/DLLTest.debug.app/Contents/MacOS/DLLTest.debug Parent: bmk [463] Version: ??? (???) PID: 472 Thread: 0 Exception: EXC_BAD_ACCESS (0x0001) Codes: KERN_INVALID_ADDRESS (0x0001) at 0x202967f0 Thread 0 Crashed: 0 <<00000000>> 0x202967f0 0 + 539584496 1 DLLTest_DLL 0x00002a34 4 + 25 2 DLLTest_DLL 0x0000241b run + 162 3 com.apple.Foundation 0x927f8237 _nsnote_callback + 230 4 com.apple.CoreFoundation 0x908553d2 __CFXNotificationPost + 345 5 com.apple.CoreFoundation 0x9084cb51 _CFXNotificationPostNotification + 600 6 com.apple.Foundation 0x927f07c8 -[NSNotificationCenter postNotificationName:object:userInfo:] + 121 7 com.apple.Foundation 0x927f7769 -[NSNotificationCenter postNotificationName:object:] + 55 8 com.apple.AppKit 0x93299976 -[NSApplication _postDidFinishNotification] + 124 9 com.apple.AppKit 0x93299860 -[NSApplication _sendFinishLaunchingNotification] + 67 10 com.apple.AppKit 0x9329935d -[NSApplication(NSAppleEventHandling) _handleAEOpen:] + 273 11 com.apple.AppKit 0x93298f28 -[NSApplication(NSAppleEventHandling) _handleCoreEvent:withReplyEvent:] + 96 12 com.apple.Foundation 0x927fdf21 -[NSAppleEventManager dispatchRawAppleEvent:withRawReply:handlerRefCon:] + 447 13 com.apple.Foundation 0x927fdd4b _NSAppleEventManagerGenericHandler + 91 14 com.apple.AE 0x91521fb5 aeDispatchAppleEvent(AEDesc const*, AEDesc*, unsigned long, unsigned char*) + 147 15 com.apple.AE 0x91521ee6 dispatchEventAndSendReply(AEDesc const*, AEDesc*) + 44 16 com.apple.AE 0x91521db2 aeProcessAppleEvent + 190 17 com.apple.HIToolbox 0x92df4084 AEProcessAppleEvent + 37 18 com.apple.AppKit 0x9329711d _DPSNextEvent + 1044 19 com.apple.AppKit 0x93296b37 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 137 20 com.apple.AppKit 0x932908c4 -[NSApplication run] + 512 21 DLLTest_DLL 0x000029f5 main + 1124 22 DLLTest_DLL 0x0000227e _start + 228 (crt.c:272) 23 DLLTest_DLL 0x00002199 start + 41 Thread 0 crashed with X86 Thread State (32-bit): eax: 0x00000000 ebx: 0x00425950 ecx: 0x0000533b edx: 0x0000b060 edi: 0x00000000 esi: 0x0010c7a0 ebp: 0xbfffefb8 esp: 0xbfffef9c ss: 0x0000001f efl: 0x00010246 eip: 0x202967f0 cs: 0x00000017 ds: 0x0000001f es: 0x0000001f fs: 0x00000000 gs: 0x00000037 Binary Images Description: 0x1000 - 0x9fff DLLTest_DLL DLLTest_DLL 0x1000 - 0x9fff DLLTest.debug /Users/rozek/BlitzMax/DLLTest.debug.app/Contents/MacOS/DLLTest.debug 0x205000 - 0x2e3fff libxml2.2.dylib /usr/lib/libxml2.2.dylib 0x8fe00000 - 0x8fe4afff dyld 46.16 /usr/lib/dyld 0x90000000 - 0x90171fff libSystem.B.dylib /usr/lib/libSystem.B.dylib 0x901c1000 - 0x901c3fff libmathCommon.A.dylib /usr/lib/system/libmathCommon.A.dylib 0x901c5000 - 0x90202fff com.apple.CoreText 1.1.3 (???) /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/CoreText.framework/Versions/A/CoreText 0x90229000 - 0x902fefff ATS /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ATS.framework/Versions/A/ATS 0x9031e000 - 0x90773fff com.apple.CoreGraphics 1.258.79 (???) /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/CoreGraphics.framework/Versions/A/CoreGraphics 0x9080a000 - 0x908d2fff com.apple.CoreFoundation 6.4.11 (368.35) /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation 0x90910000 - 0x90910fff com.apple.CoreServices 10.4 (???) /System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices 0x90912000 - 0x90a06fff libicucore.A.dylib /usr/lib/libicucore.A.dylib 0x90a56000 - 0x90ad5fff libobjc.A.dylib /usr/lib/libobjc.A.dylib 0x90afe000 - 0x90b62fff libstdc++.6.dylib /usr/lib/libstdc++.6.dylib 0x90bd1000 - 0x90bd8fff libgcc_s.1.dylib /usr/lib/libgcc_s.1.dylib 0x90bdd000 - 0x90c50fff com.apple.framework.IOKit 1.4.8 (???) /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit 0x90c65000 - 0x90c77fff libauto.dylib /usr/lib/libauto.dylib 0x90c7d000 - 0x90f23fff com.apple.CoreServices.CarbonCore 682.30 /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/CarbonCore.framework/Versions/A/CarbonCore 0x90f66000 - 0x90fcefff com.apple.CoreServices.OSServices 4.1 /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/OSServices.framework/Versions/A/OSServices 0x91007000 - 0x91046fff com.apple.CFNetwork 129.22 (129.23) /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/CFNetwork.framework/Versions/A/CFNetwork 0x91059000 - 0x91069fff com.apple.WebServices 1.1.3 (1.1.0) /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/WebServicesCore.framework/Versions/A/WebServicesCore 0x91074000 - 0x910f3fff com.apple.SearchKit 1.0.8 /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/SearchKit.framework/Versions/A/SearchKit 0x9112d000 - 0x9114bfff com.apple.Metadata 10.4.4 (121.36) /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/Metadata.framework/Versions/A/Metadata 0x91157000 - 0x91165fff libz.1.dylib /usr/lib/libz.1.dylib 0x91168000 - 0x91307fff com.apple.security 4.5.2 (29774) /System/Library/Frameworks/Security.framework/Versions/A/Security 0x91405000 - 0x9140dfff com.apple.DiskArbitration 2.1.2 /System/Library/Frameworks/DiskArbitration.framework/Versions/A/DiskArbitration 0x91414000 - 0x9141bfff libbsm.dylib /usr/lib/libbsm.dylib 0x9141f000 - 0x91445fff com.apple.SystemConfiguration 1.8.6 /System/Library/Frameworks/SystemConfiguration.framework/Versions/A/SystemConfiguration 0x91457000 - 0x914cdfff com.apple.audio.CoreAudio 3.0.5 /System/Library/Frameworks/CoreAudio.framework/Versions/A/CoreAudio 0x9151e000 - 0x9151efff com.apple.ApplicationServices 10.4 (???) /System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices 0x91520000 - 0x9154bfff com.apple.AE 314 (313) /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/AE.framework/Versions/A/AE 0x9155e000 - 0x91632fff com.apple.ColorSync 4.4.11 /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ColorSync.framework/Versions/A/ColorSync 0x9166d000 - 0x916eafff com.apple.print.framework.PrintCore 4.6 (177.13) /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/PrintCore.framework/Versions/A/PrintCore 0x91717000 - 0x917c0fff com.apple.QD 3.10.27 (???) /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/QD.framework/Versions/A/QD 0x917e6000 - 0x91831fff com.apple.HIServices 1.5.2 (???) /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/HIServices.framework/Versions/A/HIServices 0x91850000 - 0x91866fff com.apple.LangAnalysis 1.6.3 /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/LangAnalysis.framework/Versions/A/LangAnalysis 0x91872000 - 0x9188cfff com.apple.FindByContent 1.5 /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/FindByContent.framework/Versions/A/FindByContent 0x91896000 - 0x918d3fff com.apple.LaunchServices 183 /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/LaunchServices 0x918e7000 - 0x918f3fff com.apple.speech.synthesis.framework 3.5 /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/SpeechSynthesis.framework/Versions/A/SpeechSynthesis 0x918fa000 - 0x9193afff com.apple.ImageIO.framework 1.5.8 /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/ImageIO 0x9194d000 - 0x919fffff libcrypto.0.9.7.dylib /usr/lib/libcrypto.0.9.7.dylib 0x91a45000 - 0x91a5bfff libcups.2.dylib /usr/lib/libcups.2.dylib 0x91a60000 - 0x91a7efff libJPEG.dylib /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/Resources/libJPEG.dylib 0x91a83000 - 0x91ae2fff libJP2.dylib /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/Resources/libJP2.dylib 0x91af4000 - 0x91af8fff libGIF.dylib /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/Resources/libGIF.dylib 0x91afa000 - 0x91b82fff libRaw.dylib /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/Resources/libRaw.dylib 0x91b86000 - 0x91ba1fff libPng.dylib /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/Resources/libPng.dylib 0x91ba6000 - 0x91ba8fff libRadiance.dylib /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/Resources/libRadiance.dylib 0x91ca5000 - 0x91ce4fff libTIFF.dylib /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/Resources/libTIFF.dylib 0x91cea000 - 0x91ceafff com.apple.Accelerate 1.3.1 (Accelerate 1.3.1) /System/Library/Frameworks/Accelerate.framework/Versions/A/Accelerate 0x91cec000 - 0x91d7afff com.apple.vImage 2.5 /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vImage.framework/Versions/A/vImage 0x91d81000 - 0x91d81fff com.apple.Accelerate.vecLib 3.3.1 (vecLib 3.3.1) /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/vecLib 0x91d83000 - 0x91ddcfff libvMisc.dylib /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libvMisc.dylib 0x91de5000 - 0x91e09fff libvDSP.dylib /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libvDSP.dylib 0x91e11000 - 0x9221afff libBLAS.dylib /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib 0x92254000 - 0x92608fff libLAPACK.dylib /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libLAPACK.dylib 0x92635000 - 0x92722fff libiconv.2.dylib /usr/lib/libiconv.2.dylib 0x92724000 - 0x927a2fff com.apple.DesktopServices 1.3.7 /System/Library/PrivateFrameworks/DesktopServicesPriv.framework/Versions/A/DesktopServicesPriv 0x927e3000 - 0x92a13fff com.apple.Foundation 6.4.10 (567.37) /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation 0x92b2d000 - 0x92b44fff libGL.dylib /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib 0x92b4f000 - 0x92ba7fff libGLU.dylib /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGLU.dylib 0x92bbb000 - 0x92bbbfff com.apple.Carbon 10.4 (???) /System/Library/Frameworks/Carbon.framework/Versions/A/Carbon 0x92bbd000 - 0x92bcdfff com.apple.ImageCapture 3.0.4 /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/ImageCapture.framework/Versions/A/ImageCapture 0x92bdb000 - 0x92be3fff com.apple.speech.recognition.framework 3.6 /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/SpeechRecognition.framework/Versions/A/SpeechRecognition 0x92be9000 - 0x92beefff com.apple.securityhi 2.0.1 (24742) /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/SecurityHI.framework/Versions/A/SecurityHI 0x92bf4000 - 0x92c85fff com.apple.ink.framework 101.2.1 (71) /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/Ink.framework/Versions/A/Ink 0x92c99000 - 0x92c9cfff com.apple.help 1.0.3 (32.1) /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/Help.framework/Versions/A/Help 0x92c9f000 - 0x92cbdfff com.apple.openscripting 1.2.7 (???) /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/OpenScripting.framework/Versions/A/OpenScripting 0x92ccf000 - 0x92cd5fff com.apple.print.framework.Print 5.1 (192.3) /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/Print.framework/Versions/A/Print 0x92cdb000 - 0x92d3efff com.apple.htmlrendering 66.1 (1.1.3) /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HTMLRendering.framework/Versions/A/HTMLRendering 0x92d62000 - 0x92da3fff com.apple.NavigationServices 3.4.4 (3.4.3) /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/NavigationServices.framework/Versions/A/NavigationServices 0x92dca000 - 0x92dd7fff com.apple.audio.SoundManager 3.9.1 /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/CarbonSound.framework/Versions/A/CarbonSound 0x92dde000 - 0x92de3fff com.apple.CommonPanels 1.2.3 (73) /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/CommonPanels.framework/Versions/A/CommonPanels 0x92de8000 - 0x930ddfff com.apple.HIToolbox 1.4.10 (???) /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/HIToolbox 0x931e3000 - 0x931eefff com.apple.opengl 1.4.16 /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL 0x9327e000 - 0x9327efff com.apple.Cocoa 6.4 (???) /System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa 0x93280000 - 0x93936fff com.apple.AppKit 6.4.10 (824.48) /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit 0x93cb7000 - 0x93d32fff com.apple.CoreData 91 (92.1) /System/Library/Frameworks/CoreData.framework/Versions/A/CoreData 0x93d6b000 - 0x93e24fff com.apple.audio.toolbox.AudioToolbox 1.4.7 /System/Library/Frameworks/AudioToolbox.framework/Versions/A/AudioToolbox 0x93e67000 - 0x93e67fff com.apple.audio.units.AudioUnit 1.4.2 /System/Library/Frameworks/AudioUnit.framework/Versions/A/AudioUnit 0x93e69000 - 0x9402afff com.apple.QuartzCore 1.4.12 /System/Library/Frameworks/QuartzCore.framework/Versions/A/QuartzCore 0x94070000 - 0x940b1fff libsqlite3.0.dylib /usr/lib/libsqlite3.0.dylib 0x940b9000 - 0x940f3fff libGLImage.dylib /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGLImage.dylib 0x940f8000 - 0x9410efff com.apple.CoreVideo 1.4.2 /System/Library/Frameworks/CoreVideo.framework/Versions/A/CoreVideo Model: Macmini1,1, BootROM MM11.0055.B08, 2 processors, Intel Core Duo, 1.66 GHz, 2 GB Graphics: Intel GMA 950, GMA 950, Built-In, spdisplays_integrated_vram Memory Module: BANK 0/DIMM0, 1 GB, DDR2 SDRAM, 667 MHz Memory Module: BANK 1/DIMM1, 1 GB, DDR2 SDRAM, 667 MHz AirPort: spairport_wireless_card_type_airport_extreme (0x168C, 0x86), 1.4.4 Bluetooth: Version 1.9.5f4, 2 service, 0 devices, 1 incoming serial ports Network Service: Ethernet (integriert), Ethernet, en0 Serial ATA Device: ST98823AS, 74.53 GB Parallel ATA Device: MATSHITADVD-R UJ-846 USB Device: Hub, Up to 480 Mb/sec, 500 mA USB Device: Hub in Apple Pro Keyboard, Mitsumi Electric, Up to 12 Mb/sec, 500 mA USB Device: Apple Pro Keyboard, Mitsumi Electric, Up to 12 Mb/sec, 250 mA USB Device: Apple Optical USB Mouse, Mitsumi Electric, Up to 1.5 Mb/sec, 500 mA USB Device: Apple Cinema HD Display, Apple Computer, Inc., Up to 12 Mb/sec, 500 mA USB Device: USB2.0 Hub, Up to 480 Mb/sec, 500 mA USB Device: Mass Storage Device, Generic, Up to 480 Mb/sec, 500 mA USB Device: USB2.0 Hub, Up to 480 Mb/sec, 500 mA USB Device: Bluetooth USB Host Controller, Apple, Inc., Up to 12 Mb/sec, 500 mA USB Device: IR Receiver, Apple Computer, Inc., Up to 12 Mb/sec, 500 mA USB Device: Plantronics Headset, Plantronics, Up to 12 Mb/sec, 500 mA FireWire Device: unknown_device, unknown_value, Up to 400 Mb/sec
Does anybody have a clue what is going wrong here?
Thanks in advance for any help!