SDL 测试程序 - "No such file or directory"
Test program for SDL - "No such file or directory"
我搜索了但找不到与我类似的问题。感谢您的帮助!
我在 Mac.
上的代码块中使用 SDL
我按照这个教程安装了SDL:
https://www.youtube.com/watch?v=Bi9BPEwEMDU&t=5s
下面是我根据视频在 C::B 中设置编译器和链接器的方法:
编译器设置:
+Search directories+
/usr/local/Cellar/sdl2/2.0.5/include/SDL2
+Linker+
/usr/local/lib
链接器设置
+Link Libraires+
/usr/local/lib/libSDL2_test.a
/usr/local/lib/libSDL2-2.0.0.dylib
/usr/local/lib/libSDL2.a
/usr/local/lib/libSDL2main.a
测试程序构建,但终端 window 状态:
~ Buckwheat$ /Applications/CodeBlocks.app/Contents/MacOS/cb_console_runner DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:. /Users/Buckwheat/Documents/Code Blocks Projects/o/bin/Debug/o
sh: /Users/Buckwheat/Documents/Code: No such file or directory
Process returned 127 (0x7F) execution time : 0.002 s
这里是测试程序:
// Example program:
// Using SDL2 to create an application window
#include "SDL.h"
#include <stdio.h>
int main(int argc, char* argv[]) {
SDL_Window *window; // Declare a pointer
SDL_Init(SDL_INIT_VIDEO); // Initialize SDL2
// Create an application window with the following settings:
window = SDL_CreateWindow(
"An SDL2 window", // window title
SDL_WINDOWPOS_UNDEFINED, // initial x position
SDL_WINDOWPOS_UNDEFINED, // initial y position
640, // width, in pixels
480, // height, in pixels
SDL_WINDOW_OPENGL // flags - see below
);
// Check that the window was successfully created
if (window == NULL) {
// In the case that the window could not be made...
printf("Could not create window: %s\n", SDL_GetError());
return 1;
}
// The window is open: could enter program loop here (see SDL_PollEvent())
SDL_Delay(3000); // Pause execution for 3000 milliseconds, for example
// Close and destroy the window
SDL_DestroyWindow(window);
// Clean up
SDL_Quit();
return 0;
}
您的路径包含 spaces :
/Users/Buckwheat/Documents/Code Blocks Projects/o/bin/Debug/o
并且您的 shell 将 space 之前的路径部分作为一个单独的参数:
sh: /Users/Buckwheat/Documents/Code: No such file or directory
你必须像这样转义 spaces 个字符:
/Users/Buckwheat/Documents/Code\ Blocks\ Projects/o/bin/Debug/o
我搜索了但找不到与我类似的问题。感谢您的帮助!
我在 Mac.
上的代码块中使用 SDL我按照这个教程安装了SDL: https://www.youtube.com/watch?v=Bi9BPEwEMDU&t=5s
下面是我根据视频在 C::B 中设置编译器和链接器的方法:
编译器设置:
+Search directories+
/usr/local/Cellar/sdl2/2.0.5/include/SDL2
+Linker+
/usr/local/lib
链接器设置
+Link Libraires+
/usr/local/lib/libSDL2_test.a
/usr/local/lib/libSDL2-2.0.0.dylib
/usr/local/lib/libSDL2.a
/usr/local/lib/libSDL2main.a
测试程序构建,但终端 window 状态:
~ Buckwheat$ /Applications/CodeBlocks.app/Contents/MacOS/cb_console_runner DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:. /Users/Buckwheat/Documents/Code Blocks Projects/o/bin/Debug/o
sh: /Users/Buckwheat/Documents/Code: No such file or directory
Process returned 127 (0x7F) execution time : 0.002 s
这里是测试程序:
// Example program:
// Using SDL2 to create an application window
#include "SDL.h"
#include <stdio.h>
int main(int argc, char* argv[]) {
SDL_Window *window; // Declare a pointer
SDL_Init(SDL_INIT_VIDEO); // Initialize SDL2
// Create an application window with the following settings:
window = SDL_CreateWindow(
"An SDL2 window", // window title
SDL_WINDOWPOS_UNDEFINED, // initial x position
SDL_WINDOWPOS_UNDEFINED, // initial y position
640, // width, in pixels
480, // height, in pixels
SDL_WINDOW_OPENGL // flags - see below
);
// Check that the window was successfully created
if (window == NULL) {
// In the case that the window could not be made...
printf("Could not create window: %s\n", SDL_GetError());
return 1;
}
// The window is open: could enter program loop here (see SDL_PollEvent())
SDL_Delay(3000); // Pause execution for 3000 milliseconds, for example
// Close and destroy the window
SDL_DestroyWindow(window);
// Clean up
SDL_Quit();
return 0;
}
您的路径包含 spaces :
/Users/Buckwheat/Documents/Code Blocks Projects/o/bin/Debug/o
并且您的 shell 将 space 之前的路径部分作为一个单独的参数:
sh: /Users/Buckwheat/Documents/Code: No such file or directory
你必须像这样转义 spaces 个字符:
/Users/Buckwheat/Documents/Code\ Blocks\ Projects/o/bin/Debug/o