-2

I have 3 files in c++

functions.h

void handle_1(std::string line);

functions.c

#include "functions.h"
void handle_1(string line)
{
//do something
}

main.c

#include <iostream>
#include "functions.h"
using namespace std;
int main()
{
    string line;
    getline(cin, line);
    handle_1(line);
}

I am getting the following error-
In function `main':

main1.cpp:(.text+0x116): undefined reference to 'handle_1(std::string)'

collect2: error: ld returned 1 exit status
Vaibhav Bajaj
  • 1,934
  • 16
  • 29
Noober
  • 1,516
  • 4
  • 22
  • 48

1 Answers1

3

Use this:

g++ functions.c main.c -o main
Ryan
  • 14,392
  • 8
  • 62
  • 102