Sign in to follow this  
Hop chewer

Header files

Recommended Posts

Hello, I am trying to learn how to use header files but am having trouble. Here is what I have:
#include <iostream>
#include "func1.h"
using namespace std;

int main()
	cout << "This is main.cpp" << endl;
	return 0;

#include "func1.h"
#include <iostream>
using namespace std;

void func1()
	cout << "This is func1." << endl;

#ifndef __FUNC1_H_
#define __FUNC1_H_

void func1();


I get the following error: g++ -o headers main.o -lpthread main.o: In function `main': main.cpp:(.text+0x83): undefined reference to `func1()' collect2: ld returned 1 exit status make: *** [headers] Error 1 I am not sure what I am doing wrong. Thanks.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this