當前位置:首頁 » 編程軟體 » ubuntuopengl怎麼編譯

ubuntuopengl怎麼編譯

發布時間: 2023-02-11 12:44:04

⑴ ubuntu設置opengl當前版本

ubuntu設置opengl當前版本

但是沒有替換OpenGL版本.那麼現在的問題是何如讓Ub... 博文 來自: SolaxiY的博客 OpenGL Programming Guide: The Official Guide to Learning OpenGL, Ver

關於幾種開發環境的組合,參考這篇博客:

開源項目推薦:OpenGL之gult/freeglut/glew/glfw/glad的聯系與區別_$firecat全宏的代碼足跡$-CSDN博客_glut和glfw區別
1. 安裝 CLion

安裝包下載鏈接:

Download CLion: A Smart Cross-Platform IDE for C and C++
cd /usr/local
sudo mkdir clion
將下載得到的壓縮解壓到目標文件夾下:

sudo tar -zxvf CLion-2021.2.2.tar.gz -C /usr/local/clion
創建打開軟體的快捷方式:

touch CLion.desktop
填入下面的內容:

[Desktop Entry]
Encoding=UTF-8
Name=CLion
Exec=/usr/local/clion/clion-2021.2.2/bin/clion.sh
Icon=/usr/local/clion/clion-2021.2.2/bin/clion.png
Terminal=False
Type=Application
StartupNotify=False
Categories=Application;Development
然後右鍵打開屬性,修改文件的許可權為可讀可寫,可作為可執行文件。 將其移動到指定文件夾中:

sudo mv CLion.desktop /usr/share/applications
然後就可以在啟動台中找到該軟體。

2. 安裝相關包

sudo apt-get install build-essential libgl1-mesa-dev
sudo apt-get install freeglut3-dev
sudo apt-get install libglew-dev libsdl2-dev libsdl2-image-dev libglm-dev libfreetype6-dev
3. 編譯測試

新建一個名為test的C項目。

// main.c
#include <GL/glut.h>
void myDisplay(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glRectf(-0.5f, -0.5f, 0.5f, 0.5f);
glFlush();
}
int main(int argc, char *argv[]){
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);
glutInitWindowPosition(100, 100);
glutInitWindowSize(400, 400);
glutCreateWindow("window name");
glutDisplayFunc(&myDisplay);
glutMainLoop();
return 0;
}

# CMakeLists.txt
cmake_minimum_required(VERSION 3.14)
project(test)

set(CMAKE_CXX_STANDARD 11)

add_executable(test main.c)

set(TARGET_LIB
"/usr/lib/x86_64-linux-gnu/libGL.so"
"/usr/lib/x86_64-linux-gnu/libGLU.so"
"/usr/lib/x86_64-linux-gnu/libglut.so"
)
target_link_libraries(test ${TARGET_LIB})
編譯運行,效果如下:

⑵ Ubuntu11.10 下編譯openGL的問題

在windows下好像從來不用調glutInit。
你在glutCreateWindow("Simple");之前加這么兩句吧。
glutInit( &argc, argv );
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);

⑶ (解決追加200分)在ubuntu上怎麼安裝openGL

什麼叫 Linux無法獨立安裝OpenGl??

需要用到的軟體包有兩個,glut
和tmake,分別可以從以下兩個網址下載:
http://www.opengl.org/resources/libraries/glut/glut-3.7.tar.gz
ftp://ftp.trolltech.com/freebies/tmake/tmake-1.8.tar.gz

下載後的文件假設都放在/usr/src中

首先是安裝glut庫,以下是從www.linux.com找到的編譯glut庫的手冊。

Install GLUT 3.7 Distribution (optional)

If you installed the MesaDemos/MesaLib package, then
you have already installed GLUT 3.7 since it is
included with MesaDemos. However, you may be
interested in installing the GLUT

manpages and you can skip right to the "Install GLUT
manual pages", below ...

Installing GLUT is a bit tricky. I'm not too familiar
with imake, the program that it uses to manage the
Makefiles, and didn't quite see how to get GLUT to
install to where I wanted it (/usr/lib,

but MesaDemos will do this without any trouble
though). It can be done manually anyhow:

cd /usr/src
tar -xvzf glut-3.7.tar.gz
cd glut-3.7

Read the file: README.linux
cd linux
READ the file: README
cp Glut.cf ..
cd ..
Edit Glut.cf: remove any Mesa references.
Replace any -lMesaGL -lMesaGLU with -lGL -lGLU if
needed.
In particular, replace:
OPENGL = $(TOP)/../lib/libMesaGL.so
GLU = $(TOP)/../lib/libMesaGLU.so
with:
OPENGL = -lGL
GLU = -lGLU

./mkmkfiles.imake
cd lib/glut
cp /usr/src/glut-3.7/linux/Makefile .
Edit the Makefile: remove any Mesa references.
Replace any -lMesaGL -lMesaGLU with -lGL -lGLU if
needed.
In particular, replace:
OPENGL = $(TOP)/../lib/libMesaGL.so
GLU = $(TOP)/../lib/libMesaGLU.so
with:
OPENGL = -lGL
GLU = -lGLU

make
ln -s libglut.so.3.7 libglut.so
ln -s libglut.so.3.7 libglut.so.3
cp -d libglut.* /usr/lib
cd ..
cd gle
# make a shared lib for libgle
make
gcc -shared -o libgle.so.3.7 *.o
ln -s libgle.so.3.7 libgle.so
ln -s libgle.so.3.7 libgle.so.3
cp -d libgle.* /usr/lib
cd ..
cd mui
# make a shared lib for libmui
make
gcc -shared -o libmui.so.3.7 *.o
ln -s libmui.so.3.7 libmui.so
ln -s libmui.so.3.7 libmui.so.3
cp -d libmui.* /usr/lib

# Install the GLUT manual pages (not included
with MesaDemos)
cd /usr/src/glut-3.7
make SUBDIRS=man Makefile
cd man/glut
make install.man
ldconfig

cd ../../progs/demos/ideas
# edit the Makefile, change OPENGL = -lGL and GLU =
-lGLU
make
./ideas
# test compiling some demos
# take a look at which libraries have to be linked
(-lX11 ...) in
# the Makefiles. Qt's tmake program available at
www.troll.no
# is a quick way to make a Makefile but you have to
edit it
# and add the -l needed.
ideas如果運行成功的話,說明glut已經可以用了,這時可以將include/GL下的glut等頭文件復制到/usr/include中去。

上面的幾步中,下載的glut包放在/usr/src目錄下,如果放在其他目錄下,將/usr/src改為相應的目錄即可。
此外應該注意的是兩個Makefile文件的修改

· OPENGL = $(TOP)/../lib/libMesaGL.so
GLU = $(TOP)/../lib/libMesaGLU.so

OPENGL = -lGL
GLU = -lGLU
因為所指定的目錄中沒有libMesaGL.so和libMesaGLU.so。

之後是tmake的配置,後面我們可以用它來生成pro工程文件和makefile文件。

先將下載的tmake解壓縮,tar -zxvf tmake-1.8.tar.gz
得到tmake-1.8目錄,之後設置兩個環境變數:PATH和TMAKEPATH
PATH=$PATH:/usr/src/tmake-1.8/bin
export PATH
TMAKEPATH=/usr/src/tmake-1.8/lib/linux-g++
export TMAKEPATH

新建一個測試目錄test,將glut-3.7目錄下的progs/redbook目錄下的hello.c復制到test目錄中

之後生成一個pro文件:progen -o hello.pro

然後生成makefile文件:tmake hello.pro "CONFIG+=opengl"
-o Makefile

編輯生成的Makefile文件,在載入動態連接庫的行裡面加入
-lglut -lXi -lXmu

保存,make。

./hello 可以看到運行結果就可以了。

PS。不過我編譯還是通不過,所以不好給你意見。

⑷ 如何在ubuntu 下開發opengl es3.0 程序

前提是:
1.配置好了Ubuntu下的c++環境,gcc以及g++可用。
2.使用eclipse for c+做OpenGL開發。
步驟一:
在ubuntu終端下運行以下命令,安裝opengl所需要的庫文件
$ sudo apt-get install build-essential
$ sudo apt-get install freeglut3-dev
步驟二:
運行一下opengl實例,測試配置的環境是否安裝成功
在eclipse下新建一個工程文件,假設命名為Test,在工程Test裡面新建一個C++源代碼文件,這里把它命名為main.cpp,在main.cpp文件中打入一下代碼
#include <GL/glut.h>

⑸ C-free和Dev-C++這些編譯器要怎樣才能編譯運行openGL程序

你要新建opengl工程,(dev)如下-----文件----新建--工程--multimedia標簽--選擇opgnglut--輸個名字保到一個你能找得到的地方----確定
然後--你能看到main.cpp編譯運行---旋轉三角形--看到了吧----這只是個例子
以後,要運行你的opengl時,打開那個.dev文件,然後在右側的工程管理裡面,選中它,右鍵---添加----找到你的.c opengl文件,編譯運行就可以了
that's all

⑹ 如何在Ubuntu平台下編譯比特幣bitcoin客戶端

很多朋友都知道如何在linux平台如何編譯比特幣程序,但是,到了windows平台,
就會感覺到無從下手. 其實, 比特幣程序是跨平台的.
你要編譯windows版的比特幣程序,基本上有兩種方法,一種是在linux平台
(推薦ubuntu 13.10)通過交叉編譯的方法來編譯.另外一種,就是直接在windows平台編譯.
我想,你既然要在windows平台使用,我就詳細介紹一下如何在windwows平台編譯比特幣程序.
我的平台:windows7

第一步:安裝變編譯環境QT和MINGW,msys
1、msys是一個在windows平台模擬shell的程序。
下載安裝程序之後,通過安裝管理程序,按安裝以下內容:
From MinGW installation manager -> All packages -> MSYS
選中以下安裝包
msys-base-bin
msys-autoconf-bin
msys-automake-bin
msys-libtool-bin
點 apply changes開始安裝。他會自動下載安裝好。
需要注意的是,確保不要安裝msys-gcc和msys-w32api ,因為這兩個包和我們的編譯系統發生沖突。
很多人出現一些莫名其妙的問題,就是因為這兩個包。
2、安裝 MinGW-builds
下載並解壓縮 i686-4.8.2-release-posix-dwarf-rt_v3-rev3.7z 到C盤根目錄 C:\
注意我的目錄結構。你盡量和我一樣。
3、設置PATH環境變數,將C:\mingw32\bin;添加到第一個。
4、在命令行模式下輸入 gc -v 會得到以下內容
c:\gcc -v
Using built-in specs.
COLLECT_GCC=c:\mingw32\bin\gcc.exe
COLLECT_LTO_WRAPPER=c:/mingw32/bin/../libexec/gcc/i686-w64-mingw32/4.8.2/lto-wrapper.exe
Target: i686-w64-mingw32
Configured with: ../../../src/gcc-4.8.2/configure --host=i686-w64-mingw32 --build=i686-w64-mingw32 --target=i686-w64-mingw32 --prefix=/mingw32 --with-sysroot=/c/mingw482/i686-482-posix-dwarf-rt_v3-rev3/mingw32 --with-gxx-include-dir=/mingw32/i686-w64-mingw32/include/c++ --enable-shared --enable-static --disable-multilib --enable-languages=ada,c,c++,fortran,objc,obj-c++,lto --enable-libstdcxx-time=yes --enable-threads=posix --enable-libgomp --enable-libatomic --enable-lto --enable-graphite --enable-checking=release --enable-fully-dynamic-string --enable-version-specific-runtime-libs --disable-sjlj-exceptions --with-dwarf2 --disable-isl-version-check --disable-cloog-version-check --disable-libstdcxx-pch --disable-libstdcxx-debug --enable-bootstrap --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-gnu-as --with-gnu-ld --with-arch=i686 --with-tune=generic --with-libiconv --with-system-zlib --with-gmp=/c/mingw482/prerequisites/i686-w64-mingw32-static --with-mpfr=/c/mingw482/prerequisites/i686-w64-mingw32-static --with-mpc=/c/mingw482/prerequisites/i686-w64-mingw32-static --with-isl=/c/mingw482/prerequisites/i686-w64-mingw32-static --with-cloog=/c/mingw482/prerequisites/i686-w64-mingw32-static --enable-cloog-backend=isl --with-pkgversion='i686-posix-dwarf-rev3, Built by MinGW-W64 project' --with-bugurl= CFLAGS='-O2 -pipe -I/c/mingw482/i686-482-posix-dwarf-rt_v3-rev3/mingw32/opt/include -I/c/mingw482/prerequisites/i686-zlib-static/include -I/c/mingw482/prerequisites/i686-w64-mingw32-static/include' CXXFLAGS='-O2 -pipe -I/c/mingw482/i686-482-posix-dwarf-rt_v3-rev3/mingw32/opt/include -I/c/mingw482/prerequisites/i686-zlib-static/include -I/c/mingw482/prerequisites/i686-w64-mingw32-static/include' CPPFLAGS= LDFLAGS='-pipe -L/c/mingw482/i686-482-posix-dwarf-rt_v3-rev3/mingw32/opt/lib -L/c/mingw482/prerequisites/i686-zlib-static/lib -L/c/mingw482/prerequisites/i686-w64-mingw32-static/lib -Wl,--large-address-aware'
Thread model: posix
gcc version 4.8.2 (i686-posix-dwarf-rev3, Built by MinGW-W64 project)
至此,你的開發環境已經搭建好了,很簡單吧

第二部分:下載bitcoin引用的外部庫
我們把它們全部放在 C:\deps目錄下

2.1 安裝OpenSSL
進入啟動 MinGw shell 比如目錄:(C:\MinGW\msys\1.0\msys.bat)運行這個msys.bat,就會啟動一個shell環境,提示符是$
輸入命令
cd /c/deps/
tar xvfz openssl-1.0.1g.tar.gz
cd openssl-1.0.1g
Configure no-shared no-dso mingw
make
等待幾分鍾後,就把openssl編譯好了。

2.2 下載Berkeley DB
我們推薦使用 4.8版本
同樣在msys shell環境下輸入以下命令
cd /c/deps/
tar xvfz db-4.8.30.NC.tar.gz
cd db-4.8.30.NC/build_unix
../dist/configure --enable-mingw --enable-cxx --disable-shared --disable-replication
make
等待編譯

2.3 安裝Boost
msys命令:
cd C:\deps\boost_1_55_0\
bootstrap.bat mingw
b2 --build-type=complete --with-chrono --with-filesystem --with-program_options --with-system --with-thread toolset=gcc variant=release link=static threading=multi runtime-link=static stage

2.4 安裝Miniupnpc
cd C:\deps\miniupnpc
mingw32-make -f Makefile.mingw init upnpc-static
msys shell命令
cd /c/deps/protobuf-2.5.0
configure --disable-shared
make

2.6 qrencode:
命令
cd /c/deps/libpng-1.6.10
configure --disable-shared
make
LIBS="../libpng-1.6.10/.libs/libpng16.a ../../mingw32/i686-w64-mingw32/lib/libz.a" \
png_CFLAGS="-I../libpng-1.6.10" \
png_LIBS="-L../libpng-1.6.10/.libs" \
configure --enable-static --disable-shared --without-tools
make

2.7 安裝 Qt 5 庫
下載和解壓縮
在 windows命令行輸入:
set INCLUDE=C:\deps\libpng-1.6.10;C:\deps\openssl-1.0.1g\include
set LIB=C:\deps\libpng-1.6.10\.libs;C:\deps\openssl-1.0.1g
cd C:\Qt\5.2.1
configure.bat -release -opensource -confirm-license -static -make libs -no-sql-sqlite -no-opengl -system-zlib -qt-pcre -no-icu -no-gif -system-libpng -no-libjpeg -no-freetype -no-angle -no-vcproj -openssl-linked -no-dbus -no-audio-backend -no-wmf-backend -no-qml-debug
mingw32-make
set PATH=%PATH%;C:\Qt\5.2.1\bin
cd C:\Qt\qttools-opensource-src-5.2.1
qmake qttools.pro
mingw32-make

3. 下載Bitcoin 0.9.1
在msys shell下輸入以下命令行:
cp /c/deps/libpng-1.6.10/.libs/libpng16.a /c/deps/libpng-1.6.10/.libs/libpng.a
cd /c/bitcoin-0.9.1
./autogen.sh
CPPFLAGS="-I/c/deps/boost_1_55_0 \
-I/c/deps/db-4.8.30.NC/build_unix \
-I/c/deps/openssl-1.0.1g/include \
-I/c/deps \
-I/c/deps/protobuf-2.5.0/src \
-I/c/deps/libpng-1.6.10 \
-I/c/deps/qrencode-3.4.3" \
LDFLAGS="-L/c/deps/boost_1_55_0/stage/lib \
-L/c/deps/db-4.8.30.NC/build_unix \
-L/c/deps/openssl-1.0.1g \
-L/c/deps/miniupnpc \
-L/c/deps/protobuf-2.5.0/src/.libs \
-L/c/deps/libpng-1.6.10/.libs \
-L/c/deps/qrencode-3.4.3/.libs" \
./configure \
--disable-upnp-default \
--disable-tests \
--with-qt-incdir=/c/Qt/5.2.1/include \
--with-qt-libdir=/c/Qt/5.2.1/lib \
--with-qt-bindir=/c/Qt/5.2.1/bin \
--with-qt-plugindir=/c/Qt/5.2.1/plugins \
--with-boost-system=mgw48-mt-s-1_55 \
--with-boost-filesystem=mgw48-mt-s-1_55 \
--with-boost-program-options=mgw48-mt-s-1_55 \
--with-boost-thread=mgw48-mt-s-1_55 \
--with-boost-chrono=mgw48-mt-s-1_55 \
--with-protoc-bindir=/c/deps/protobuf-2.5.0/src
make
strip src/bitcoin-cli.exe
strip src/bitcoind.exe
strip src/qt/bitcoin-qt.exe

這樣,你就得到了變異好的 bitcoin-cli.exe和bitcoind.exe ,bitcoin-qt.exe(windows QT圖形界面的錢包軟體)

⑺ 如何開啟Ubuntu14.04客戶機內的OpenGL3.3支持

ubuntu系統是以桌面應用為主的linux系統,現在越來越流行了。下面介紹在Ubuntu下開發OpenGL環境的配置。
在Ubuntu下安裝OpenGL環境
1,安裝
測試環境
2,安裝:EclipseIDEforC/C++LinuxDevelopers
3,新建:項目和代碼
4,設置OpenGL項目屬性
5,編譯文件,右鍵項目,BuildProject
6,運行成功
選擇驅動:查看自己的Ubuntu顯卡所支持的(以及顯卡驅動所支持的)OpenGL版本。

熱點內容
java返回this 發布:2025-10-20 08:28:16 瀏覽:748
製作腳本網站 發布:2025-10-20 08:17:34 瀏覽:1012
python中的init方法 發布:2025-10-20 08:17:33 瀏覽:718
圖案密碼什麼意思 發布:2025-10-20 08:16:56 瀏覽:878
怎麼清理微信視頻緩存 發布:2025-10-20 08:12:37 瀏覽:774
c語言編譯器怎麼看執行過程 發布:2025-10-20 08:00:32 瀏覽:1127
郵箱如何填寫發信伺服器 發布:2025-10-20 07:45:27 瀏覽:351
shell腳本入門案例 發布:2025-10-20 07:44:45 瀏覽:229
怎麼上傳照片瀏覽上傳 發布:2025-10-20 07:44:03 瀏覽:911
python股票數據獲取 發布:2025-10-20 07:39:44 瀏覽:875