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 使用C#,asp.net读取Excel文件并保存到Oracle数据库
  • ¥15 C# datagridview 单元格显示进度及值
  • ¥15 thinkphp6配合social login单点登录问题
  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 虚心请教几个问题,小生先有礼了
  • ¥30 截图中的mathematics程序转换成matlab