Command-Line

如何在 ubuntu 上安裝 OpenGL 和 SDL2 庫

  • January 4, 2022

我正在嘗試建構 Cube2 Sauerbraten,但我需要 OpenGL 和 SDL2 庫來執行 makefile。(我在這裡使用 ubuntu)我嘗試執行sudo apt-get install --yes software-properties-common g++ make然後sudo apt-get install --yes libsdl2-dev最後sudo apt-get install --yes freeglut3-dev,編譯,g++ main.cpp -I /usr/include/SDL2/ -lSDL2 -lGL.

我從https://gist.github.com/dirkk0/cad259e6a3965abb4178獲得了這些命令。當我執行它們時,前三個命令工作正常,但最後一個沒有工作,給了我這個錯誤。

optiplex780@super-OptiPlex-780:~$ g++ main.cpp -I /usr/include/SDL2/ -lSDL2  -lGL
cc1plus: fatal error: main.cpp: No such file or directory
compilation terminated.
optiplex780@super-OptiPlex-780:~$

我應該用makefile替換main.cpp嗎?

我只是個笨蛋,還是這裡有問題?安裝軟體包後,我嘗試進入~/sauerbraten/src目錄並執行make install. 我得到了這些錯誤。

optiplex780@super-OptiPlex-780:~/sauerbraten_2020_12_29_linux/sauerbraten/src$ make install
make    -C enet/ all
make[1]: Entering directory '/home/optiplex780/sauerbraten_2020_12_29_linux/sauerbraten/src/enet'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/home/optiplex780/sauerbraten_2020_12_29_linux/sauerbraten/src/enet'
g++ -O3 -fomit-frame-pointer -Wall -fsigned-char -o sauer_client shared/crypto.o shared/geom.o shared/stream.o shared/tools.o shared/zip.o engine/3dgui.o engine/bih.o engine/blend.o engine/blob.o engine/client.o engine/command.o engine/console.o engine/cubeloader.o engine/decal.o engine/dynlight.o engine/glare.o engine/grass.o engine/lightmap.o engine/main.o engine/material.o engine/menus.o engine/movie.o engine/normal.o engine/octa.o engine/octaedit.o engine/octarender.o engine/physics.o engine/pvs.o engine/rendergl.o engine/rendermodel.o engine/renderparticles.o engine/rendersky.o engine/rendertext.o engine/renderva.o engine/server.o engine/serverbrowser.o engine/shader.o engine/shadowmap.o engine/sound.o engine/texture.o engine/water.o engine/world.o engine/worldio.o fpsgame/ai.o fpsgame/client.o fpsgame/entities.o fpsgame/fps.o fpsgame/monster.o fpsgame/movable.o fpsgame/render.o fpsgame/scoreboard.o fpsgame/server.o fpsgame/waypoint.o fpsgame/weapon.o -Lenet/.libs -lenet -L/usr/X11R6/lib `sdl-config --libs` -lSDL_image -lSDL_mixer -lz -lGL -lrt
/bin/sh: 1: sdl-config: not found
/usr/bin/ld: cannot find -lSDL_image
/usr/bin/ld: cannot find -lSDL_mixer
collect2: error: ld returned 1 exit status
make: *** [Makefile:163: client] Error 1
optiplex780@super-OptiPlex-780:~/sauerbraten_2020_12_29_linux/sauerbraten/src$

你的程序有很多文件,那麼一個文件g++是不夠的。(無make參數)命令通常是從 Makefile 編譯軟體的正確方法。

Makefile 在src文件夾中……您應該cd src在啟動前輸入它 ( ) makemake install如果沒有完成,請編譯軟體並安裝它。

根據 readme_source.txt 文件,它使用的是 zlib,那麼這個zlib1g-dev包會很有幫助。還有libsdl-mixer1.2-devlibsdl-image1.2-dev在 Debian 系統上,實際版本可能會有所不同。您似乎有一個 2 版本)。

引用自:https://unix.stackexchange.com/questions/684845