参考:一个解决方案中有两个项目,一个项目调用另一个项目中的函数_一个解决方案中调用另一个项目怎么写-CSDN博客
0.目录情况
解决方案test_diaoyong
项目1:test_diaoyong
test.h
test.cpp
项目2:test2
test2.cpp
test2.cpp调用test.cpp内的函数
test代码
test.h
//test1.h
int fun(int a, int b);
#pragma once
test.cpp
#include <iostream>
#include "test.h"
using namespace std;
int fun(int a, int b)
{
return a + b;
}
test2.cpp
#include <iostream>
#include "test.h"
using namespace std;
void main()
{
cout << fun(2, 3);
}
1.附加目录![](https://i-blog.csdnimg.cn/direct/232c14ba15a349c392a5da03a875b68d.png)
2.生成调用项目的lib
输出目录为生成lib的路径,路径为:C:\Users\16076\source\repos\test_diaoyong\x64\Debug\lib
内容如下: