FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Derelict2 in Xcode with "D for XCode"-problem?
Goto page 1, 2, 3  Next
 
Post new topic   Reply to topic     Forum Index -> Derelict
View previous topic :: View next topic  
Author Message
heywood



Joined: 18 Jun 2010
Posts: 2

PostPosted: Fri Jun 18, 2010 6:10 pm    Post subject: Derelict2 in Xcode with "D for XCode"-problem? Reply with quote

Hi!

I've just started playing around with D today and I thought getting an OpenGL cube up and spinning would be cool : ) Unfortunately I'm not very experienced with "real" programming, ie building and compiling etc., so I'm afraid my problem might be more about me than anything else... erh.

Anyway, I've downloaded "D for XCode" which installed DMD 2.047 and added a D-command line tool-template to XCode. Nice.

So I've created a new D-project and Hello World compiles and runs! Yey! What I thought I'd do next was I'd simply import all the module-files from Derelict2 into my project and simply let XCode compile them. So I've got Derelict2 with svn and then dragged out all the source-files (*.d) into a project (I can hear you *rolling your eyes*) and imported them. I still kept the folder-hierarchy dictated by the modules. Ie everything is in derelict/xxxx/xxx.d.

Now, to my great surprise, the following packages compiled without errors: devil, fmod, freetype, ode, ogg, openal, portaudio, sfml and util. Cool, and I don't even know what some of them do Smile (Of course, I realize these are only bindings. Getting them to talk to the actual libraries will be another adventure.)

But, the following libraries gave me errors: opengl and SDL. Bummer!

When trying to build OpenGL I get:

Code:

extloader.d(603): Error: undefined identifier loadGLSymbol

gl.d(870): Error: function derelict.opengl.cgl.loadPlatformGL (void delegate(void**, string) bindFunc) is not callable using argument types (void delegate(void** ptr, string funcName, bool doThrow = true))

/gl.d(870): Error: cannot implicitly convert expression (&this.bindFunc) of type void delegate(void** ptr, string funcName, bool doThrow = true) to void delegate(void**, string)


And when trying to build SDL I get the following:

Code:

macinit/DerelictSDLMacLoader.d:50:0 function derelict.sdl.macinit.CoreFoundation.load (void delegate(void**, string) bindFunc) is not callable using argument types (void delegate(void** ptr, string funcName, bool doThrow = true))

macinit/DerelictSDLMacLoader.d:50:0 cannot implicitly convert expression (&this.bindFunc) of type void delegate(void** ptr, string funcName, bool doThrow = true) to void delegate(void**, string)

macinit/DerelictSDLMacLoader.d:51:0 function derelict.sdl.macinit.NSZone.load (void delegate(void**, string) bindFunc) is not callable using argument types (void delegate(void** ptr, string funcName, bool doThrow = true))

macinit/DerelictSDLMacLoader.d:51:0 cannot implicitly convert expression (&this.bindFunc) of type void delegate(void** ptr, string funcName, bool doThrow = true) to void delegate(void**, string)

macinit/DerelictSDLMacLoader.d:52:0 function derelict.sdl.macinit.runtime.load (void delegate(void**, string) bindFunc) is not callable using argument types (void delegate(void** ptr, string funcName, bool doThrow = true))

macinit/DerelictSDLMacLoader.d:52:0 cannot implicitly convert expression (&this.bindFunc) of type void delegate(void** ptr, string funcName, bool doThrow = true) to void delegate(void**, string)

macinit/runtime.d(189): Error: cannot implicitly convert expression (cast(immutable(char)*)theSelector) of type immutable(char)* to char*
macinit/runtime.d(66): Error: template instance derelict.sdl.macinit.runtime.objc_msgSend!() error instantiating

macinit/runtime.d(189): Error: cannot implicitly convert expression (cast(immutable(char)*)theSelector) of type immutable(char)* to char*
macinit/runtime.d(58): Error: template instance derelict.sdl.macinit.runtime.objc_msgSend!() error instantiating

macinit/runtime.d(189): Error: cannot implicitly convert expression (cast(immutable(char)*)theSelector) of type immutable(char)* to char*
macinit/runtime.d(57): Error: template instance derelict.sdl.macinit.runtime.objc_msgSend!() error instantiating

macinit/runtime.d(189): Error: cannot implicitly convert expression (cast(immutable(char)*)theSelector) of type immutable(char)* to char*
macinit/runtime.d(57): Error: template instance derelict.sdl.macinit.runtime.objc_msgSend!() error instantiating

macinit/runtime.d(189): Error: cannot implicitly convert expression (cast(immutable(char)*)theSelector) of type immutable(char)* to char*
macinit/runtime.d(57): Error: template instance derelict.sdl.macinit.runtime.objc_msgSend!() error instantiating

macinit/runtime.d(189): Error: cannot implicitly convert expression (cast(immutable(char)*)theSelector) of type immutable(char)* to char*
macinit/runtime.d(60): Error: template instance derelict.sdl.macinit.runtime.objc_msgSend!() error instantiating

macinit/runtime.d(189): Error: cannot implicitly convert expression (cast(immutable(char)*)theSelector) of type immutable(char)* to char*
macinit/runtime.d(60): Error: template instance derelict.sdl.macinit.runtime.objc_msgSend!() error instantiating

macinit/runtime.d(189): Error: cannot implicitly convert expression (cast(immutable(char)*)theSelector) of type immutable(char)* to char*
macinit/runtime.d(57): Error: template instance derelict.sdl.macinit.runtime.objc_msgSend!() error instantiating


macinit/runtime.d(189): Error: cannot implicitly convert expression (cast(immutable(char)*)theSelector) of type immutable(char)* to char*
macinit/runtime.d(56): Error: template instance derelict.sdl.macinit.runtime.objc_msgSend!() error instantiating

macinit/runtime.d(189): Error: cannot implicitly convert expression (cast(immutable(char)*)theSelector) of type immutable(char)* to char*
macinit/runtime.d(58): Error: template instance derelict.sdl.macinit.runtime.objc_msgSend!() error instantiating

macinit/runtime.d(189): Error: cannot implicitly convert expression (cast(immutable(char)*)theSelector) of type immutable(char)* to char*
macinit/runtime.d(69): Error: template instance derelict.sdl.macinit.runtime.objc_msgSend!() error instantiating

macinit/SDLMain.d(103): Error: function derelict.sdl.macinit.SDLMain.load (void delegate(void**, string) bindFunc) is not callable using argument types (void delegate(void** ptr, string funcName, bool doThrow = true))

macinit/SDLMain.d(103): Error: cannot implicitly convert expression (&DerelictSDLMac.bindFunc) of type void delegate(void** ptr, string funcName, bool doThrow = true) to void delegate(void**, string)

macinit/SDLMain.d(124): Error: cannot implicitly convert expression (cast(immutable(char)*)sel_terminate) of type immutable(char)* to char*


macinit/runtime.d(100): Error: template instance derelict.sdl.macinit.runtime.objc_getClass!("NSApplication") error instantiating



And this is where my knowledge about things come to a disheartening end : /
The only thing I can see is that seems to be a Mac-specific issue, at least with SDL?
Is there anyone who can shed some light into this? What can/should I do? Should this even work?
(I know there's this DSSS-thing, I'd rather build it inside XCode if possible. Maybe I'm overdoing it.)



BR
/heywood
Back to top
View user's profile Send private message
aldacron



Joined: 05 May 2004
Posts: 1322
Location: Seoul, South Korea

PostPosted: Sat Jun 19, 2010 2:16 am    Post subject: Reply with quote

This is the result of my not having a Mac to develop on. The Mac SDL stuff needs to be updated to work with D2 and the new loader. And the OpenGL loader needs to be fully implemented (it's currently incomplete). For now, I have to rely on patches from users for this sort of thing. So unless someone steps forward, there's not much I can do other than blindly make changes and hope they compile.
_________________
The One With D | The One With Aldacron | D Bits
Back to top
View user's profile Send private message Send e-mail
doob



Joined: 06 Jan 2007
Posts: 367

PostPosted: Sat Jun 19, 2010 4:54 am    Post subject: Reply with quote

I'll have a look at this. I've actually not tested derelict with D2.
Back to top
View user's profile Send private message
heywood



Joined: 18 Jun 2010
Posts: 2

PostPosted: Sat Jun 19, 2010 7:39 am    Post subject: Reply with quote

Hi!, ok, thank your for the information!

And to anyone working on this: yey!! Thanks!!

Well, anyway, how things played out is I sat all night playing around. The lure of having a spinning cube in D was simply to big : ) I eventually did get the SDL to compile : D don't ask how I did it because I essentially hacked away at it with an axe. But, once I hooked up the actual SDL-lib it crashes big time. It crashes with:

Code:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[NSApplication sharedApplication]: unrecognized selector sent to class 0xa06ca8a0'


Now here is where I quit and switched strategy. I realized D can make C-calls, and, Objective-C can make C-calls, and D can receive C-calls! So I've been playing around with some really simple sample OpenGL-code from Apple, and simpy added hooks like _render() in Cocoa, and then making extern (C) _render-functions in D that takes over. Works like a charm! (Of course, this doesn't include Derelict anymore :/ ) But I got a spinning triangle! In D! Soon to be a cube...

But, I'm now looking back on the Derelict2-changes I made and although I think simply giving them out as a patch (which I have no idea of how to do anyway) is pointless (because I made changes that I don't know what they do, like removing '.ptr' and adding cast(char*) etc.) I however can give a brief summary of the problems I encountered:

Code:

macinit/DerelictSDLMacLoader.d:50:0 function derelict.sdl.macinit.CoreFoundation.load (void delegate(void**, string) bindFunc) is not callable using argument types (void delegate(void** ptr, string funcName, bool doThrow = true))


Here I found I needed to change the accepted parameter to a series of functions called "load". Here's one of those functions in CoreFoundation:

Code:

//before
void load (void delegate(void**, string) bindFunc)
//after
void load (void delegate(void**, string, bool doThrow = true) bindFunc)



Code:

macinit/runtime.d(189): Error: cannot implicitly convert expression (cast(immutable(char)*)theSelector) of type immutable(char)* to char*


These were hell. Seems like in a lot of places a 'const' has been declared, sometimes in a C-functions, and then somewhere in a chain of calls a variable is passed by pointer, like "selector.ptr". The changes I made here that finally made it compile is a blur. I removed and added 'const' here and there, I added cast(SEL) here and there, etc. etc.--and everytime I made a change some other error popped up somwhere else--Specifically I created a copy of a function:

Code:

//copy of 'objc_msgSend' but with 'const' theReceiver
id objc_msgSendImmutable (ARGS...)(const id theReceiver, string theSelector, ARGS args)


And then used that instead in places, which helped a lot. But like I said, it's a blur. (Later I read the D docs, you gotta do that sooner or later, don't you? and found an interesting attribute called 'inout'. I have a feeling maybe that could be a solution in places. I don' t know.)

Well. I'm not sure what to do here. Now I know these are just maintenance problems, I feel I can/should take a step back : )

(As a side note, I can recommed a nice piece of sample code from Apple that shows how to switch between fullscreen and windowed mode on OS X 10.6 (and 10.5). I'm not sure how they do it, but the swiching is really fast! I mean like instant! http://developer.apple.com/mac/library/samplecode/GLFullScreen/Introduction/Intro.html Otherwise I always get the impression switching to/from fullscreen has a small delay associated with it. I'm just trying to be of some use : )

BR
/heywood
Back to top
View user's profile Send private message
doob



Joined: 06 Jan 2007
Posts: 367

PostPosted: Sun Jun 20, 2010 6:45 am    Post subject: Reply with quote

I've fixed all the compile errors and ported it to D2. It works using D1 and Tango but using D2 I get "Memory allocation failed" as soon as I import SDL. Any ideas?
Back to top
View user's profile Send private message
aldacron



Joined: 05 May 2004
Posts: 1322
Location: Seoul, South Korea

PostPosted: Mon Jun 21, 2010 5:37 am    Post subject: Reply with quote

That's a definite puzzler. I've never seen that error anywhere with D.
_________________
The One With D | The One With Aldacron | D Bits
Back to top
View user's profile Send private message Send e-mail
doob



Joined: 06 Jan 2007
Posts: 367

PostPosted: Tue Jun 22, 2010 4:57 am    Post subject: Reply with quote

BTW I tried to remove all the code in the module constructors both in macinit and in sdl, but that didn't help.
Back to top
View user's profile Send private message
aldacron



Joined: 05 May 2004
Posts: 1322
Location: Seoul, South Korea

PostPosted: Tue Jun 22, 2010 5:47 am    Post subject: Reply with quote

I would assume that it's got to be something with the Mac-specific modules. The SDL code itself has shown no problems on Linux or Windows with D2. The Mac stuff has obviously not been tested with D2 before now.
_________________
The One With D | The One With Aldacron | D Bits
Back to top
View user's profile Send private message Send e-mail
doob



Joined: 06 Jan 2007
Posts: 367

PostPosted: Wed Jun 23, 2010 4:27 am    Post subject: Reply with quote

Yes but I removed all the macinit stuff (the code from the module constructors) and I still got the error.
Back to top
View user's profile Send private message
doob



Joined: 06 Jan 2007
Posts: 367

PostPosted: Sun Jun 27, 2010 3:14 am    Post subject: Reply with quote

I've committed the changes I've made, changeset 486. Apparently it didn't compile with D1 and Tango so I fixed that. But the error is still there when using D2.
Back to top
View user's profile Send private message
aldacron



Joined: 05 May 2004
Posts: 1322
Location: Seoul, South Korea

PostPosted: Sun Jun 27, 2010 5:27 am    Post subject: Reply with quote

Thanks, doob!
_________________
The One With D | The One With Aldacron | D Bits
Back to top
View user's profile Send private message Send e-mail
jaysistar



Joined: 30 Jun 2010
Posts: 31

PostPosted: Thu Jul 22, 2010 2:11 pm    Post subject: Reply with quote

doob wrote:
I've fixed all the compile errors and ported it to D2. It works using D1 and Tango but using D2 I get "Memory allocation failed" as soon as I import SDL. Any ideas?


I have this problem as well. It works fine on Windows and Linux, but not on Mac OS X.

I did find this (/usr/local/lib):
Code:

$ grep "Memory allocation failed" *
Binary file libdruntime.a matches
Binary file libphobos2.a matches


...so I looked at the source (/Library/Compilers/dmd2/src) and found this:

Code:

$ grep -r "Memory allocation failed" *
druntime/import/core/exception.di:super("Memory allocation failed",file,line);
druntime/import/core/exception.di:return msg ? super.toString() : "Memory allocation failed";
druntime/src/core/exception.d:        super( "Memory allocation failed", file, line );
druntime/src/core/exception.d:        return msg ? super.toString() : "Memory allocation failed";


Unfortunately I haven't had time to look at it further.

Also, the following files:

CoreFoundation.di
DerelictSDLMacLoader.di
ID.di
MacTypes.di
NSApplication.di
NSArray.di
NSAutoreleasePool.di
NSDictionary.di
NSEnumerator.di
NSEvent.di
NSGeometry.di
NSMenu.di
NSMenuItem.di
NSNotification.di
NSObject.di
NSProcessInfo.di
NSString.di
NSZone.di
SDLMain.di
runtime.di
selectors.di
string.di

...only on Mac OS X do not get output to derilect/sdl/macinit, they're just in derelect/sdl, which causes problems.

Actually, I haven't verified that it outputs correctly on Windows and Linux, but I assume that it does because my test apps work on those platforms, while they fail to compile only on OSX. I can manually move those .di files to a new macinit directory inside derilect/sdl, and then it compiles correctly, but still suffers from the "Memory allocation failed" problem.
Back to top
View user's profile Send private message
doob



Joined: 06 Jan 2007
Posts: 367

PostPosted: Fri Jul 23, 2010 2:57 am    Post subject: Reply with quote

aldacron: can you have a look at why the macinit imports don't end up in the right folder, I'm not good with makefiles, ticket #59.
Back to top
View user's profile Send private message
doob



Joined: 06 Jan 2007
Posts: 367

PostPosted: Fri Jul 23, 2010 3:01 am    Post subject: Reply with quote

jaysistar wrote:

I have this problem as well. It works fine on Windows and Linux, but not on Mac OS X.

I did find this (/usr/local/lib):
Code:

$ grep "Memory allocation failed" *
Binary file libdruntime.a matches
Binary file libphobos2.a matches


...so I looked at the source (/Library/Compilers/dmd2/src) and found this:

Code:

$ grep -r "Memory allocation failed" *
druntime/import/core/exception.di:super("Memory allocation failed",file,line);
druntime/import/core/exception.di:return msg ? super.toString() : "Memory allocation failed";
druntime/src/core/exception.d:        super( "Memory allocation failed", file, line );
druntime/src/core/exception.d:        return msg ? super.toString() : "Memory allocation failed";


Unfortunately I haven't had time to look at it further.


I wonder why it doesn't print the line and file number, is it because of the toString method?

jaysistar wrote:

Actually, I haven't verified that it outputs correctly on Windows and Linux, but I assume that it does because my test apps work on those platforms, while they fail to compile only on OSX. I can manually move those .di files to a new macinit directory inside derilect/sdl, and then it compiles correctly, but still suffers from the "Memory allocation failed" problem.


It works on Windows and Linux because the macinit files are specific to Mac OS X. I've filed ticket #59, I hope aldacron can fix it, I'm not good with makefiles.
Back to top
View user's profile Send private message
aldacron



Joined: 05 May 2004
Posts: 1322
Location: Seoul, South Korea

PostPosted: Fri Jul 23, 2010 8:40 am    Post subject: Reply with quote

doob wrote:
aldacron: can you have a look at why the macinit imports don't end up in the right folder, I'm not good with makefiles, ticket #59.


Unfortunately, this seems to be a limitation in DMD's handling of the -Hd flag, which is used to specify an output directory for headers. All files being compiled are deposited in that directory without taking the package hierarchy into consideration. If you examine the existing makefiles, you'll see that I've had to specify the proper directory for in each package's makefile. In order for the macinit files to be in the proper folder, they need to be compiled separately from the other SDL files, and the proper directory given to DMD.

But that's just a needless workaround. Perhaps this should be a bug report for DMD?
_________________
The One With D | The One With Aldacron | D Bits
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Derelict All times are GMT - 6 Hours
Goto page 1, 2, 3  Next
Page 1 of 3

 
Jump to:  
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 vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group