[m-users.] Using the. 'Extras' modules, specifically posix

Sean Charles (emacstheviking) objitsu at gmail.com
Wed Apr 21 18:06:09 AEST 2021


Perfect reply Julien, thank you very much indeed.

For the record I have the command:

    mmc --ml posix --mld /usr/local/mercury-rotd-2021-04-15/extras/lib/mercury mwipe.m

Which builds and links without issues and runs just fine, excellent!

As a newcomer (well, second time around user) from SWI Prolog, with an application I want to port, it feels very daunting at the moment as it is such a change of tooling i.e. compiled not REPL based with interactive edit/reload/test cycle.

And manuals… so much to take in, I think mmc might well hold a record for he most command line options ever listed on a man page for a non-builtin command!  :)

Thanks again, I will read those sections of the manual carefully and take notes, I can see now why using `@files` might be useful going forward!

All the best,
Sean.



> On 21 Apr 2021, at 08:16, Julien Fischer <jfischer at opturion.com> wrote:
> 
> 
> Hi Sean,
> 
> On Tue, 20 Apr 2021, Sean Charles (emacstheviking) wrote:
> 
>> I followed the instructions on how to build this library.It installed lots of files into here, for example:
>>     /usr/local/mercury-rotd-2021-04-15/extras/lib/mercury/inc/posix.kill.mh
>> When I try to import it I get an error, it can’t find it. The build
>> process seemed to know where to put it so how do I tell it where to
>> find it, I possibly naively assumed it would be automatic?
> 
> For a library other than standard library, you need to tell the compiler
> that (1) you want to use it and (2) where it is.  How you do that
> depends on which of the Mercury build systems you are using to build
> your program.
> 
> If you're using mmc --make or just building directly using mmc, pass
> the following options to the compiler (as well as any others you
> require):
> 
>   --ml posix --mld /usr/local/mercury-rotd-2021-04-15/extras/lib/mercury
> 
> (Or set the in a Mercury.options file.)
> 
> If you're using mmake to build your program set the following in your
> Mmakefile:
> 
>   EXTRA_LIB_DIRS = /usr/local/mercury-rotd-2021-04-15/extras/lib/mercury
>   EXTRA_LIBRARIES = posix
> 
>> I have —zero— knowledge of Mmake and any command line magic.
> 
> The relevant sections of the Users's guide are "6.2.2 Using installed
> libararies with mmc --make" and "6.3.3. Using libraries with Mmake".
> 
>> Here is my meagre excuse of a program, for educational purposes I wanted to write a little app that could scan the `cwd` for all files ending in
>> `.m` then remove any build files. Yes, I know I can tell it to explicitly use a folder and also I could write a makefile and do `make clean` but
>> then I wouldn’t be learning Mercury would I?
>> :- module mwipe.
>> :- interface.
>> :- import_module io.
>> :- pred main(io::di, io::uo) is det.
>> :- implementation.
>> :- import_module dir, list, posix, string.
>> main(!IO) :-
>>     dir.current_directory(D, !IO),
>>     (   D = ok(Dir),
>>         io.format("looking for crufty files in %s...\n", [s(Dir)], !IO)
>>     ;
>>         D = error(_),
>>         io.format("oops: \n", [], !IO)
>>     ).
>> And the error:
>>     mercury_compile: cannot find `posix.int' in directories .,
>>       /usr/local/mercury-rotd-2021-04-15/lib/mercury/ints
> 
> By default the compiler will only search for library files where the
> standard library is installed (/usr/local/mercury/rotd-2021-04-15/lib in
> your case).  If you want to use libaries installed into
> /usr/loca/mercury-rotd-2021-04-15 you need to tell it to search there.
> 
> Julien.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurylang.org/archives/users/attachments/20210421/d8cc73cd/attachment-0001.html>


More information about the users mailing list