之前说了如何把自己写的.lib文件卖给别人,现在看看如何在自己的工程中调用自己写的.lib文件. 其实也很简单. 先给出简单的程序:
// myLib.h
#ifndef MY_LIB_HEADER
#define MY_LIB_HEADER
int myMax(int x, int y);
#endif// myLib.cpp
#include "myLib.h"
int myMax(int x, int y)
{
	return x > y ? x : y;
}// newProduct.cpp
#include <stdio.h>
// 以下两个地方用相对路径更好,通用性强
// ..表示上一个目录
#include "..\\myLib\\myLib.h"
#pragma comment(lib, "..\\myLib\\Debug\\myLib.lib")
int main()
{
	int a = 20; 
	int b = 30;
	int c = myMax(a, b);
	printf("%d\n", c);
	return 0;
}
        
       具体的文件及工程的组织为:


明白了.