[m-users.] Can't compile sample programn

Volker Wysk post at volker-wysk.de
Wed Mar 20 22:44:28 AEDT 2019


Am Mittwoch, 20. März 2019, 02:35:39 CET schrieb Julien Fischer:
> As Mark has mentioned, that library is only set up for building using
> mmake.  The  reason you get the above error with mmc --make is that
> there is a chunk of C code (in posix_workarounds.c) that needs to be
> separately compiled into an object file and included in the Mercury
> library and then the corresponding C header file (posix_workarounds.h)
> needs to be installed alongside the header files generated by the
> Mercury compiler.

> If you did want to compile it using mmc --make, then you need to do
> something like the following:
> 
> 1. Compile posix_workaround into an object file.
> 2. Invoke mmc --make with the following options:
> 
>     $ mmc --link-object posix_workarounds.o  \
>           --extra-library-header posix_workarounds.h
>           --make libposix
> 
> Since the POSIX binding only supports C grades, you probably also want
> to prevent mmc --make from attempting to install the library in non-C
> grades.  That can be done by applying an exclusion to the libgrade set.
> 
>     $ mmc --link-object posix_workarounds.o  \
>           --extra-library-header posix_workarounds.h
>           --libgrades-exclude java \
>           --libgrades-exclude csharp \
>           --libgrades-exclude erlang \
>           --make libposix

When the library is set up for building with mmake, I use mmake. That's fine. 
I've built and successfully installed it that way.

But I think you should be able to use it with mmc --make, after it has been 
installed successfully. Isn't it? 

When I do this:

cd /usr/local/src/mercury-srcdist-rotd-2019-03-12/extras/posix
rm hello
LANG=C mmc --make hello --ml posix

I get this:

Making hello
** Error making `hello'.
Mercury/os/posix.select.o: In function `<predicate 
'posix:select.new_fdset_ptr'/3 mode 0>':
posix.select.c:(.text+0x291): undefined reference to `ME_fd_zero'
Mercury/os/posix.select.o: In function `<predicate 'posix:select.fd_zero'/3 
mode 0>':
posix.select.c:(.text+0x2cc): undefined reference to `ME_fd_zero'
Mercury/os/posix.select.o: In function `<predicate 'posix:select.fd_clr'/4 
mode 0>':
posix.select.c:(.text+0x2ff): undefined reference to `ME_fd_clr'
Mercury/os/posix.select.o: In function `<predicate 'posix:select.fd_isset'/5 
mode 0>':
posix.select.c:(.text+0x33f): undefined reference to `ME_fd_isset'
Mercury/os/posix.select.o: In function `<predicate 'posix:select.fd_set'/4 
mode 0>':
posix.select.c:(.text+0x37f): undefined reference to `ME_fd_set'
collect2: error: ld returned 1 exit status

I've tried it with --link-object posix_workarounds.o and --extra-library-
header posix_workarounds.h, like you've written. This works. But I think this 
shouldn't be necessary to specify every time, after the library has been 
correctly installed. Am I right?

Bye
Volker





More information about the users mailing list