I want to use clion to develop the SDL project on the mac of my M1 chip. I have carried out the following steps
Install the SDL library through Homebrew: brew install sdl2
Configure SDL in CLion: CLion project Add a reference to SDL in the CMakeLists.txt file. At the bottom of the file, add the following lines: find_package(SDL2 REQUIRED) include_directories (${SDL2_INCLUDE_DIRS}) target_link_libraries(${PROJECT_NAME} ${SDL2_LIBRARIES})
Test SDL #include <SDL.h>
int main(int argc, char* argv[]) { SDL_Init
type here
(SDL_INIT_VIDEO); // Initialize the video system of SDL
SDL_Window* 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
0 // Flag, can be set to 0
);
if (window == NULL) {
// Handle errors creating the window here
printf("Could not create window: %s\n", SDL_GetError());
return 1;
}
SDL_Delay(3000); // wait three seconds
SDL_DestroyWindow(window); // Destroy the window
SDL_Quit(); // clean up and exit
return 0;
}
Unfortunately: when I run the code I get Error log,: "ld: warning: ignoring file /opt/homebrew/lib/libSDL2.dylib, building for macOS-x86_64 but attempting to link with file built for macOS-arm64".
I know this error is caused by the incompatibility between the Mac's M1 chip and the x86_64 architecture.
But how should I fix it?
this error is caused by the incompatibility between the Mac's M1 chip and the x86_64 architecture.
But how should I fix it?