一个静态链接库调用静态链接库的问题

****第一个静态库:
static1.h
#ifndef STA123123_H
#define STA123123_H
extern "C"
int add(int a,int b);
#endif

static1.cpp
#include
#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
#include "static2.h"
#include "static1.h"
int compute(int a,int b)

{
return add(a,b);
}

可执行文件
main.cpp
#include
#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'
为什么?静态库调用静态库要注意什么问题吗?****

没见你把两个lib里的函数export啊

静态库要在工程中import导入,不然找不到lib,怎么找到函数实现。

按理说编译静态库的时候C++会自动生成lib和h,将它们导入你的编译路径即可。