this post was submitted on 09 Oct 2023
10 points (100.0% liked)

Linux

48208 readers
737 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 5 years ago
MODERATORS
 

My system reports that im using OpenGL 4.2: https://pastebin.com/uXu3BLxX But when i try to use that OpenGL vesion to write a program with it, it fails, the maximum version i can use for that is OpenGL 2.1, why does that happen?

you are viewing a single comment's thread
view the rest of the comments
[–] e0qdk@kbin.social 2 points 1 year ago (1 children)

Try compiling GLFW from source against GLX instead of EGL. If glxinfo is talking to a software implementation running on your system, I'd expect GLFW built to use GLX would use the same implementation on your computer.

[–] prettydarknwild@lemmy.world 1 points 1 year ago (1 children)

im using the GLFW source code, and compiling it alongside my program, how i should compile it now?

[–] e0qdk@kbin.social 2 points 1 year ago* (last edited 1 year ago) (1 children)
  • GLFW is intended to be built with cmake.
  • After unzipping the source, make a build directory, and configure glfw3
  • ^^ I like using ccmake to do this interactively, but you can also just pass flags to cmake if you know what they are
  • You should build with GLFW_USE_WAYLAND and GLFW_USE_OSMESA turned off to get it to try to build against X11.
  • You will probably also want to turn off GLFW_BUILD_DOCS, GLFW_BUILD_EXAMPLES, GLFW_BUILD_TESTS
  • You can adjust CMAKE_INSTALL_PREFIX if you don't want to use the /usr/local default install path.
  • After generating a Makefile, run make and make install
  • glfw3 generates a pkg-config compatible .pc file as part of its build process that lists flags needed for compilation and linking against the library. Normally, you'd just call pkg-config --cflags --libs --static glfw3 to get this info as part of your own build process (in a Makefile, for example) or else require glfw3 as part of a cmake-based build, but you can read what's generated in there if that program is not available to you for some reason. In case it's helpful for comparison, what I get with a custom build of the static library version of glfw3 installed into /usr/local on a slightly old version of Ubuntu is output like -I/usr/local/include -L/usr/local/lib -lglfw -lrt -lm -ldl -lX11 -lpthread -lxcb -lXau -lXdmcp but you may need something different for your particular configuration.

Basically, something like this, probably, to do the compilation and get the flags to pass to g++:

wget 'https://github.com/glfw/glfw/releases/download/3.3.8/glfw-3.3.8.zip'
unzip glfw-3.3.8.zip
mkdir build
cd build
cmake -D GLFW_BUILD_DOCS=OFF -D GLFW_BUILD_EXAMPLES=OFF -D GLFW_BUILD_TESTS=OFF -D GLFW_USE_OSMESA=OFF -D GLFW_USE_WAYLAND=OFF -D GLFW_VULKAN_STATIC=OFF ../glfw-3.3.8
make
make install

pkg-config --cflags --libs --static glfw3

If you want to just compile a single cpp file after building and install, you can do something like

g++ main.cpp `pkg-config --cflags --libs --static glfw3` -lGL

[–] prettydarknwild@lemmy.world 1 points 1 year ago

it worked! thank you