Код: Выделить всё
main.cppКод: Выделить всё
#include
#include "utils/greet.hpp"
int main() {
greet("Arek");
return 0;
}
< /code>
greet.cppКод: Выделить всё
#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Код: Выделить всё
#include "greet.hpp"
#include
using namespace std;
void greet(string name) {
cout
Подробнее здесь: [url]https://stackoverflow.com/questions/79706300/mingw-cant-find-a-function-from-another-file[/url]