Answer the question
In order to leave comments, you need to log in
Compiling C++ code. What option to specify?
Good day!
When describing the logic of class element-functions in another file with the .cpp extension, 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 `Students::getName()'
main.cpp:(.text+0x1e7): undefined reference to `Students::getLName()'
main.cpp:(.text +0x233): undefined reference to `Students::getBall()'
collect2: error: ld returned 1 exit status
They say you need to specify an option.
As I understand it, the compiler writes that there are no links.
I am using GCC g++.
Who knows a way out of the situation, help.
Thanks in advance
Answer the question
In order to leave comments, you need to log in
Formally, you forgot to tell the compiler that you have not one cpp, but two. The linker does not find the body of the methods, so it swears.
You can simply list all your files to the compiler on the command line.
Better, you need to use the build system. The Makefile is there, that's all.
In fact, you should finally start using ide. ide does all this automatically.
Is there a full text of the command line to run the compiler?
In the simplest case, this is something like
g++ $(CXXFLAGS) -o program$(EXE) main.cpp module1.cp module2.cpp
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question