- 论坛徽章:
- 0
|
sco unix下编写动态库
testlib.c代码:
#include <stdio.h>;
void prntHello(){
printf("Hello world!" ;
}
testlib.h代码:
void prntHello();
dlltest.cpp代码:
#include "testlib.h"
main ()
{
prntHello ();
}
1. 产生动态库:
gcc -c testlib.c
ar -q libhello.a testlib.o
2. 调用动态库:
g++ -o aa dlltest.cpp -lhello
错误信息如下:
Undefined first referenced
symbol in file
prntHello(void) /usr/tmp/cc4Wztqg.o
aa: fatal error: Symbol referencing errors. No output written to aa
collect2: ld returned 1 exit status
如果将第一步中的gcc换为g++,则没有问题。 |
|