So I've been banging my head on this compiler error for the last 2 hours and thought I would post the code here to see if anyone can shed any light on my mistake.
I have stripped out all the irrelevant bits to leave a bare minimal program (shown below) which as far as I can see should compile and run. If I comme but I can't see what is wrongnt out the call to testFunc in main then everything compiles and runs fine. With the call to testFunc in however, I get the following:
$ ./waf -v --run abr-tool
Waf: Entering directory `/home/conor/workspace/msc/AdaptiveIPTV/Software/conor/ns3/ns-3.15/build'
[1665/1822] cxxprogram: build/src/abr-tools/examples/abr-tool.cc.4.o -> build/src/abr-tools/ns3.15-abr-tool-debug
19:04:19 runner ['/usr/bin/g++', '-L/usr/lib', '-lboost_iostreams', '-L/usr/lib', '-lboost_iostreams', '-pthread', 'src/abr-tools/examples/abr-tool.cc.4.o', '-o', '/home/conor/workspace/msc/AdaptiveIPTV/Software/conor/ns3/ns-3.15/build/src/abr-tools/ns3.15-abr-tool-debug', '-Wl,-Bstatic', '-Wl,-Bdynamic', '-Wl,--no-as-needed', '-L.', '-L.', '-L.', '-L.', '-L.', '-L.', '-lns3.15-point-to-point-debug', '-lns3.15-internet-debug', '-lns3.15-mpi-debug', '-lns3.15-bridge-debug', '-lns3.15-network-debug', '-lns3.15-core-debug', '-lrt']
src/abr-tools/examples/abr-tool.cc.4.o: In function `main':
/home/conor/workspace/msc/AdaptiveIPTV/Software/conor/ns3/ns-3.15/build/../src/abr-tools/examples/abr-tool.cc:7: undefined reference to `testFunc()'
collect2: ld returned 1 exit status
As you can see the code below is being built as part of a much larger project, and I am aware that the error may be coming from that build process rather than an issue with my code, but either way I have hit something of a wall in my understanding of what is happening here. I'm learning c++ as I go and to tell the truth I don't feel experienced enough to even just compile this code on its own and be able to say "that should definitely work but it doesn't", which is why I present it like this.
Another couple of points which might be relevant:
I can use macros defined in abr-helper.h from abr-tools.cc, and the problem persists when I put abr-tools.cc in the same folder as abr-helper.h and just use '#include "abr-helper.h"'.
the original error was the same thing, but for a bunch of other stuff defined in abr-helper.h and use in abr-tools.cc
I would appreciate any help you folks can offer, thanks in advance.
abr-helper.h:
#ifndef ABR_HELPER_H
#define ABR_HELPER_H
#include <iostream>
void testFunc();
#endif /* ABR_HELPER_H */
abr-helper.cc:
#include <iostream>
#include "abr-helper.h"
void testFunc(){
std::cout << "this is all testFunc() does ..." << std::endl;
}
abr-tool.cc:
#include <iostream>
#include "ns3/abr-helper.h"
int main (int argc, char *argv[]){
std::cout << "in main()" << std::endl;
testFunc();
return 0;
}