如图,初学C++,使用的是Visual Studio 2022,在文件包含.cpp文件中想调用fun1().cpp文件时报错,想请教一下原因,谢谢帮助!
源程序如下:
//*****文件包含.cpp*****
#include
using namespace std;
#include "fun1().cpp"
int main()
{
double a=5,b=8;
fun1(a,b);
return 0;
}
//*****fun1().cpp*****
double fun1(double a,double b)
{
return a*b;
}
删除
#include "fun1().cpp"
main前面加上
extern double fun1(double a,double b);
cpp不需要包含
main函数下面的fun1函数定义(如果有),删除
源码:
TunApplication_base.cc:(.text+0x40c): undefined reference to `vkn::com::Runtime::getInstance()
include/vkn/com/runtime.h
/*!
* \brief Returns an instance of Runtime class
* \return Runtime instance
*/
static Runtime& getInstance();
二进制库:
objdump -D libvkn.a
0000000000002464 <_GLOBAL__sub_I__ZN3vkn3com7Runtime11getInstanceEv>:
2464: a9bf7bfd stp x29, x30, [sp, #-16]!
2468: 910003fd mov x29, sp
246c: 529fffe1 mov w1, #0xffff // #65535
2470: 52800020 mov w0, #0x1 // #1
2474: 97ffff2a bl 211c <_Z41__static_initialization_and_destruction_0ii>
2478: a8c17bfd ldp x29, x30, [sp], #16
247c: d65f03c0 ret