liao5189 2015-03-05 11:40 采纳率: 0%
浏览 1797

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

****第一个静态库:
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'
为什么?静态库调用静态库要注意什么问题吗?****

  • 写回答

3条回答 默认 最新

  • Peter_Wang 2015-03-05 12:20
    关注

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

    评论

报告相同问题?

悬赏问题

  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥30 BC260Y用MQTT向阿里云发布主题消息一直错误
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)