View previous topic :: View next topic |
Author |
Message |
joelcnz
Joined: 23 Feb 2009 Posts: 76
|
Posted: Wed Jun 16, 2010 11:59 pm Post subject: Compiling with DMD2 |
|
|
The new D programming book is being shipped. It's for D2. So I would like to know how to use it with allegro.
Using dmd 2.039
With this code:
Code: |
import allegro.allegro;
void main() {
allegro_init();
}
|
I get:
Quote: |
C:\Jpro\dpro2\small>dmd alleg.d alleg.lib -d
OPTLINK (R) for Win32 Release 8.00.2
Copyright (C) Digital Mars 1989-2009 All rights reserved.
http://www.digitalmars.com/ctg/optlink.html
alleg.obj(alleg)
Error 42: Symbol Undefined _D7allegro7allegro12__ModuleInfoZ
alleg.obj(alleg)
Error 42: Symbol Undefined _D7allegro6system12allegro_initFZi
--- errorlevel 2
|
Any help would be great.
DAllegro is tidy. Just uses one DLL (on Windows). I think I've just used it for a long time. I haven't gotten very far with other media libraries.
I think it's a library thing I'm having trouble with. I've gotten the same problem with a one file source code library. |
|
Back to top |
|
|
michaelp
Joined: 27 Jul 2008 Posts: 114
|
Posted: Thu Jun 17, 2010 1:42 pm Post subject: |
|
|
For you compile, I think you want:
Code: | dmd alleg.d -Lalleg.lib -d |
So that alleg.lib is passed to the linker. |
|
Back to top |
|
|
joelcnz
Joined: 23 Feb 2009 Posts: 76
|
Posted: Fri Jun 18, 2010 6:06 am Post subject: |
|
|
Thanks for the reply.
A little different, this has added:
Quote: | OPTLINK : Warning 9: Unknown Option : NOIALLEG.LIB |
So, still no success. :-\ |
|
Back to top |
|
|
michaelp
Joined: 27 Jul 2008 Posts: 114
|
Posted: Fri Jun 18, 2010 6:11 am Post subject: |
|
|
That says warning; does that mean it still compiled?
Not sure about this, but how about:
Code: | dmd alleg.d -L-lalleg -d |
I don't know if that changes anything. |
|
Back to top |
|
|
joelcnz
Joined: 23 Feb 2009 Posts: 76
|
Posted: Sat Jun 19, 2010 3:58 am Post subject: |
|
|
I get this, with that:
Quote: | OPTLINK : Warning 9: Unknown Option : LALLEG |
I guess there must be away to do it.
I wonder what libraries do work with D2, (D and DMD confuse me, D = language and DMD compiler).
...
This is what I get with a different build tool (http://bitbucket.org/h3r3tic/xfbuild):
Quote: | C:\Jpro\dpro2\small>xfbuild allegtest.d -I\jpro\dmd2\src\ alleg.lib -d +orun
Thread 0: compiling 31 modules
Thread 1: compiling 32 modules
Thread 1: compiling 56 modules
Thread 0: compiling 56 modules
\jpro\dmd2\src\allegro\inline\fmaths_inl.d(25): Error: undefined identifier ERAN
GE
\jpro\dmd2\src\allegro\inline\fmaths_inl.d(30): Error: undefined identifier ERAN
GE
\jpro\dmd2\src\allegro\inline\fmaths_inl.d(57): Error: undefined identifier ERAN
GE
\jpro\dmd2\src\allegro\inline\fmaths_inl.d(61): Error: undefined identifier ERAN
GE
\jpro\dmd2\src\allegro\platform\alwin.d(44): Error: function allegro.base.AL_ID
(char a, char b, char c, char d) is not callable using argument types (char,char
,int,char)
\jpro\dmd2\src\allegro\platform\alwin.d(44): Error: cannot implicitly convert ex
pression (65 + n) of type int to char
\jpro\dmd2\src\allegro\platform\alwin.d(45): Error: function allegro.base.AL_ID
(char a, char b, char c, char d) is not callable using argument types (char,char
,int,char)
\jpro\dmd2\src\allegro\platform\alwin.d(45): Error: cannot implicitly convert ex
pression (65 + n) of type int to char
\jpro\dmd2\src\allegro\platform\alwin.d(46): Error: function allegro.base.AL_ID
(char a, char b, char c, char d) is not callable using argument types (char,char
,int,char)
\jpro\dmd2\src\allegro\platform\alwin.d(46): Error: cannot implicitly convert ex
pression (65 + n) of type int to char
\jpro\dmd2\src\allegro\platform\alwin.d(4: Error: function allegro.base.AL_ID
(char a, char b, char c, char d) is not callable using argument types (char,char
,char,int)
\jpro\dmd2\src\allegro\platform\alwin.d(4: Error: cannot implicitly convert ex
pression (65 + n) of type int to char
Build failed: "dmd @xfbuild.1ce0e00.rsp" returned 1 |
Some guys think it's cool |
|
Back to top |
|
|
torhu
Joined: 30 Mar 2006 Posts: 56
|
Posted: Sun Jun 20, 2010 12:43 pm Post subject: |
|
|
I just uploaded a snapshot that's got better support for the latest DMD 2.x versions. Still need to compile with -d, and allegro_errno is broken.
Let me know how it works out for you, I haven't tested it much.
(The reason you get those linker errors when building with dmd, is that dmd does not compile other files then the ones passed on the command line. So you have to either hand all dallegro files you need to dmd, or use make-lib.bat to create dalleg.lib which you then hand to dmd, which passes it on to the linker. xfbuild automates this by passing all needed dallegro, and other, files to dmd.) |
|
Back to top |
|
|
joelcnz
Joined: 23 Feb 2009 Posts: 76
|
Posted: Sun Jun 20, 2010 4:43 pm Post subject: |
|
|
Thanks for the reply torhu and maintenance.
Glad to see the project is still going.
I'll get back to you if I have trouble, etc.
...
Had some errors that had me stumped, but found 'writefln()' was not allowed any more. Also I have to be-tend to edit a curtain file to avoid undefined symbols compile time errors. Actually, '-clean' with 'bud' compiler tool seems to fix that
A thing though. How do you convert a 'int' to a 'char' variable? Like 'char c = readkey();' (readkey returns an 'int'). |
|
Back to top |
|
|
torhu
Joined: 30 Mar 2006 Posts: 56
|
Posted: Tue Jun 22, 2010 5:50 pm Post subject: |
|
|
Yeah, use writeln() instead when you don't need to use format codes.
I tend to just build with -full to avoid those linker errors. You can prebuild dallegro with make-lib.bat and link with the resulting lib file to speed up the building if full builds are too slow. Remember to use -Xallegro then, so bud won't just build allegro anyway. Also might be an idea to use -Xcore for phobos 2.
To get just the ascii code you could do this:
char c = readkey() & 0xff;
But usually the scancode is easier to work with, see the docs for how to do that.
http://alleg.sourceforge.net/latestdocs/en/alleg006.html#readkey |
|
Back to top |
|
|
joelcnz
Joined: 23 Feb 2009 Posts: 76
|
Posted: Tue Jun 22, 2010 7:23 pm Post subject: |
|
|
Thanks for the reply torhu.
I tried the -Xallegro and -Xcore, but got compile errors sighting in the phobos library.
I would normally put 'writefln();' (or 'writeln();') but that doesn't work with D2, but just small alteration - 'writeln("");'.
I've got a program that has a list of strings that I match up with text from the user. Your trick worked, thanks, (actually 'char c = cast(char)readkey;' works too). An odd thing though, I made my own way to make my single chars lower case, because 'std.string' 'tolower' doesn't seem to work for 'char' types, don't know why they wouldn't have that.
Do you help out at 'allegro.cc' as well? |
|
Back to top |
|
|
torhu
Joined: 30 Mar 2006 Posts: 56
|
Posted: Tue Jun 22, 2010 7:56 pm Post subject: |
|
|
joelcnz wrote: |
I tried the -Xallegro and -Xcore, but got compile errors sighting in the phobos library.
|
Yeah, there's something going on with the phobos build.
joelcnz wrote: |
I've got a program that has a list of strings that I match up with text from the user. Your trick worked, thanks, (actually 'char c = cast(char)readkey;' works too). |
The cast works, but it's a bit uglier and less explicit than the bitmask.
joelcnz wrote: |
An odd thing though, I made my own way to make my single chars lower case, because 'std.string' 'tolower' doesn't seem to work for 'char' types, don't know why they wouldn't have that.
|
There's a tolower in std.ctype that works with ascii chars. And a unicode one in std.uni, but then you should probably use allegro's ureadkey and all that... Too much trouble, probably.
joelcnz wrote: | Do you help out at 'allegro.cc' as well? |
Sure, I read that forum daily. |
|
Back to top |
|
|
torhu
Joined: 30 Mar 2006 Posts: 56
|
Posted: Tue Jun 22, 2010 8:19 pm Post subject: |
|
|
Btw, you might want to use SVN to check out the latest dallegro revision, to get today's bugfixes. At least once your program starts crashing or behaving weirdly. |
|
Back to top |
|
|
joelcnz
Joined: 23 Feb 2009 Posts: 76
|
Posted: Tue Jun 22, 2010 10:34 pm Post subject: |
|
|
I've gotten 'std.ctype' 'tolower' working, just added '& 0xFF', (note: I've started using '& 0xFF' now.
For the SVN, just get the tortus(sp)SVN that has options added to the right click windows menu?
How do you handle memory that 'BITMAP*' and 'SAMPLE*' variables point to? Like I haven't been using 'allegro_exit();' And it seems to build up if you don't destroy it. |
|
Back to top |
|
|
torhu
Joined: 30 Mar 2006 Posts: 56
|
Posted: Wed Jun 23, 2010 12:21 am Post subject: |
|
|
You could use tortoisesvn, sure. But if you're building on the command line anyway, I'd just go with the command line client. In fact, the only reason I have tortoisesvn installed nowadays are the nice green and red folder icons. I don't actually use it the thing.
joelcnz wrote: | How do you handle memory that 'BITMAP*' and 'SAMPLE*' variables point to? Like I haven't been using 'allegro_exit();' And it seems to build up if you don't destroy it. | allegro_exit is called automatically, it's an atexit function. As for the others, you should really start reading the manual, and some of allegro's many examples
Btw, you can actually reply to yourself in this forum, it's not run by Matthew Leverton |
|
Back to top |
|
|
|
|
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
|