GNU-make 4. Running the example for "Loading dynamic objects"

The latest version of GNU-Make http://www.gnu.org/software/make/ provides many advanced features, including many useful features. (...) On systems that support dynamically loaded objects, you can write your own extension in any language (which can be compiled into such an object) and download it to provide advanced features ... http://www.gnu.org/ software / make / manual / make.html # Loading-Objects

I tried to run a simple example below (function $ (hello string)). It works if I compile hello.so first. But this will not work if I run it as an example given here (with a directive load) http://www.gnu.org/software/make/manual/make.html#Loading-Objects . Make4 is installed in the current directory.

./Makefile:

all:
    echo $(hello world)

load hello.so

hello.so: hello.c
    $(CC) -shared -I./include -fPIC -o $@ $<

./hello.c:

#include <stdlib.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>

#include <gnumake.h>

int plugin_is_GPL_compatible;

char * hello(const char *nm, unsigned int argc, char **argv)
    {
    int len = strlen (argv[0]) + 7;
    char *buf = gmk_alloc (len);
    sprintf(buf,"Hello %s",argv[0]);
    return buf;
    }

int hello_gmk_setup ()
    {
    gmk_add_function("hello", hello, 1, 1, 1);
    return 1;
    }

follow the example:

 ./bin/make -v
GNU Make 4.0
Built for i686-pc-linux-gnu

$ ./bin/make 
Makefile:4: hello.so: cannot open shared object file: No such file or directory
Makefile:4: *** hello.so: failed to load.  Stop.

How to run this example using the 'load' directive?

+4
source share
1 answer

I suggest using in the comments

-load hello.so

instead load hello.so; this is analog use -includein Makefile.

, make, , , make, ( make, , $(MAKE) -C subdir toplevel Makefile , , $(MAKE) -C subdir)

hello.so -load hello.so, GNU make . ( , ).

, make, , Makefile, load - .

, Guile make , .

+2

All Articles