+2 votes
by
Good day!
In the description of the logic element functions of a class in another file with rasshireniem .cpp , the compiler issues a message.

main.cpp:(.text+0xa1): undefined reference to `Students::sentName(std::string)'
main.cpp:(.text+0xd0): undefined reference to `Students::sentLName(std::string)'
main.cpp:(.text+0x162): undefined reference to `Students::sentNums(int*)'
main.cpp:(.text+0x182): undefined reference to `Students::sentBall(float)'
main.cpp:(.text+0x194): undefined reference to `Student::getName()'
main.cpp:(.text+0x1e7): undefined reference to `Student::getLName()'
main.cpp:(.text+0x233): undefined reference to `Students::getBall()'
collect2: error: ld returned 1 exit status

Say, you need to specify the option.
As I understand it , the compiler says that there are no links.
Ispolzuyu GCC g++.
Who knows the way out of the situation, help.
Thanks in advance

2 Answers

0 votes
by
 
Best answer
Technically, you forgot to tell the compiler that you do not have one. cpp and two. The linker does not find the body of the methods here and swears.

You can simply list all your files in the compiler command line.

Better, you have to use the build system. The Makefile there, and that's it that's all.

In fact, you should finally begin to use the ide. all the ide does it automatically.
0 votes
by
The full text of the command line compiler there?

In the simplest case is something like
g++ $(CXXFLAGS) -o program$(EXE) main.cpp module1.cp module2.cpp


But in your case, if the project is going from multiple files using the IDE, this can be a more complex problem, such as a linker error in processing function names/medow changed mangharam
...