DeskLib - getting started
Chris (121) 472 posts |
Rather than hijack the other DeskLib thread, which prompted this, I thought I might ask this here: I’ve just attempted to get started with some C programming, and am trying to figure out compiling with GCC. I’m having trouble using the latest version of DeskLib. I’ve got a simple program which I’ve attempted to build with the following:
This doesn’t work, and gives the warning ‘/DeskLib:o/DeskLib: not a directory [enabled by default]’, followed by lots of undefined references to all the DeskLib functions. I’m obviously doing something stupid – any pointers? DeskLib and GCC are the latest versions from riscos.info. Doing all this on RPCEmu, RO 5.22. |
David Pitt (102) 743 posts |
I always preface any C answers that I attempt by saying that C is not something I have ever really got to grips with but I hope the following is of assistance. In the command line above the *gcc task.c -mthrowback -IDeskLib: -lDeskLib:o.DeskLib -o !RunImage Another snag is the do with ELF usage. The latest gcc requires ELF libraries and the version of DeskLib on riscos.info isn’t so I used gcc 3.4.6. |
David Pitt (102) 743 posts |
There is a second DeskLib on riscos.info that does appear to have an ELF DeskLib, but I cannot get it to work with gcc 4.7.4. The header files are of the form name/h rather than in an ‘h’ directory and the DeskLib library DeskLib/a never gets found. |
Steve Pampling (1551) 8172 posts |
I think you will find, among the information for GCC 4.7.4, that it actually says quite explicitly that the old form libraries and header directory layouts are not supported. |
Chris (121) 472 posts |
Thank you! I was tearing my hair out. Both your points seem to be correct. I think I misread the -I and -l switches in the documentation, which won’t have helped. But you’re also right about the ELF issue, and GCC 3.4.6 did the trick. I did have to use the Many thanks again. |
Jeffrey Lee (213) 6048 posts |
Be aware that if you’re planning on releasing your programs, GCC 3.4.6 isn’t a good choice because it won’t produce ARMv7-safe code. 4.1.1 release 2 and above should be fine. For the ELF version of DeskLib, you should be able to rename the files to follow the RISC OS conventions. I have a utility for this, which I’ll upload when I get a chance (I’m sure other people have released utilities for it as well, but I can’t think of any names!) |
David Pitt (102) 743 posts |
I have now persuaded the ELF DeskLib to run with gcc 4.7.4. Having sorted out the header filenaming issue, where the ‘h’ should be, all that was further needed was to prefix the library name with ‘lib’ to become **gcc task.c -IDeskLib: -LDeskLib: -lDeskLib -o !RunImage A comparison with OSLib 7.00 revealed that little gotcha. The DeskLib ELF is not compatible with the SharedCLibrary with loads of these in the error shower, “
Good thinking. I am using OS4.39 VRPC on a Mac for this. Oops. did I say that out loud! |
Steve Pampling (1551) 8172 posts |
Macs can be quite useful. |
Chris (121) 472 posts |
Thanks. At present I’m just getting started, but it sounds like it’d be best to get the latest GCC/DeskLib combo working before trying to get anything ready for a release.
Hmm. That’s just producing an ‘internal error:abort on instruction fetch’ for me. I’ve created an ‘h’ directory in the ‘include’ directory inside !DeskLib, and stripped the ‘/h’ suffix from the files there. I also renamed ‘DeskLib/a’ to ‘libDeskLib/a’. Then tried your command above, using the most recent GCC and the ELF DeskLib. Do I need to do anything else? |
David Pitt (102) 743 posts |
The only other thing is that slot size needs to huge, at least 15MB, but that errors clearly if it is insufficient. I have tried it again on OS5.23 RPCEmu and it’s all good. There has been a fair bit of fumbling around and sundry guessing here but always with understandable errors, never an abort. From an RPCEmu 23MB, no science here just a big handful, TaskWindow, show that right DeskLib has been seen, verify gcc version then go for it. *show desklib* DeskLib$Dir : HostFS:$.SymLinks.local.HD4.Progm.DeskLibELF.!DeskLib DeskLib$Path : DeskLib_User:,DeskLib_Core: DeskLib_Core$Path : HostFS:$.SymLinks.local.HD4.Progm.DeskLibELF.!DeskLib.,HostFS:$.SymLinks.local.HD4.Progm.DeskLibELF.!DeskLib.include.,HostFS:$.SymLinks.local.HD4.Progm.DeskLibELF.!DeskLib.oldinclude. DeskLib_User$Dir : HostFS:$.SymLinks.local.HD4.Progm.DeskLibELF.!DLUser DeskLib_User$Path : HostFS:$.SymLinks.local.HD4.Progm.DeskLibELF.!DLUser.,HostFS:$.SymLinks.local.HD4.Progm.DeskLibELF.!DLUser.include., *gcc --version gcc (GCCSDK GCC 4.7.4 Release 1 Development) 4.7.4 Copyright (C) 2012 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *gcc task.c -IDeskLib: -LDeskLib: -lDeskLib -o !RunImage * Just in case, that is an upper case |
Chris (121) 472 posts |
Well, finally got it working. I think I’d actually given the taskwindow too much memory, such that there was too little left over to to all the other things once compilation got started. 20MB seems like a magic number to coax everything into going OK. Thanks for your help! |