Installing flex (lexical analyzer) on Mac - c

Can someone tell me how I can install flex (lexical analyzer) on my Mac? I searched everywhere on google and I can't find it. I have the universal binary and I extracted it to my desktop but I have no idea where to go from here. Any help would be greatly appreciated!

Try using Homebrew (Packet manager for Mac) and use the following command :-
brew install flex

You can use macports to install flex

You can always install from source. Download the tarball from the flex site, extract it, cd to the directory where you extracted it, and run the following:
./configure
make
make install
make clean
Assuming you have make and a C compiler on your Mac, which I believe all Macs have.

Flex is shipped with the xCode Command line tools; you only got to install them via xcode > preferences > downloads > Command line tools. This also includes gcc (Clang).

This info can help to somebody to save time:
Just today I have try to install FLEX 2.5.39 from sources.
Make - fails.
After some thoughts I have decide to try older archives.
2.5.38 - fail
2.5.37 - OK
It seems on now() = 2015-03-15, macport also uses 2.5.37 build.

Related

Bluetooth C compiling

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

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.

How do you install zlib on aarch64?

I'm trying to see if I can get wagtail running locally on my Android phone (aarch64) with Termux. But it uses Pillow which has a dependency for zlib. I can't seem to find zlib on package depos like apt or pkg. Do I need to compile it from source? (Still a novice with Unix, sorry.)
zlib is already there in the NDK.
i was having the same problem. i have a note 8(samsung). just go to GitHub and install zlib from there, after that you will be avaible to install pillow.
You can fix this issue by running termux-chroot before running buildozer
buildozer expecte zlib to be
/usr/include/zlib.h
but in termux it is in
$PREFIX/include/zlib.h
By running termux-chroot, $PREFIX will be /usr

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

(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

Resources