一个静态链接库调用静态链接库的问题
****第一个静态库:
static1.h
#ifndef STA123123_H
#define STA123123_H
extern "C"
int add(int a,int b);
#endif
static1.cpp
#include <stdio.h>
#include "static1.h"
int add(int a,int b)
{
return a+b;
}
第二个静态库:
static2.h
#ifndef STA55555555_H
#define STA55555555_H
extern "C"
int compute(int a,int b);
#endif
static2.cpp
#include <stdio.h>
#include "static2.h"
#include "static1.h"
int compute(int a,int b)
{
return add(a,b);
}
可执行文件
main.cpp
#include <stdio.h>
#include "static2.h"
int main(int argc, char **argv)
{
int a=3,b=5;
int c=compute(a,b);
return 0;
}
已经在工程属性里面添加好了各自需要的lib文件;
但是main函数运行时报错
static2.cpp:7: undefined reference to `add'
为什么?静态库调用静态库要注意什么问题吗?****