Visual Studio command prompt compile problem

I'm using visual studio c++ express and using the Command Line to Compile a C++ Program. What I typed at the command line was cl main.cpp

The code compiles but I get a linker error. The error is as follows error LNK2019: unresolved external symbol "int_cdec1 add(int,int)" main.exe fatal error LNK1120: 1 unresolved externals

This is the code I'm trying to compile
//main.cpp:
#include <iostream>
#include "add.h"

using namespace std;
int main()
{
cout << "2+3=" << add(2,3) << endl;
return 0;
}

//add.cpp
#include "add.h"

int add(int a, int b) {
return a + b;
}


//add.h
#ifndef ADD_H_INCLUDED
#define ADD_H_INCLUDED

int add(int a, int b) ; /* <-- SEMICOLON */

#endif // ADD_H_INCLUDED
In this line #include "add.h" do I need to include the whole path?
I figured it out.

I have to cl add.cpp main.cpp and that gives me add.exe.
Topic archived. No new replies allowed.