- 论坛徽章:
- 0
|
请教各位高手在SCO5.05环境下,C++的程序里能不能调用C的静态库?
我试了没用成功。以下是我的测试例子
/******tools.c************/
#include <stdio.h>;
#include <stdlib.h>;
#include <time.h>;
#include <sys/times.h>;
#include <sys/select.h>;
void Get_sys_time(char * buftime)
{
struct tm *t;
long tim;
tim=time((long *)0); /*Get current system time*/
t=localtime(&tim);
sprintf(buftime,"%d-%02d-%02d,%02d:%02d:%02d",t->;tm_year+1900,t->;tm_mon+1,t->;tm_mday,t->;tm_hour,t->;tm_min,t->;tm_sec);
}
/**************test1.cpp************/
#include <stdio.h>;
#include <stdlib.h>;
#include <iostream.h>;
#include <time.h>;
#include <sys/times.h>;
#include <sys/select.h>;
extern int Get_sys_time(char * buftime);
int main()
{
char buftime[50]={0};
Get_sys_time(buftime);
cout<<"data="<<buftime<<endl;
}
编译:
cc -c tools.c
CC -dy -o test1 test1.cpp tools.o
系统提示:
Undefined first referenced
symbol in file
Get_sys_time(char*) /tmp/CC.573/test1.o
test1: fatal error: Symbol referencing errors. No output written to test1
我把tools.c 改成tools.cpp,再用CC编译一次就可以用了
这是测试时可以改源程序,但有时我们经常会用到别人提供的.o文件,没有.c是不是就没办法了呢? |
|