Given a main.cpp
file :
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include "inoutfich.h"
using namespace std;
int main()
{
/* chargement du texte en mémoire dans une string */
char n_fichin[80];
cout << "Nom du fichier à copier : " ;
cin >> n_fichin;
vector<string> texte;
ChargeTexte(n_fichin, texte);
// cherche ligne la plus longue
unsigned iPLongue = LigneLaPlusLongue(texte);
cout << "La ligne la plus longue du texte est la ligne " << iPLongue;
cout << "**** " << texte[iPLongue] << " ****";
return 0;
} // main
and a submodule inoutfich.cpp
which works in an other programm.
a submodule header inoutfich.h
such :
#ifndef _INOUTF_H
#define _INOUTF_H
#include <vector>
#include <string>
using namespace std;
void ChargeTexte(char [], vector<string>& );
void EcrireFichier(char [], const vector<string>&);
unsigned short LigneLaPlusLongue(const vector<string>&);
#endif
When I compile
`$g++ main.cpp -o out.o`
I get the following terminal error :
/tmp/ccunCT7N.o: In function `main':
main.cpp:(.text+0x5a): undefined reference to `ChargeTexte(char*, std::vector<std::string, std::allocator<std::string> >&)'
main.cpp:(.text+0x66): undefined reference to `LigneLaPlusLongue(std::vector<std::string, std::allocator<std::string> > const&)'
How to fix it ?