Я хотел вызвать функцию Greet из другого файла в моем main () , поэтому я создал папку utils , а затем создал 2 файла внутри Greet.cpp и Greet.hpp . Похоже: < /p>
#include "greet.hpp"
#include
void greet(const std::string& name) {
std::cout
Now I got the error, that the linker cannot find the definition of the function but everything looks correct according to the tutorial.
g++.exe C:\Users\arkad\CLionProjects\Beginner\main.cpp -o main
S:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\arkad\AppData\Local\Temp\ccxkaoUw.o:main.cpp:(.text+0x3c): undefined reference to `greet(std::__cxx11::basic_string const&)'
collect2.exe: error: ld returned 1 exit status
Process finished with exit code 1
< /code>
I tried changing greet.cpp
Я хотел вызвать функцию Greet из другого файла в моем main () , поэтому я создал папку utils , а затем создал 2 файла внутри Greet.cpp и Greet.hpp . Похоже: < /p> [code]main.cpp[/code] [code]#include #include "utils/greet.hpp"
void greet(const std::string& name) { std::cout Now I got the error, that the linker cannot find the definition of the function but everything looks correct according to the tutorial. g++.exe C:\Users\arkad\CLionProjects\Beginner\main.cpp -o main S:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\arkad\AppData\Local\Temp\ccxkaoUw.o:main.cpp:(.text+0x3c): undefined reference to `greet(std::__cxx11::basic_string const&)' collect2.exe: error: ld returned 1 exit status
Process finished with exit code 1
< /code> I tried changing greet.cpp[/code] от [code]#include "greet.hpp" #include