Hi Everyone.
I try to translate a small C project to a C++ one. With modifing the .c to .cc and little modifing in the Makefile using g++.
But I have a following error with the structure of the translated c++ project
make
g++ -std=c++17 build/traceroute.o build/assignment3.o libraw/libraw.a -o trace6
build/assignment3.o: In function `main':
Makefile:16: recipe for target 'trace6' failed
/home/jigao/Workspace/Netz_VM/u1824/assignment3/src/assignment3.cc:139: undefined reference to `parse_args(arguments*, int, char**)'
/home/jigao/Workspace/Netz_VM/u1824/assignment3/src/assignment3.cc:145: undefined reference to `grnvs_open(charconst*, int)'
/home/jigao/Workspace/Netz_VM/u1824/assignment3/src/assignment3.cc:154: undefined reference to `grnvs_close(int)'
collect2: error: ld returned 1 exit status
make: *** [trace6] Error 1
Process finished with exit code 2
For example function parse_args(arguments*, int, char**) is already defined in the src/traceroute.cc
This one is shout. Given the error message: /home/jigao/Workspace/Netz_VM/u1824/assignment3/src/assignment3.cc:154: undefined reference to `grnvs_close(int)' . The "154" refers to line 154 of the source code and without the source code it is impossible to tell what is happening.
I believe the problems is not in the make file as most error messages tend to refer to something in the source code.
It sounds like you may be trying to call a function before it has been seen by the compiler and the compiler has nothing to reference to.
@CakeByTheOcean: do a clean build
> For example function parse_args(arguments*, int, char**) is already defined in the src/traceroute.cc
¿are you sure?
my guess is that you keep the old traceroute.o that was compiled with gcc (not g++) so the name mangling is different.
if you can't upload your project, try to reproduce the error in a minimal example