Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
C++ Coding Magpi#66
#1
This one is a bit of a step up, putting graphics system in place, but even so we're only half way there. The nature of a 4 page article makes it very hard to keep the content relevant and interesting. But stick with it, we'll expand on it more each week and soon have a bunch of recognizable game characters chasing you around.
Reply
#2
I'm trying to follow along with these articles but ran into an issue with MagPi#66.

Where you describe adding the references to the libs in Code:Blocks, I was not able to locate the file names that are listed in the article. I'm running a RasPi 3B+ with the latest Raspibian kernel 4.14.71-v7+.

This is what I found:
No GLESv2_static.a only libGLES_static.a
No EGL_static.a only libEGL_static.a
no vchiq_arm.a only libvchiq_arm.so
no vcos.a only libvcos.so


Also, when compiling the code (modified from MagPi #65) I get the following error:
-------------- Build: Debug in HelloWorld (compiler: GNU GCC Compiler)---------------

g++ -Wall -fexceptions -g -I../../../../../../opt/vc/include -I../../../../../../opt/vc/include/interface -I../../../../../../opt/vc/include/interface/vmcs_host/linux -I../../../../../../opt/vc/include/interface/vcos/pthreads -c /home/pi/development/MagPi/ed65/HelloWorld/SimpleObject.cpp -o obj/Debug/SimpleObject.o
g++ -o bin/Debug/HelloWorld obj/Debug/Game.o obj/Debug/main.o obj/Debug/OGL.o obj/Debug/SimpleObject.o ../../../../../../opt/vc/lib/libbcm_host.so ../../../../../../opt/vc/lib/libGLESv2_static.a ../../../../../../opt/vc/lib/libEGL_static.a ../../../../../../opt/vc/lib/libkhrn_static.a ../../../../../../opt/vc/lib/libvchiq_arm.so ../../../../../../opt/vc/lib/libvcos.so
/usr/bin/ld: ../../../../../../opt/vc/lib/libEGL_static.a(khrn_client_platform_linux.c.o): undefined reference to symbol 'pthread_getspecific@@GLIBC_2.4'
//lib/arm-linux-gnueabihf/libpthread.so.0: error adding symbols: DSO missing from command line

Oh, I got it. I had to add -lpthread to the Other linker options.
Reply
#3
(10-29-2018, 07:35 AM)jomoengineer Wrote: I'm trying to follow along with these articles but ran into an issue with MagPi#66.

Where you describe adding the references to the libs in Code:Blocks, I was not able to locate the file names that are listed in the article.  I'm running a RasPi 3B+ with the latest Raspibian kernel 4.14.71-v7+.

This is what I found:
No GLESv2_static.a only libGLES_static.a
No EGL_static.a only libEGL_static.a
no vchiq_arm.a only libvchiq_arm.so
no vcos.a only libvcos.so


Also, when compiling the code (modified from MagPi #65) I get the following error:
-------------- Build: Debug in HelloWorld (compiler: GNU GCC Compiler)---------------

g++ -Wall -fexceptions -g -I../../../../../../opt/vc/include -I../../../../../../opt/vc/include/interface -I../../../../../../opt/vc/include/interface/vmcs_host/linux -I../../../../../../opt/vc/include/interface/vcos/pthreads -c /home/pi/development/MagPi/ed65/HelloWorld/SimpleObject.cpp -o obj/Debug/SimpleObject.o
g++  -o bin/Debug/HelloWorld obj/Debug/Game.o obj/Debug/main.o obj/Debug/OGL.o obj/Debug/SimpleObject.o   ../../../../../../opt/vc/lib/libbcm_host.so ../../../../../../opt/vc/lib/libGLESv2_static.a ../../../../../../opt/vc/lib/libEGL_static.a ../../../../../../opt/vc/lib/libkhrn_static.a ../../../../../../opt/vc/lib/libvchiq_arm.so ../../../../../../opt/vc/lib/libvcos.so
/usr/bin/ld: ../../../../../../opt/vc/lib/libEGL_static.a(khrn_client_platform_linux.c.o): undefined reference to symbol 'pthread_getspecific@@GLIBC_2.4'
//lib/arm-linux-gnueabihf/libpthread.so.0: error adding symbols: DSO missing from command line

Oh, I got it.  I had to add -lpthread to the Other linker options.

the library names always start with libXXX 

we just refer to them without the lib in your project build options

take a look at this image attached to see how you set up the libs  and the other to see how you set up the search paths for the linker
Brian Beuken
Lecturer in Game Programming at Breda University of Applied Sciences.
Author of The Fundamentals of C/C++ Game Programming: Using Target-based Development on SBC's 



Reply
#4
hmmm the images are not attached?

try this link
Brian Beuken
Lecturer in Game Programming at Breda University of Applied Sciences.
Author of The Fundamentals of C/C++ Game Programming: Using Target-based Development on SBC's 



Reply
#5
Yeah, I compared the Project code from the MagPi github repository with mine but the one posted is for an older version of Raspbian. I'm running the latest with a RasPi 3B+.

The images you provided do not match what is in the magazine article but make more sense. The article did not mention /usr/lib and suggestion keeping the selections relative.

With the libs set as I listed and adding -lpthread to the Other linker options.seems to solve the build issue.

Also, I had set 'gpu_mem=256' and 'dtoverlay=vc4-fkms-v3' in '/boot/config.txt' to run other OpenGL games but this seems to cause an issue with the MagPi code. This is the error I see from gdb:

(gdb) run
Starting program: /home/pi/development/MagPi/ed65/HelloWorld/bin/Debug/HelloWorld
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/arm-linux-gnueabihf/libthread_db.so.1".
Hello my name is Bobby1and my Xpos is1.4013e-45
* failed to add service - already in use?
[New Thread 0x76bbf450 (LWP 1473)]
[Thread 0x76ff4000 (LWP 1470) exited]
[Inferior 1 (process 1470) exited with code 01]

After removing (commenting) out 'gpu_mem=256' and 'dtoverlay=vc4-fkms-v3' and rebooting the Pi this solved the issue and the example runs just fine now. However, my HelloTriangle example from the Fundamentals book still does not run but that is another issue.

Thanks.
Reply
#6
ah the joys of programming on a system with a moving target OS

the size of our GPU shouldn't make a lot of difference, especially on such a simple starting project, not sure about the dtoverlay, those values all can be set using the Raspberyy config util, and I don't ever manually mess with any config txt files.

I would suggest kicking it back to legacy GLES status though as all the work I do is always for GLES2.0 only so it can produce conflcts I've never seen.
Brian Beuken
Lecturer in Game Programming at Breda University of Applied Sciences.
Author of The Fundamentals of C/C++ Game Programming: Using Target-based Development on SBC's 



Reply
#7
Yeah, I think commenting out the 'dtoverlay=vc4-fkms-v3' entry put it back to Legacy mode. This entry I believe is for the Fake KMS setting.

I'll have to check the Lib settings in Code:Blocks to set them they way you show, but at least the code runs.

I still can not get the Fundamentals HelloTriangle code to work. The example under /opt/vc/src/hello_pi seems to work just fine though.

I guess I spoke too soon.

I broke down and did a full update on the RasPi 3B+ using the following:
sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
sudo rpi-update

Only the rpi-update updated anything and is a bit risky, however it did do an update to the VideoCore libs and now my HelloTriangle code works perfectly. Crazy!
Reply
#8
very much crazy, never had a problem with any new raspberry (until this glm thing) that would stop the hello triangle test project. I regulalry set up and prep raspberries for my students and not once have we ever had any fail. I install latest raspbian, set gpu to 128, set ssh on, put into legacy mode, git clone glm and stb, then everything works.

if it updated the videocore libs, maybe there was something wrong with the old ones, can't really offer any rational explination
Brian Beuken
Lecturer in Game Programming at Breda University of Applied Sciences.
Author of The Fundamentals of C/C++ Game Programming: Using Target-based Development on SBC's 



Reply
#9
I had an issue with the 3 in the past where after performing an update on the system the uart that is used for the ble and wifi on board modules were swapped causing connection to the board to get messed up. It took a bit to get them to swap back but did cause havoc in a design contest I was involved with.

The 3B+ plus has had a number of issues such as this with the Raspbian image since it was released so it is surprising the issues still persist. It's all part of the game with these devices.
Reply
#10
(10-29-2018, 03:41 PM)jomoengineer Wrote: /usr/lib

With the libs set as I listed and adding -lpthread to the Other linker options.seems to solve the build issue.

...
Thanks so much for your helpful post! I had just tried the example and run into exactly the same problems before coming here to see if someone had already found a solution... Thanks to your hints my Hello_Triangle example from MagPi is running now!

The article did mention a different set of libs for systems after 2017, but obviously the libs have been changed again... This is a bit of a hassel for beginners like myself, because one can expect that ones code wont compile every two to three years due to changes in libs and I would not know how to identify the relevant libs myself at the time being... (I saw that there is a Hello_Triangle example delivered with the OS under /opt/vc/src/hello_pi/ , maybe with more experience I would be able to extract the relevant information from there...)

I could locate all libs in the snapshot provided by Brian except "pthread", but adding the "other compiler option" -lpthread just did the trick...  

Also, I still specified the libs with full name and relative path as advised in the article, which worked... e.g.
../../../../../opt/vc/lib/libbcm_host.so
etc.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)