Actually, this almost worked. So, I need to include the same libraries in both files?
Also, why I had to change this?
#ifndef HEADER_H
#define HEADER_H
Now I get LNK1120 error when I try to use it in another program.
I think I need to do this:
When you build on the Visual Studio command line, you must build the program in two steps. First, run cl /c /EHsc MathFuncsLib.cpp to compile the code and create an object file that's named MathFuncsLib.obj. (The cl command invokes the compiler, Cl.exe, and the /c option specifies compile without linking. For more information, see /c (Compile Without Linking).) Second, run lib MathFuncsLib.obj to link the code and create the static library MathFuncsLib.lib. (The lib command invokes the Library Manager, Lib.exe. For more information, see LIB Reference.)
Now I get LNK1120 error when I try to use it in another program.
my guess is you didn't do this
2.Before you can use the math routines in the static library, you must reference it. To do this, open the shortcut menu for the MyExecRefsLib project in Solution Explorer, and then choose References. In the MyExecRefsLib Property Pages dialog box, expand the Common Properties node, select Framework and References, and then choose the Add New Reference button. For more information about the References dialog box, see Framework and References, Common Properties, <Projectname> Property Pages Dialog Box.
3.The Add Reference dialog box lists the libraries that you can reference. The Projects tab lists the projects in the current solution and any libraries that they contain. On the Projects tab, select the MathFuncsLib check box, and then choose the OK button.
I think I need to do this:
When you build on the Visual Studio command line, you must build the program in two steps. First, run cl /c /EHsc MathFuncsLib.cpp to compile the code and create an object file that's named MathFuncsLib.obj. (The cl command invokes the compiler, Cl.exe, and the /c option specifies compile without linking. For more information, see /c (Compile Without Linking).) Second, run lib MathFuncsLib.obj to link the code and create the static library MathFuncsLib.lib. (The lib command invokes the Library Manager, Lib.exe. For more information, see LIB Reference.)