Error compiling Ubuntu 24.04
Here is the terminal error:
Executing task: make -j$(nproc) Release
Compiling OF library for Release
make[1]: Entering directory '/home/lewis/openFrameworks/libs/openFrameworksCompiled/project'
Done!
make[1]: Leaving directory '/home/lewis/openFrameworks/libs/openFrameworksCompiled/project'
Compiling MageFight for Release
make[1]: Entering directory '/home/lewis/openFrameworks/apps/myApps/MageFight'
make[2]: Entering directory '/home/lewis/openFrameworks/apps/myApps/MageFight'
cp ../../../libs/*/lib/linux64/*.so bin/ ; true
compiling done
to launch the application
cd bin
./MageFight
- or -
make RunRelease
make[2]: Leaving directory '/home/lewis/openFrameworks/apps/myApps/MageFight'
make[1]: Leaving directory '/home/lewis/openFrameworks/apps/myApps/MageFight'
* Terminal will be reused by tasks, press any key to close it.
* Executing task: make RunRelease
Segmentation fault (core dumped)
make: *** [../../../libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk:191: RunRelease] Error 139
* The terminal process "/usr/bin/bash '-c', 'make RunRelease'" terminated with exit code: 2.
* Terminal will be reused by tasks, press any key to close it.
Hi!
- Do the regular examples that come with OF run okay?
- Did you clone the OF repo or are you using a nightly release or the 0.12.1 release?
- Did you run the scripts in
OF/scripts/linux/ubuntu/?
Hello, The examples do run perfectly. I'm using the 0.12.1 gcc6 download from the website. I did run the Ubuntu scripts.
I started making my game on Windows in Visual Studio and wanted to switch to my Bazzite OS PC where I'm using Distrobox and VSCode. I copied over the 3 src files and bin/data assets, but I get this error? I have an AMD CPU and GPU.
Thanks for your help!
Ahh it sounds like your project's addon.make and config.make might need updating. VS Code relies mostly on these for compilation on Linux.
- Are there any libraries that you are using that aren't part of an addon?
- I'd first check that all the addons you are using are listed in addon.make
- If you have any .so libraries in your addons you may need to copy to YOUR_PROJECT_FOLDER/bin/libs or YOUR_PROJECT_FOLDER/bin/ depending on what you have set in config.make
EDIT: Looking at it more, I think you might have a code error which just doesn't manifest on Windows.
Try doing:
- Terminal->Run Task->Build Debug
- Then do Run->Start Debugging
It should point you to the code line where it's crashing.
I'm using glm/gtx/intersect.hpp in my .h. I have just ofxAssimpModelLoader in my addons.make currently.
With run and debug the crash happened at the ofRectangle:
Thread 1 "MageFight_debug" received signal SIGSEGV, Segmentation fault.
0x0000555555786df2 in ofRectangle::getCenter (this=0x555556587d40) at /home/lewis/openFrameworks/libs/openFrameworks/types/ofRectangle.cpp:733
733 return {x + width * 0.5f, y + height * 0.5f, 0.f};
ahh interesting. I am guessing the crash/error might be a level up - so it might be that a pointer to an object that is calling getCenter might be out of bounds or NULL.
If you post a picture of the stack trace it might help narrow it down.
Thanks for your help
My guess would be ofApp line 335. If you wanted to share the ofApp::drawMainMenu() function code and highlight what line 335 is I think it could be easy to track down.
You could also try commenting out the inside of ofApp::drawMainMenu() and see if it runs without crashing.
This is the function. I tried commenting out everything under void and the window didn't crash. Though after setting the current state as gameplay in my .h and called my setupGame function at the end of the setup function it still does.
void ofApp::drawMainMenu() {
ofSetColor(ofColor::white);
string title = "Mage Fight";
ofRectangle titleBox = titleFont.getStringBoundingBox(title, 0, 0);
float titleX = round(ofGetWidth() / 2.0f - titleBox.getWidth() / 2.0f);
float titleY = round(ofGetHeight() * 0.25f);
titleFont.drawString(title, titleX, titleY);
// --- Draw Buttons ---
auto drawButton = [&](const ofRectangle & rect, const string & text, bool isHovered) {
ofSetColor(isHovered ? ofColor::lightGray : ofColor::white);
ofFill();
ofDrawRectRounded(rect, 15);
ofSetColor(ofColor::black);
ofNoFill();
ofSetLineWidth(2);
ofDrawRectRounded(rect, 15);
ofFill();
ofRectangle textBox = uiFont.getStringBoundingBox(text, 0, 0);
float textX = round(rect.getCenter().x - textBox.getWidth() / 2.0f);
float textY = round(rect.getCenter().y + textBox.getHeight() / 2.0f);
uiFont.drawString(text, textX, textY);
};
drawButton(mainMenuPlayAIButton, "Play vs AI", mainMenuHoveredIndex == 0);
drawButton(mainMenuMultiplayerButton, "Multiplayer (Disabled)", mainMenuHoveredIndex == 1);
drawButton(mainMenuSettingsButton, "Settings", mainMenuHoveredIndex == 2);
drawButton(mainMenuQuitButton, "Quit", mainMenuHoveredIndex == 3);
}
Hmm - are the rectangles like mainMenuPlayAIButton etc defined in ofApp.h?
eg:
ofRectangle mainMenuPlayAIButton;
I would probably put a bunch of couts to track down the issue. eg:
void ofApp::drawMainMenu() {
std::cout << "titleFont loaded: " << titleFont.isLoaded()
<< " uiFont loaded: " << uiFont.isLoaded() << std::endl;
auto drawButton = [&](const ofRectangle & rect, const string & text, bool isHovered) {
std::cout << " rect sanity check " << rect << " text check " << text << std::endl;
I usually print out every line near where I think a crash is happening. eg:
std::cout << "here 1 ?" << endl;
Then once I narrow it down print out the properties of different objects like the ofRectangle etc.
I would also definitely do a Terminal->Run Task->Clean but if that doesn't fix the new issue it is probably something with the way you are initializing your variables.
There is also a gcc flag for making non initialized variables an error - which forces you to fix any variables that are being used before being initialized.
In your config.make in your Project folder you could add to the C_FLAGS Werror=uninitialized -Werror=maybe-uninitialized
so it would look like this.
PROJECT_CFLAGS = -Wno-sign-compare -Wno-unused-but-set-variable -Wno-unused-variable -Wno-unknown-pragmas -Werror=uninitialized -Werror=maybe-uninitialized
Hi thanks for your help, I ended up deleting this container and created a new one and managed to get it fully working. Both compiling correctly and using my GPU and not llvmpipe. These were my, hopefully, exact commands and structure in case of future reference.
distrobox create --name of_arch --image archlinux:latest --home ~/of_workspace
distrobox enter of_arch
sudo usermod -aG video,render $USER
exit
xhost +
distrobox enter of_arch
sudo pacman -Syu
sudo pacman -S base-devel git glu mesa mesa-utils
sudo pacman -S libxinerama libxrandr libxcursor libxi libxkbcommon-x11 libglvnd gtk3
git clone --depth=1 https://github.com/openframeworks/openFrameworks.git
cd openFrameworks/scripts/linux
./download_libs.sh
sudo pacman -S cmake
git clone -b 3.3.10 https://github.com/glfw/glfw.git
cd glfw/build
cmake -DGLFW_BUILD_DOCS=OFF -DGLFW_BUILD_TESTS=OFF -DGLFW_BUILD_EXAMPLES=OFF -DGLFW_INSTALL=ON -DBUILD_SHARED_LIBS=ON ..
make
sudo make install
sudo cp src/libglfw.so.3 /usr/lib/libglfw.so.3
Edited: ~/openFrameworks/libs/openFrameworksCompiled/project/makefileCommon/config.linux.common.mk Replaced the ifeq check for glfw3 with
PLATFORM_PKG_CONFIG_LIBRARIES += glfw3 PLATFORM_LIBRARIES += Xinerama
rm -rf ~/openFrameworks/libs/openFrameworksCompiled/lib/linux64
rm -rf ~/openFrameworks/libs/openFrameworksCompiled/project/linux64/obj
cd ~/openFrameworks/scripts/linux
./compileOF.sh -j$(nproc)
unset WAYLAND_DISPLAY
unset XDG_SESSION_TYPE
export DISPLAY=:0
cd bin
./MyGame