我已阅读here关于如何在 Linux 上安装 Ndless SDK,我已经尽可能地遵循了,比如通过终端安装软件包:
sudo apt-get install [package]
一切顺利,直到我到达根“make”命令。我按照说明在 ~/Ndless 中进行操作,然后在终端中运行“make”。每次我尝试执行此操作时都会收到此错误:
make -C ndless-sdk
make[1]: Entering directory '/home/pi/Ndless/ndless-sdk'
make -C libsyscalls
make[2]: Entering directory '/home/pi/Ndless/ndless-sdk/libsyscalls'
arm-none-eabi-gcc -mcpu=arm926ej-s -std=c11 -nostdlib -O3 -fPIE -mlong-calls -Wall -Werror -I ../include/ -I ../thirdparty/nspire-io/include/ -D_TINSPIRE -ffunction-sections -fdata-sections -c realpath.c -o realpath.o
realpath.c: In function 'realpath1':
realpath.c:50:12: error: 'PATH_MAX' undeclared (first use in this function)
char left[PATH_MAX], next_token[PATH_MAX];
^
realpath.c:50:12: note: each undeclared identifier is reported only once for each function it appears in
realpath.c:50:23: error: unused variable 'next_token' [-Werror=unused-variable]
char left[PATH_MAX], next_token[PATH_MAX];
^
realpath.c:50:7: error: unused variable 'left' [-Werror=unused-variable]
char left[PATH_MAX], next_token[PATH_MAX];
^
realpath.c: In function 'realpath':
realpath.c:159:25: error: 'PATH_MAX' undeclared (first use in this function)
m = resolved = malloc(PATH_MAX);
^
cc1: all warnings being treated as errors
Makefile:21: recipe for target 'realpath.o' failed
make[2]: *** [realpath.o] Error 1
make[2]: Leaving directory '/home/pi/Ndless/ndless-sdk/libsyscalls'
Makefile:14: recipe for target 'build-libsyscalls' failed
make[1]: *** [build-libsyscalls] Error 2
make[1]: Leaving directory '/home/pi/Ndless/ndless-sdk'
Makefile:19: recipe for target 'build-ndless-sdk' failed
make: *** [build-ndless-sdk] Error 2
此外,我在我的主目录中创建了一个 .bash_profile,并将其添加到其中,如说明所示:
export PATH="/home/pi/Ndless/ndless-sdk/toolchain/install/bin:/home/pi/Ndless/ndless-sdk/bin:${PATH}"
当指令将PATH环境变量显示为粗体时,我上网发现.bashrc是PATH,所以我将上面相同的代码添加到其中。
最后编辑
make[4]: Entering directory '/home/pi/Ndless/ndless/src/tools/MakeSyscalls'
php ./mkSyscalls.php "idc" "../../../../ndless-sdk/include/syscall-addrs.h"
/bin/sh: 1: php: not found
Makefile:9: recipe for target '../../../../ndless-sdk/include/syscall-addrs.h' failed
make[4]: *** [../../../../ndless-sdk/include/syscall-addrs.h] Error 127
make[4]: Leaving directory '/home/pi/Ndless/ndless/src/tools/MakeSyscalls'
Makefile:10: recipe for target 'build-MakeSyscalls' failed
make[3]: *** [build-MakeSyscalls] Error 2
make[3]: Leaving directory '/home/pi/Ndless/ndless/src/tools'
Makefile:9: recipe for target 'build-tools' failed
make[2]: *** [build-tools] Error 2
make[2]: Leaving directory '/home/pi/Ndless/ndless/src'
Makefile:9: recipe for target 'build-src' failed
make[1]: *** [build-src] Error 2
make[1]: Leaving directory '/home/pi/Ndless/ndless'
Makefile:19: recipe for target 'build-ndless' failed
make: *** [build-ndless] Error 2
最佳答案
以下用于更改目录的命令中出现字符串 user 的任何地方,只需将其替换为您在 Linux 中的用户名即可。
更新apt-get
sudo apt-get update
如果失败,请确保您暂时禁用您的 VPN 连接;它对我有用。
安装包
sudo apt-get -y install git && sudo apt-get -y install gcc && sudo apt-get -y install binutils && sudo apt-get -y install libmpfr-dev && sudo apt-get -y install libmpc-dev && sudo apt-get -y install zlib1g-dev && sudo apt-get -y install libboost-program-options-dev && sudo apt-get -y install wget && sudo apt-get -y install texinfo && sudo apt-get -y install python2.7 && sudo apt-get -y install python2.7-dev && sudo apt-get -y install python3 && sudo apt-get -y install python3-dev && sudo apt-get -y install php && sudo apt-get -y install libboost-dev && sudo apt-get -y install build-essential && sudo apt-get -y install gcc-arm-none-eabi && sudo apt-get -y install python
将 Ndless 克隆到家里
git clone --recursive https://github.com/ndless-nspire/Ndless.git
运行构建工具链
cd Ndless/ndless-sdk/toolchain && ./build_toolchain.sh
无限命令路径
export PATH="/home/user/Ndless/ndless-sdk/toolchain/install/bin:/home/user/Ndless/ndless-sdk/bin:${PATH}"
无尽的生成文件
cd /home/user/Ndless && make
所有这些都将花费很长时间(我花了 5 个小时),具体取决于您的硬件和可能的互联网连接。
注意事项
让我们尝试构建这个简单的文件:
// main.cpp
#include <libndls.h>
#include <SDL/SDL.h>
#include <SDL/SDL_config.h>
int main() {
SDL_Surface *screen;
nSDL_Font *font;
SDL_Init(SDL_INIT_VIDEO);
screen = SDL_SetVideoMode(320, 240, has_colors ? 16 : 8, SDL_SWSURFACE);
font = nSDL_LoadFont(NSDL_FONT_TINYTYPE, 29, 43, 61);
SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 255, 0, 0));
nSDL_DrawString(screen, font, 10, 10, "Hello, world! \x1");
SDL_Flip(screen); // update screen
SDL_Delay(3000); // wait for 3 seconds
SDL_Quit(); // get out of SDL screen, returns to normal nspire
return 0;
}
生成 makefile:
nspire-tools new main
然后运行:
make
输出应该是这样的:
user@DESKTOP-6IBLUJD:/mnt/d/NdlessSDK/workspace/cpp/test$ make
nspire-g++ -Wall -W -marm -Os -c main.cpp -o main.o
mkdir -p .
nspire-ld main.o -o main.cpp.elf
genzehn --input main.cpp.elf --output main.cpp.tns.zehn --name "main.cpp"
make-prg main.cpp.tns.zehn main.cpp.tns
rm main.cpp.tns.zehn
我在 WSL 中执行此操作,因此我必须执行 cd cd/mnt
以访问我的主驱动器进行编译。
您也可以尝试在安装了 Ndless 的 Firebird 模拟器中运行它!
如果您向前跳过,并决定在没有完全完成 ./build_toolchain 命令的情况下运行 make(可能是由于错误),那么如果 make 命令失败,请不要感到惊讶。失败的输出将是关于 a
undeclared PATH_MAX
但是,如果您安装了所有必要的包,并成功地完全构建了命令,Ndless 应该可以正常编译和运行。
如果在构建 SDK 时遇到 nspire-gcc: Command not found
,请确保正确设置 PATH
变量。我做了 echo "$PWD"
,它显示了我当前的目录,我将其用于 Ndless 路径。
关于linux - Ndless makefile/make 安装错误linux,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48895299/