最新版本的GNU-Make http://www.gnu.org/software/make/ 提供了許多高級功能,其中包括許多有用的功能。 (...)的支持動態加載的對象系統,你可以寫 任何語言在自己的分機(可被編譯成 這樣的對象),並加載它提供擴展能力... http://www.gnu.org/software/make/manual/make.html#Loading-ObjectsGNU-make 4.運行「加載動態對象」的示例
我試圖運行下面的簡單例子($(hello string)函數)。它起作用,如果我第一次編譯hello.so。但如果我按照此處提供的示例運行它(使用load
指令)http://www.gnu.org/software/make/manual/make.html#Loading-Objects,則它不起作用。 Make4安裝在當前目錄中。
./Makefile:
all:
echo $(hello world)
load hello.so
hello.so: hello.c
$(CC) -shared -I./include -fPIC -o [email protected] $<
./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;
}
運行示例:
./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.
我如何能與 '負荷' 運行這個例子指令?
僅供參考:我剛剛將我的問題發佈到make-help郵件列表。 – Pierre 2014-08-30 17:06:49
不應該'全部'只取決於'hello.so'? – 2014-08-30 18:36:20
試試'load。/ hello.so';因爲'dlopen'處理沒有'/'的特殊路徑;也'全部'應該取決於'hello.so' – 2014-08-30 18:39:16