help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

GNU-make 4. Running an example for “Loading Dynamic Objects”


From: Pierre LINDENBAUM
Subject: GNU-make 4. Running an example for “Loading Dynamic Objects”
Date: Sat, 30 Aug 2014 19:02:32 +0200 (CEST)
User-agent: SquirrelMail/1.4.17

(Cross posted on SO: http://stackoverflow.com/questions/25583351 )

Hi all,

I tried to run the simple example below , a $(hello string) function.

It works if I first compile the 'hello.so'. But it doesn't work if I run
it as the example provided here (with a load directive)
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;
    }


>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

running 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 can I run this example with the 'load' directive ?


Thank you,

Pierre






reply via email to

[Prev in Thread] Current Thread [Next in Thread]