Getting stared with DDE: Make and libraries
Stevyn Gadd (2272) 63 posts |
Hi, I’ve installed DDE from NutPi but haven’t yet managed to compile my first application. Here’s what I’ve done so far: What am I not doing? I suspect the link can’t see the header/object library files? Hopefully I’m close. Also, if I want to install my own library – specifically bringing a library across from the Linux world, do I need to go back to the .c implementation of the library’s binary file and compile that for RISC OS? Many thanks in advance. |
Rick Murray (539) 13840 posts |
The DDE expects:
I’ll do the same, only without scanf as I never remember the syntax. Here, it’s this:
It is saved as “
? With my version, doing that calls the linker automatically and eventually offers me an executable called “Text1”. Are you sure you don’t have “Compile only” ticked?
You mean this:
That’s because the linker can’t find the standard library. What happens is the linker will take your program, then link it with with CLib stubs (to initialise the C program) and any other bits and pieces as necessary to arrive at a proper executable. It knows where your program is, but… In the Link window, you’ll see that it holds the name of your object file. Following that, enter a space character and then
That’s exactly it. However do note that this all gets a bit messy when it comes to a C program built up of multiple source files and libraries. You ought to investigate MakeFiles and AMU (it’s better than Make).
Yes. RISC OS is not able to use Linux style libraries so you will need to port it across from source – but note that RISC OS is very very far from POSIX (refer to another thread today for a brief discussion on “threads”). Having said this, it may be worth looking at the GCCSDK project http://www.riscos.info/index.php/GCC_for_RISC_OS as there are a fair few Linux libraries already ported. |
Chris Mahoney (1684) 2165 posts |
I don’t want to complicate things too much, but “shared makefiles” seem to be ROOL’s recommended way of doing things now. You don’t touch CC directly at all, and rather let AMU (the command-line component of Make) do all the work [Edit: I see that Rick also mentioned this]. When you have multiple source files in your app, this becomes quite a bit easier than manually compiling with CC. Admittedly this requires a bit of initial setup, but it tends to be worth doing. Create your “c” directory and put your helloworld file in there. Then, in your project’s root directory, create a text file called Makefile with: COMPONENT = HelloWorld TARGET = !RunImage OBJS = helloworld CINCLUDES = -IC: include CApp The first line is the name of your app and the second is the name of the resulting binary (absolute) file. The third is a list of all the C files to compile, separated by spaces. Then we include the C libraries, and finally tell AMU that it’s a C app. You can then build by running AMU from a task window, but it can be easier to create a TaskObey file (typically named Mk): Dir <Obey$Dir> WimpSlot -min 1024k amu all |
David Pitt (102) 743 posts |
The “said” file should be named as “helloworld” and placed in the “c” directory. that is |
Steve Pampling (1551) 8170 posts |
If !Builder has been seen everything is correctly set and running a taskobey file as described by Chris, the o directory is created. @Stevyn Dir <Obey$Dir> and the setup cleans old objects out and rebuilds everything. |
Stevyn Gadd (2272) 63 posts |
Thank you all for the excellent help. I’ve now got an application to compile, using Rick’s instructions – although for some reason it isn’t automatically launching the Linker. When I take CC’s object code and drop it manually into Link, then append C:o.stubs, I get a Save As dialogue with a nice RunImage. Having a play with AMU which half-works again, but not all the way to creating the RunImage. I suspect it’s the same problem. I’m going to try and reinstall I think. |
Rick Murray (539) 13840 posts |
Exactly. I like all my nuts and bolts in order and exactly where I put them, not someplace else.
Damn straight. I write my code using Zap and you know how I perform a new build? I press Shift-Ctrl-C. This saves the current source (in the editor) and then kicks the MakeFile to AMU. It isn’t so hard to insert other stuff into the MakeFile, such as deleting CMHG’s object file (means CMHG must be run every time, ensuring the module header contains the correct build date etc). If I want a full build (though it isn’t that common I’d want to perform a clean build), I just open the ‘o’ directory, delete all the object files, then press Sh-Ctrl-C in Zap. |
Chris Mahoney (1684) 2165 posts |
I’ve only ever tried shared makefiles in DDE 25 so I can’t speak for other versions, but Builder isn’t required. So long as SetPaths has been seen then shared makefiles should work.
Personally I avoid doing this; it’s not going to make any practical difference for a tiny app, but will slow things down when you have, say, 20 source files. Cleaning on build will result in all 20 being recompiled every time, even if they haven’t changed. I keep a separate “MkClean” TaskObey file for situations such as when making a backup, but most of the time I just let AMU work out what needs to be rebuilt.
It should go all the way to the RunImage. Can you post the taskwindow output?
I remembered Rick saying that in the past, and tried to choose my words carefully in my earlier post :) |
Steve Pampling (1551) 8170 posts |
Yup, I do that. I was just pointing out the possibility for the quick cleanup. |
Stevyn Gadd (2272) 63 posts |
Here’s what I get taking the AMU route: ram AMU: * ‘all’ not re-made because of errors * * Note – still no !RunImage is being created..AMU doesn’t seem to be seeing the CLib stuff. |
Steve Pampling (1551) 8170 posts |
Have you tried going to line 7, moving to the end of the line and hitting the return key to add a line feed after the code and before what I presume is the end of the file immediately afterward? |
Chris Mahoney (1684) 2165 posts |
That looks to be the issue. Every line in a C program, including the last one, must end with a newline (return) character. |
Stevyn Gadd (2272) 63 posts |
Dismissed that for being too simple! All seems to be working now. Thank you all. |