【发布时间】:2022-11-28 09:31:37
【问题描述】:
我正在尝试编写一个简单的程序来调用在一对 Header 和 CPP 文件中编写的函数。
我在 Raspberry Pi 3 Model B 和 Geany IDE v1.37.1 上执行此操作。
编译命令:
g++ -Wall -c "%f" -c test.cpp
构建命令:
g++ -Wall -o "%e" "%f" -o test test.cpp
main.cpp:
#include "test.h"
int main()
{
test_function();
return 0;
}
test.h:
#ifndef _test_h_
#define _test_h_
#include <iostream>
void test_function();
#endif
test.cpp:
#include "test.h"
void test_function()
{
std::cout << "hello world";
}
上面的代码可以很好地编译和构建,但是尝试运行它会产生以下错误:
./main: not found
(program exited with code: 127)
也许我把编译和构建命令搞砸了?
感谢您阅读我的帖子,感谢任何指导!
【问题讨论】: