EDIT: I run nm -C unit.o | grep ergebnis
as suggested in the comments and got the following output:
0000000000001210 T ergebnis(std::vector<Student, std::allocator<Student> > const&)
0000000000000350 T ergebnis(std::vector<double, std::allocator<double> > const&)
0000000000000810 T ergebnis(std::vector<std::string, std::allocator<std::string> > const&)
so the overload should exist and is correct, right?
I have a file unit.o given, it's header looks like:
#ifndef unit2b
#define unit2b
#include "student.h"
#include <iostream>
#include <vector>
#include <string>
// Funktionen zur Ueberpruefung der Ergebnisse
// geben zurueck, ob ein Fehler entdeckt wurde
bool ergebnis( const std::vector<double>& feld);
bool ergebnis( const std::vector<std::string>& feld);
bool ergebnis( const std::vector<Student>& feld);
#endif
In my program (sort.cpp) i have three vector's, one of type double, one of type Student, and one of type std::string. I am calling some sort algorithms, and ergebnis(x) for each of that vectors after that. trying to compile with
clang++ -std=c++14 -o prog sort.cpp unit.o student.cpp
i get the following error:
/tmp/sort-cc51a6.o: In function `main':
sort.cpp:(.text+0x548): undefined reference to `ergebnis(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&)'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
i am very new to c++ and don't understand what the problem could be. The interesting part is, that the error only occurs for the ergebnis() call with the std::string type vector - the other two types work fine. The calls in sort.cpp:
std::ifstream ifs1 ("strings.txt", std::ifstream::in);
std::vector<std::string> v1 = {};
einlesen(ifs1, v1);
[...]
if(!(ergebnis(v1)){ ... }
what could the problem be?
EDIT: this is not a duplicate. I read the other question, and tried everything that was suggested in the accepted answer. The problem is also, that i have no access to the source code which unit.o was created of. so please remove the duplicate mark.