Raspberry Pi crashes when building OpenFrameWorks project in Eclipse CDT - c++

I'm working on a Raspberry Pi 3 with OS Raspbian Jessie. I'm using Eclipse CDT (for C/C++) and am trying to learn about OpenFrameWorks:
http://openframeworks.cc/
I installed everything according to the guides and imported everything to Eclipse. I thought it seemed to work out, but when I try to run some test-code I get the error "Unable to launch, binary not found." I look it up and find a potential solution, that I have to build the actual project first.
This is my problem, when I try to build the project Eclipse gets to about 20% and then the entire Raspberry freezes, forcing me to force a restart. How can I continue from here on out? I don't know if I still should try to build the project through Eclipse or if there is another way to actually run some test code for OpenFrameWorks.
I don't know if this is the best place to ask about this, but I'm thankful for all answers.

Eclipse is super slow on Raspberry Pi.
I recommend using the provided setup scripts to install dependencies. After you compile OF, use make files to compile projects.
In terms of editing code, I recommend using a light weight text editor (geany for example). I've tried CodeBlocks and Qt Creator, which are faster/less resource intensive than eclipse, but still pretty heavy for a system with limited resources.
Another option is to combine your computer the RPi:
Use projectGenerator to generate a project for both Raspberry Pi and your computer/IDE
Edit/test/iterate on your computer
When ready to run on RPi, sync the project using your preferred method(e.g. SSH/SFTP/git/etc.), then use make -j4(to use all 4 cores) in the RPi project folder.
The pro is you the quick compile/feedback times you're used to on your computer.
The con is this method won't work for RPi specific code (e.g. accessing GPIO, PiCamera, etc.)
Another option is to setup cross compilation, but getting everything ready is a bit laborious. (Although, once it's done, it saves time on the long run).

Related

VS2017 - How to configure project for remote debugging

I want to create an MP3 player on my Raspberry Pi (OS: Raspbian). The problem is, that i don't have any experience with Linux programming, and I'm having a huge problem with project configuration, becouse of cross platform compiling. I want to add two liblaries:
mpg123
libao
I'm able to compile the code on linux machine with gcc -O2 test.cpp -lmpg123, but I can't force Visual Studio to make see those libs.
I'm also having a problem with using wiringPi lib while I'm trying to remote debugging my program, since I have to run it as root for GPIO configuration. Is there any way for any way to force Visual Studio to run my compiled code with root privilages?
Personally I come from a long history of C/C++/MFC/Windows programming with no Linux experience at all. I started programming for the Raspberry a year or so ago, when I got one from my son for my birthday. With a C/C++ history it's really not that hard, but you just have to read in a bit because on Linux a lot is the same, and a lot isn't :). Just read and read and in time, you're an experienced Linux programmer! It takes some time I'm afraid.
So, I'm sort of an experienced newbie on this I think :). I found a lot of info on www.die.net (and other Linux man pages). If you search there for a function, say printf(), look at the (3) pages - they explain how you should use 'm.
But although VS2017 does a really good job on this, it's not always going as smooth as you would like. Sometimes it's just necessary to reboot your Raspberry, restart VS and try again. The Linux cross-compiling is quite new in VS and isn't perfect yet.
A few tips:
Use a Raspberry with a fresh Stretch image to start with. Of course after a sudo apt-get update && sudo apt-get -y upgrade.
Set the debugger in Visual Studio to gdb instead of gdbserver. This will prevent certain debugging problems.
Place all your source files (.h and .cpp) in the main folder of your project alongside the main.cpp. If you place them in different directories and then include in your project, you can debug your program but you won't be able to step through.
Start simple and debug your program often when you're developing. Don't add too much code before your next check. In a cross-compile setup there are just a lot more things than normal that can (and will) go wrong.
VS2017 has default Linux include files in C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\Linux\include. If you need others, place them in a folder of you own and include the path.
With cross-compiling VS itself doesn't do any compiling, you use it to maintain your project. When the project has to be compiled, all necessary files are copied to the Raspberry and the compiler and linker there are invoked by VS.
On your question how to configure a project for remote debugging: it's probably best to start with the Blink example in Visual Studio 2017 (File, New, Project, Installed, Visual C++, Cross Platform, Linux => Blink). It should run without problems. From there, you can build further on your project.
In the Blink example, they use wiringPiSetupSys() and the remote command gpio export 17 out to run your program without sudo. I've found that changing that to wiringPiSetup() and disabling the remote command, it still is possible to run and debug the program. On the Raspberry I can run the program from it's folder by issuing ./[programname]. If that doesn't work for you, you could run the program by issuing sudo ./[programname].

MySql connector-c++ wont link in QtCreator but works fine locally on raspberry pi3

Firstly, thank you in advance for at least reading this question.
Secondly, feel free to call me an idiot if this is a "no brainer"
Now down to the issue at hand...
I am running Ubuntu 16.04 (64bit) with QT Creator as my IDE and on the whole it works great. I can cross compile for the Raspberry Pi3 (running raspbian) and also compile plugins for X-Plane.
Everything was going great until I needed to implement MySql into my project. That's when it all went south.
I can not use the Qt library for this as X-Plane does not like anything Qt related in its plugins. But that is fine, I have connector-c++ working on that machine and it connects to my MySql server and does everything it's supposed to.
I think I have read just about every forum and watched every youtube video on this but can not get Qt Creator to compile with connector for the raspberry pi.
I wrote/compiled a test app locally (with g++) on the pi and it works great. However for some reason (government plot maybe?) it refuses to link the libraries when compiling under Qt Creator.
The error I get when compiling in QtCreator is:
undefined reference to `get_driver_instance'
Currently,
I have followed the instructions for setting up a cross compiler here:
https://wiki.qt.io/RaspberryPi2EGLFS
Downloaded the connector code from here:
git clone https://github.com/mysql/mysql-connector-cpp
I have followed the instructions for compiling connector-c++ here:
https://dev.mysql.com/doc/connector-cpp/en/connector-cpp-installation-source-unix.html
And I have banged my head 1000x on a brick wall here:
(picture of blood stained wall not available)
Also, I have tried compiling connector on my Ubuntu pc with paths to the pi's sysroot etc. but i think it made a 64bit version which causes Qt Creator to have a dummy spit about "unrecognized format".
I am hoping that this is just me having a "senior moment" and that someone can point me in the right direction.
To save putting up irrelevant logs/code I will wait until someone asks for it and then copy/paste what they need.
Again, thanks in advance and know that I will be eternally grateful for any light on this matter (preferably before I go even insanerer)
Well after 2 weeks of pain, I have solved this problem. Here is what I think is the issue:
Firstly, I found that mysqlcppconn is not needed (at least for me) and used the mysql libraries in /usr/lib
Secondly, the symlinks to libmysqlclient.so.6.0.22 were by default:
libmysqlclient.so.6 -> libmysqlclient.so.6.0.22
The compiler was looking for libmysqlclient.so which didn't exist. So I created the link (libmysqlclient.so -> libmysqlclient.so.6) and it worked!!
Thanks to all who helped.

VSCode c++ configuring for vc toolchain

I'm trying to start a work in vscode , latest C++ plugin version supports ms debugger, so as I'm mostly working under windows it was a signal to try this.
c++ tools plugin from MS and cmake tools were installed.
my test project was however not built . the problem is clear , but I need an advice from experienced vscode users how to solve this right.
cmake doesn't see vc compiler.
(after using QtCreator) I expected that vscode could detect vc installation... however that's not so. ok, I have a two ways:
fill environment variables INCLUDE/LIB/PATH with a headers, libs and binaries
just run vcvarsall.bat x64
Second way is a simple and reliable. so final question is:
how to run .bat at the begining of vscode start?
(I don't mean write another bat/cmd, prepare the environment and run vscode inside the same script after that)
Although the question is fairly old, I'll try to give a useful answer, in case others stumble across, just like I did.
I believe what you are trying to achieve is not possible. Code inherits the environment it was started with. If you did not launch it from a developer command prompt, you will not be able build and debug. (Building might be possible if every task first starts the vcvarsall.bat, but that slows things down by a lot. Debugging I think will still not work.)
If you are willing to, you can check out vector-of-bools CMake Tools extension which does build automation as well as automatic MSVC detection. It builds using CMake (thus you need to write your build scripts using CMake), but it will take care of building just by pressing F7, like what most VS users are familiar with.

Netbeans always compiling from the beginning

I'm having a quite big C++ project in Netbeans. It takes about 3 minutes for it to compile (with -j5 mode enabled).
I'm using my VM server (FreeBSD) hosted on Windows 8 and using SFTP option to compile.
Everything is working like a charm except that it looks like Netbeans is always making clean while compiling (no clean messages appearing in the output console though!). It's really annoying for me to wait 3 minutes for each change I have to make in my source code.
My friend had a similar issue some time ago - it was related to the Netbeans timestamps files (different time setting on the local & remote VM machine). In my case the VM machine time setting is the same as on my PC.
I am currently running Netbeans version 7.3.1 (because later & latest version are having some odd SFTP issue not working correctly). I've also tried the latest beta build including earlier versions and it doesn't seem to solve my problem.
Whats the problem? I will appreciate every solution.
There is excellent article "Make Dependency Checking" on this topic by NetBeans team which is worth reading to understand this behaviour.
NetBeans internally uses make utility for dependency checking defined in Makefile. When we create a new project in NetBeans, it enables "Full rebuild" feature. This leads to this particular behaviour.
However if want to avoid this, we can change this particular feature to "Incremental rebuild".
For complete information and to understand its consequences, please refer the above article from NetBeans team.

Apply VST audio effect/plugin to audio-file

This is my first question after leeching over here for some time.. So spare me.
I need to apply the iZotope Vinyl VST effect to some audio files via CLI or C++ (so language doesn't really matter), it has to work on a Mac or on a Unix based system. I've researched all over the webs and can't find any working solution.
I've tried using MissWatson, a command line utility, this works but my result audio files are silent...
./MissWatson -plugin=Vinyl -input-file="/Users/Sjaq/Desktop/test.wav" -output-file="/Users/Sjaq/Downloads/MissWatson-v1.0-mac/res.wav" -parameter=1:0.6,2:0.6,11:0.4
Then I tried using the Steinberg VST SDK by creating a host application, starting from the vstvalidator provided by the SDK. But when I try to load the VST I get this error:
2010-12-01 16:57:40.774 vstvalidator[4654:903] Error loading /Library/Audio/Plug-Ins/VST/Vinyl.vst/Contents/MacOS/Vinyl: dlopen(/Library/Audio/Plug-Ins/VST/Vinyl.vst/Contents/MacOS/Vinyl, 262): no suitable image found. Did find:
/Library/Audio/Plug-Ins/VST/Vinyl.vst/Contents/MacOS/Vinyl: no matching architecture in universal wrapper
And I don't know what to do. I'm pretty new to C++ and and made a few apps without any issues, but this time I've hit a dead end.
I've read about pyvst but it seems to need a DLL for the VST so that didn't work either.
I'm the author of MissWatson, and as you probably noticed on the webpage, I unfortunately was required to close-source the code, so I can't really ask you for more diagnostic information, since I wouldn't be able to patch MissWatson if it's a bug there. However, I would recommend running MissWatson with the -verbose switch and perhaps logging that output to file if that floods your terminal. You might find something in that output which helps you to diagnose the problem.
Anyways, as for the error in your VST host, I have a feeling that you are compiling your app as a 64-bit executable and trying to load a 32-bit plugin. Since hardly any VST/AU plugins (and also sequencers, for that matter) have made the leap to 64-bit, you'd be better off just compiling your app as a 32-bit x86 binary.
By default, the "debug" configuration in Xcode only builds your app for the native architecture of your machine to save time during compilation. I would advise that you disable this feature in your project's build settings and always build with the architectures you plan to ship with. This will prevent weird cross-architecture types of errors like the one you saw above.
Edit: I have since started a new command-line VST host to replace MissWatson which is called MrsWatson. You should try using this tool instead.
Perhaps you can port the source code of this open source vst host to match your platforms?
http://www.hermannseib.com/english/vsthost.htm
Scroll down to the bottom of the page.
Hope it helps.