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

Julien Fischer jfischer at opturion.com
Wed Mar 20 12:35:39 AEDT 2019


Hi,

On Tue, 19 Mar 2019, Volker Wysk wrote:

> I've successfully built and installed the posix library. But the example 
> program "hello" can't be built:
>
> In extras/posix:
>
>> mmc  --make libposix
> Making libposix.a
> Making libposix.so

...

>> sudo checkinstall mmc --make --no-libgrade \
> 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
>
> Any hints about what I should try? (I've already read the user manual chapter 
> about libraries).

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

Julien.


More information about the users mailing list