各位大侠,请关注一下动态连接库的问题

我希望我的程序能调用我自己的动连接库(在我的固定目录下),可是为什么生成的可执行文件总提示不能打开我的动态库呢?为什么编译的时候不提示错误呢?同样的功能我已经用静态库实现了。下面是我的程序,高手们,帮菜鸟看看吧?

//myprog.h
#include

 1<stdio.h>   
 2#define TESTOK 1   
 3  
 4// myprog.c   
 5#include "myprog.h"   
 6#include <stdlib.h>   
 7void main()   
 8{   
 9int argc;   
10scanf("%d",&amp;argc);   
11if(TestInput(argc)==TESTOK)   
12printf("The Value '%d'\tis Even Number\n",argc);   
13else   
14printf("The Value '%d'\tis Odd Number\n",argc);   
15  
16if(TestSU(argc)==TESTOK)   
17printf("The Value '%d'\tis SU Number\n",argc);   
18else   
19printf("The Value '%d'\tis NOT SU Number\n",argc);   
20  
21}   
22  
23//myfunc1.c………………判断奇偶性   
24#include "myprog.h"   
25int TestInput(int ValueInput)   
26{   
27if(ValueInput%2==0)   
28return(TESTOK);   
29else   
30return(!TESTOK);   
31}   
32  
33  
34  
35//myfunc2.c…………判断是否为素数   
36#include "myprog.h"   
37int TestSU(int ValueInput)   
38{ int i;   
39  
40for(i=2;i&lt;=ValueInput/2;i++)   
41if (ValueInput%i==0)   
42return(!TESTOK);   
43return(TESTOK);   
44}   
45  
46//mkdll.mk…………生成动态链接库   
47DLL=./libtest.so   
48  
49$(DLL):: myfunc1.c myfunc2.c   
50$(CC) -K pic -G -b elf -o $(DLL) myfunc1.c myfunc2.c   
51rm *.o   
52  
53//makefile………………调用libtest.so来编译   
54DLLDRV=./   
55myprog : myprog.o   
56$(CC) -L $(DLLDRV) -Bdynamic -o $@ $? -l test   
57rm $?   
58myprog.o :myprog.c myprog.h   
59  
60\---------------------------------------------------------------   
61  
62叫动态库编译当然不会报错,ft,看看env的LD_LIBRARY_PATH有没有指向你dll的路径</stdlib.h></stdio.h>
Published At
Categories with 服务器类
Tagged with
comments powered by Disqus