W
WW
Markus said:Hi,
Well, I'm still a newbie to C++, so excuse my maybe (probably???)
stupid question...btw, I use gcc 2.95.2.
Here are my (test) funtions:
mainfunc.cpp:
#include <iostream>
using namesapce std;
#include "func1.h" //so it looks in the same dir, right?
int main(){
int a=42;
func1(a); }
func1.cpp:
#include <iostream>
using namesapce std;
#include "func1.h" /* I read you should also include it here... */
void func1(int i) {
cout << i << endl; }
func1.h:
void func1(int i);
My Problem is that when I try to compile it, it gives me an "undefined
reference to 'func1(int)' error and I don't know how to get rid of
it. I tried to put the files everywhere, like in the "include"-folder
or others folders that I set with path.
What is my mistake??? Thank you in advance, I really appreciate it!
You need to LINK func1.o into your executable! Please get a gcc/g++ manual
and read about it. It is _using_ your compiler and not about the language
so - strictly speaking - it is off topic here. Byt I am pretty sure that a
million tutorials exist out there for gcc/g++.