Bluetooth C compiling - c

I am reposting this again in case missed out.
i have installed
sudo apt-get install libbluetooth-dev
and tried to compile btgatt-client.c from Blue5.54/tools/ with
gcc -o btgatt-client btgatt-client.c -lbluetooth
but get '#include "lib/bluetooth.h":no such file or directory'
What could be missing.I have tried move the files from '/usr/include/bluetooth'
the compilation folder but seems doesn't work. I am also curious where does this "src/shared/mainloop" from?
I am able to run the example and connect to nrf app but unable to compile the .c file.

The source files in BlueZ are not designed to be compiled singularly. Instead, you are supposed to build and install the entire BlueZ source, which in turn will compile btgatt-client.c for you. Please see the link below for instructions on how to build the entire BlueZ source:-
How to rebuild bluez
You will probably find that you need to install a lot of dependencies along the way, but you can either install these using sudo apt-get install <dependency> or try and not include it in the build. For example, to build BlueZ without systemd, you can do the following:-
./configure --disable-systemd
make
I hope this helps.

#Youssif Saeed. Thanks for the replies.
The good news is i have found out the cause.It seems the BlueZ bluetooth stack has an issue running in Raspbian Buster. I have downgrade the OS to Stretch and all seems up and running.
However i am trying gatt-client example and seems like not working when i set nrf app to advertising mode with exact UUID as in example. Or maybe i missed out certain part.Going to give a try with a simpler device like ESP32.
UPDATED
Thanks again guys.DBus gatt-client able to connect to BLMCU's. They key of operation is it needs to be paired > connected and read the BLE Server

Related

How to correctly run Cuda toolkit in Ubuntu in the WSL (eventually to be used for YOLO)?

I followed the tutorial here from the Medium: https://medium.com/#GuruAtWork/setup-fastai-ubuntu-on-windows-10-44ca50b13a9
I was following it well until a MinGW was used for command lines. I am not sure how they went about doing this as the only way I could get nvcc to work is with sudo apt install nvidia-cuda-toolkit. However, this does not seem to complete the same thing as their tool kit is installed as if the exe was just run with Windows. However, that, of course, doesn't work with the Ubuntu. Let me know what you think, thank you.
AFAIK it's just not possible right now to do so from WSL. The link from Medium only sets it up for the Git bash prompt, which is not the same as WSL.

FFmpeg: building example C codes

I have configured and compiled the FFmpeg library using this link:
https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu
Now, I am trying to build example C codes provided by FFmpeg from here:
https://github.com/FFmpeg/FFmpeg/tree/master/doc/examples
However, when I run make install-examples or make install (suggested by /example/README), I receive this kind of message:
make: *** No rule to make target '/doc/examples/README', needed by
'install-examples'. Stop.
I thought this may be due to the rules not being in the correct MakeFile format (I am not sure why they refers to README). How should I go about in fixing this and compiling the example codes? I have tried to find solutions about this, but there doesn't seem to be much information online.
Thank you.
Run ./configure && make -j4 examples in the FFmpeg source directory, then look in doc/examples for the compiled examples.
Requires make and pkg-config.
To remove the compiled examples use make examplesclean in the FFmpeg source directory.
nasm/yasm not found or too old. Use --disable-x86asm for a crippled build. If you think to configure made a mistake, make sure you are using the latest version from Git. If the latest version fails, report the problem to theffmpeg-user#ffmpeg.org mailing list or IRC #ffmpeg on irc.freenode.net.Include the log file "ffbuild/config.log" produced by configure as this will help solve the problem.
If you see this when you execute the above command then do this
macOS:
brew install yasm
Ubuntu:
sudo apt-get install yasm

LibFTDI correct compiling / build [ Raspbian ]

INTRODUCTION
Hi everyone, I'm making a project in Raspbian (Raspberry Pi3) using the async streaming feature of the libFTDI library.I first tried to build one of their examples that scans all the ftdi devices inside the Build directory following this guide using cmake and I run perfectly ./find_all getting all the FTDI devices, and that's good.
So I wanted to build a custom libFTDI project in another directory by my own and to compile it by the only compiler tool I know: Gnu C Compiler.
PROBLEM
Well, the compiler shows me no errors when I tried to compile out of the Build directory using a code of mine which has an #include libftdi with gcc -lusb -lftdi AND ./find_all gave me back that there's no device found at all.At this point I toke exactly the same piece of code inside 'find_all.c AND ./find_all STILL gave me back that there's no device found at allObviously before I ran gcc I installed all the libFTDI dependencies via apt-get install, to be more specific:
build-essential
git-core
cmake
doxygen
libusb
libconfude-dev
swig
python-dev
libboost-all-dev
QUESTION
Can anyone help me finding out what's wrong in it?I'd really like to use this wonderful library. I state that I'm a newbie in cmake stuff therefore I guess that even if I'm making a custom project (and not an example) using libFTDI most probably I also have to cmake. I should be grateful if someone explained to me how to cmake/build/gcc this library everywhere I want.
Thanks for the attention payed.

(Mac OSX) Adding libraries to C -specifically gnuplot

I am a begineer trying to get code in C. I am working on a Mac and using xcode. My only past experience has been with java using eclipse and everything was pretty straight forward. I have almost no experience with terminal.
I am required to learn a bit of C for a project I will be working on and the learning of syntax is coming along okay, but I am at a point where I need to include some libraries in my c program. Specifically I am attempting to make plots with gnuplots.
I have downloaded gnuplot-4.6.3 from their repository and I do not even know how to install the files. I have been looking around and have tried using terminal to use the ./configure command when I am in the gnuplot-4.6.3 directory. But I really don't know what I am doing so I don't even know where to go next or what to do next.
Sorry if this is so trivial, I honestly just have never done this before and I cannot find a good tutorial on what to do.
Thanks for any help you can offer.
I would recommend using MacPorts for installing third-party tools and libraries. It knows the dependencies required and will install them as part of the installation.
Download it from macports.org.
Install it, and allow it to modify your ~/.profile so that /opt/local/bin is in your $PATH (any issue then just do export PATH=/opt/local/bin:$PATH from the command line).
sudo port selfupdate
sudo port install gnuplot
Now that will install the library into /opt/local/lib with the include files in /opt/local/include, so now just add that library to your Xcode project. Select the target and in the Build Phases tab open up the Link Binary With Libraries and press the + button and select Add Other. Now find /opt/local/lib/libgnuplot.a (I am assuming that's what it's called; I don't have it installed my self):
Now add /opt/local/include to your Header Search Paths so the compiler can find the gnuplot header files. Select the target and in Build Setting type in "header search" in the search box. Now double-click on the Header Search Path in the target column (or the project column to the right) and add /opt/local/include:
It's fine! You're learning then! Keep up! When I hit this kind of problem you may want to learn about the basis for linux gcc/g++ compilation and linking processes. Then you should learn Cmake and Automake, which are basically packages to configure projects before compiling building.
A typical (good) project in Unix systems build with commands
./configure
make
sudo make install
or
cmake CMakelists.txt
make all
sudo make install
That's what you need to do after downloading a source tarball online to install unix programs.
Now since you are using Mac, there are so-called package installers, one which is macports and homebrew. I personally suggest homebrew than macports here (I've tried both, although macports still outnumber homebrew with the number of repos, homebrew has the newest support, especially when upgrading to a new OS). So to install homebrew you can do
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Execute that in your terminal (see http://brew.sh/) for more information.
Then you could simply install GNUplot by
brew install gnuplot

How to set up libusb on Mac OS X?

I'd like to try to make a user-space device driver using libusb on Mac, but I'm confused where to start. In the SDK installer (which I got from http://www.ellert.se/twain-sane) it said something about examples which I couldn't find anywhere on my computer.
Could anyone please describe how do I set up libusb for development on OS X? May I use Xcode? What should I include in my code?
brew install libusb-compat
Working on OSX Yosemite 10.10
Easiest way to do this:
brew install libusb
Homebrew is amazing and I recommend it for all developers that use Mac.
I tried to install the SDK from the aforementioned website and couldn't find a trace of it once the installer finished. Though I did find some libusb items at /usr/local/Developer/SDKs/MacOSX10.6.sdk/usr/local/ I'm not sure it came from that installer as I couldn't find any examples, just libraries and they were labeled as libusb0.1.4.
On the other hand, since you asked your question with the macports tag, I'd suggest you use that to install libusb as it at least puts everything in a known location:
/opt/local/var/macports/software for install files
/opt/local/lib for libraries
/opt/local/include for header files
If you've never used macports then once you have macports installed then you can install libusb using
sudo port install libusb
to install libusb1.0 or
sudo port install libusb-legacy
to install libusb0.1.12.
Then you can create a project in Xcode and link to the libusb-*.a library contained in /opt/local/lib (in my directory my library file is called libusb-1.0.a since I have libusb1.0 installed).
I don't have much experience using Xcode so I can't help you any further down this path. Personally what I've done so far is use a Python wrapper called pyusb to do some quick experimentation with libusb as I don't have to do IDE setup or library/include file setup with Python.
UPDATE: Poking around the macports install directory for libusb, I didn't find any examples included which was a bummer. If you've gotten this far then I'd suggest going directly to the source for libusb, download and unpack the tar file, and building the code that's in the example directory. Sorry for the roundabout way of getting libusb examples but I've really come to appreciate the organization macports imposes on installations which saves me quite a bit of future pain (like when I want to uninstall).
once libusb is installed using following command:
brew install libusb
or
brew install libusb-compat
link libusb to the build system using
brew link libusb
to be able to configure any project depending on libusb, use pkg-config:
pkg-config --cflags libusb-1.0
and
pkg-config --libs libusb-1.0
before calling any ./configure

Resources