mgba icon indicating copy to clipboard operation
mgba copied to clipboard

Can't compile on raspberry pi

Open TheCoder3156 opened this issue 6 years ago • 12 comments

It fails to compile on a raspberry pi 3. Here is the error.

[ 76%] Building CXX object qt/CMakeFiles/mgba-qt.dir/DisplayGL.cpp.o
In file included from /usr/include/GL/gl.h:2055,
                 from /home/pi/mgba-0.6.3/src/platform/opengl/gl.h:21,
                 from /home/pi/mgba-0.6.3/src/platform/qt/DisplayGL.cpp:17:
/usr/include/GL/glext.h:468:19: error: conflicting declaration ‘typedef ptrdiff_t GLsizeiptr’
 typedef ptrdiff_t GLsizeiptr;
                   ^~~~~~~~~~
In file included from /usr/include/arm-linux-gnueabihf/qt5/QtGui/qopengl.h:99,
                 from /usr/include/arm-linux-gnueabihf/qt5/QtOpenGL/qgl.h:45,
                 from /usr/include/arm-linux-gnueabihf/qt5/QtOpenGL/QGLWidget:1,
                 from /home/pi/mgba-0.6.3/src/platform/qt/DisplayGL.h:21,
                 from /home/pi/mgba-0.6.3/src/platform/qt/DisplayGL.cpp:6:
/usr/include/GLES3/gl31.h:73:25: note: previous declaration as ‘typedef khronos_ssize_t GLsizeiptr’
 typedef khronos_ssize_t GLsizeiptr;
                         ^~~~~~~~~~
In file included from /usr/include/GL/gl.h:2055,
                 from /home/pi/mgba-0.6.3/src/platform/opengl/gl.h:21,
                 from /home/pi/mgba-0.6.3/src/platform/qt/DisplayGL.cpp:17:
/usr/include/GL/glext.h:469:19: error: conflicting declaration ‘typedef ptrdiff_t GLintptr’
 typedef ptrdiff_t GLintptr;
                   ^~~~~~~~
In file included from /usr/include/arm-linux-gnueabihf/qt5/QtGui/qopengl.h:99,
                 from /usr/include/arm-linux-gnueabihf/qt5/QtOpenGL/qgl.h:45,
                 from /usr/include/arm-linux-gnueabihf/qt5/QtOpenGL/QGLWidget:1,
                 from /home/pi/mgba-0.6.3/src/platform/qt/DisplayGL.h:21,
                 from /home/pi/mgba-0.6.3/src/platform/qt/DisplayGL.cpp:6:
/usr/include/GLES3/gl31.h:74:26: note: previous declaration as ‘typedef khronos_intptr_t GLintptr’
 typedef khronos_intptr_t GLintptr;
                          ^~~~~~~~
qt/CMakeFiles/mgba-qt.dir/build.make:270: recipe for target 'qt/CMakeFiles/mgba-qt.dir/DisplayGL.cpp.o' failed
make[2]: *** [qt/CMakeFiles/mgba-qt.dir/DisplayGL.cpp.o] Error 1
CMakeFiles/Makefile2:216: recipe for target 'qt/CMakeFiles/mgba-qt.dir/all' failed
make[1]: *** [qt/CMakeFiles/mgba-qt.dir/all] Error 2
Makefile:151: recipe for target 'all' failed
make: *** [all] Error 2

TheCoder3156 avatar May 12 '18 17:05 TheCoder3156

It looks like you have two versions of GL installed, and both are being included.

What if you turn off BUILD_QT in CMake? Or is QT required on the Pi?

Raijinili avatar Jun 03 '18 00:06 Raijinili

I would prefer the qt if possible. Any idea on how to fix the conflict?

TheCoder3156 avatar Aug 02 '18 15:08 TheCoder3156

May be a duplicate of #218.

In that issue, the workaround was,

Try installing libepoxy-dev and seeing if that affects anything.

Raijinili avatar Sep 20 '18 18:09 Raijinili

It's definitely the same issue. However, that one was closed with a workaround instead of a resolution.

endrift avatar Sep 20 '18 18:09 endrift

Please let me know if this patch fixes it

diff --git a/src/platform/opengl/gl.h b/src/platform/opengl/gl.h
index a6412e919..a37f7736e 100644
--- a/src/platform/opengl/gl.h
+++ b/src/platform/opengl/gl.h
@@ -18,8 +18,10 @@ CXX_GUARD_START
 #ifdef _MSC_VER
 #include <windows.h>
 #endif
+#ifndef GL_GLES_PROTOTYPES
 #include <GL/gl.h>
 #endif
+#endif
 
 #include "platform/video-backend.h"
 
diff --git a/src/platform/qt/DisplayGL.cpp b/src/platform/qt/DisplayGL.cpp
index 28b191831..7de3d17d3 100644
--- a/src/platform/qt/DisplayGL.cpp
+++ b/src/platform/qt/DisplayGL.cpp
@@ -15,15 +15,15 @@
 
 #include <mgba/core/core.h>
 #include <mgba-util/math.h>
-#ifdef BUILD_GL
-#include "platform/opengl/gl.h"
-#endif
 #if !defined(_WIN32) || defined(USE_EPOXY)
 #include "platform/opengl/gles2.h"
 #ifdef _WIN32
 #include <epoxy/wgl.h>
 #endif
 #endif
+#ifdef BUILD_GL
+#include "platform/opengl/gl.h"
+#endif
 
 using namespace QGBA;
 

endrift avatar Sep 20 '18 18:09 endrift

Forgot about this. Sorry. I can't help because I did a installed a different is on the pi

TheCoder3156 avatar Jan 15 '19 20:01 TheCoder3156

@endrift

Please let me know if this patch fixes it

Three years later, I'm trying to build on a Raspberry Pi 3 and encountering the same issue. This patch (applied manually as things have moved around slightly since 3 years ago) didn't help at all. I did a make clean and attempted another build but the result was exactly the same error as before.

EDIT: I also tried installing libepoxy-dev, the workaround suggested in the previous issue on this subject, but that doesn't seem to have made any difference on my end either. make clean; make; same error.

vaguerant avatar Jul 27 '21 13:07 vaguerant

I'll see if I can find an RPi to test on.

endrift avatar Jul 27 '21 19:07 endrift

I attempted to compile this on my Rpi4, on 32-bit Raspberry Pi OS. Things I ran into were:

  1. There was no QT5LinguistTools, which didn't interfere with compiling.
  2. When compiling mgba-qt, I would get an error at the final phase, where linking would error, stating /usr/bin/ld: CMakeFiles/mgba-qt.dir/library/LibraryController.cpp.o: undefined reference to symbol '__atomic_compare_exchange_8@@LIBATOMIC_1.0' /usr/bin/ld: //lib/arm-linux-gnueabihf/libatomic.so.1: error adding symbols: DSO missing from command line
  • Manually adding the file, with full path, to the qt/CMakeFiles/mgba-qt.dir/link.txt document fixes that error
  1. After successfully compiling this, the final thing I've run across is that the emulator gives a message stating Failed to create an appropriate display device, falling back to software display. Games may run slowly, especially with larger windows
  • I haven't been able to figure out how to correct this, and the only thought could be needing to add in compiler flags to use overlay hacks, or one of the libraries from /opt/vc/lib.

Dimensional avatar Jul 28 '21 15:07 Dimensional

I attempted to compile this on my Rpi4, on 32-bit Raspberry Pi OS. Things I ran into were:

1. There was no QT5LinguistTools, which didn't interfere with compiling.

2. When compiling mgba-qt, I would get an error at the final phase, where linking would error, stating
   `/usr/bin/ld: CMakeFiles/mgba-qt.dir/library/LibraryController.cpp.o: undefined reference to symbol '__atomic_compare_exchange_8@@LIBATOMIC_1.0'`
   `/usr/bin/ld: //lib/arm-linux-gnueabihf/libatomic.so.1: error adding symbols: DSO missing from command line`


* Manually adding the file, with full path, to the qt/CMakeFiles/mgba-qt.dir/link.txt document fixes that error


1. After successfully compiling this, the final thing I've run across is that the emulator gives a message stating
   `Failed to create an appropriate display device, falling back to software display. Games may run slowly, especially with larger windows`


* I haven't been able to figure out how to correct this, and the only thought could be needing to add in compiler flags to use overlay hacks, or one of the libraries from /opt/vc/lib.

So I found if you start the emulator from command line and add -l 0 you get rid of the error message at the start. So now I've got it functioning on Retropie which is quite fun to mess around with

retropieuser avatar Aug 11 '21 21:08 retropieuser

I attempted to compile this on my Rpi4, on 32-bit Raspberry Pi OS. Things I ran into were:

1. There was no QT5LinguistTools, which didn't interfere with compiling.

2. When compiling mgba-qt, I would get an error at the final phase, where linking would error, stating
   `/usr/bin/ld: CMakeFiles/mgba-qt.dir/library/LibraryController.cpp.o: undefined reference to symbol '__atomic_compare_exchange_8@@LIBATOMIC_1.0'`
   `/usr/bin/ld: //lib/arm-linux-gnueabihf/libatomic.so.1: error adding symbols: DSO missing from command line`


* Manually adding the file, with full path, to the qt/CMakeFiles/mgba-qt.dir/link.txt document fixes that error


1. After successfully compiling this, the final thing I've run across is that the emulator gives a message stating
   `Failed to create an appropriate display device, falling back to software display. Games may run slowly, especially with larger windows`


* I haven't been able to figure out how to correct this, and the only thought could be needing to add in compiler flags to use overlay hacks, or one of the libraries from /opt/vc/lib.

So I found if you start the emulator from command line and add -l 0 you get rid of the error message at the start. So now I've got it functioning on Retropie which is quite fun to mess around with

-l 0 disables log level mask. It doesn't change how the emulator loads to circumvent the error.

Dimensional avatar Aug 13 '21 08:08 Dimensional

I can confirm that the atomic issue is still present on the 32-bit Raspberry Pi OS:

lokathor@eva00:~/mgba/build $ make
[ 10%] Built target updater-stub
[ 10%] Built target mgba-version-info
[ 59%] Built target mgba
[ 61%] Built target mgba-sdl
[ 62%] Built target discord-rpc
[ 62%] Automatic MOC for target mgba-qt
[ 62%] Built target mgba-qt_autogen
[ 62%] Linking CXX executable mgba-qt
/usr/bin/ld: CMakeFiles/mgba-qt.dir/library/LibraryController.cpp.o: undefined reference to symbol '__atomic_compare_exchange_8@@LIBATOMIC_1.0'
/usr/bin/ld: /lib/arm-linux-gnueabihf/libatomic.so.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[2]: *** [qt/CMakeFiles/mgba-qt.dir/build.make:1690: qt/mgba-qt] Error 1
make[1]: *** [CMakeFiles/Makefile2:526: qt/CMakeFiles/mgba-qt.dir/all] Error 2
make: *** [Makefile:171: all] Error 2

However, the 64-bit version of the Raspberry Pi OS does successfully build and run mGBA-qt

Lokathor avatar Aug 03 '22 02:08 Lokathor

@Lokathor i got it built on 32bit bullseye. i used these flags:

cmake -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_CXX_FLAGS="-march=armv8-a -mtune=cortex-a72" ..

and its up and running. 2022-10-14-124904_1920x1080_scrot change the renderer to GL. works fine

foxhound311 avatar Oct 14 '22 16:10 foxhound311

I can confirm that a default build doesn't work, but using those extra flags it does work.

Possibly the readme should be updated?

Lokathor avatar Oct 15 '22 02:10 Lokathor