Detailed explanation How to run the sample code of UNIX programming 3rd edition on Mac

The Kindle book sale was half price, so I bought a book called Detailed UNIX Programming and started reading it.

51L6CwNG11L.SY346.jpg

When I tried to run the sample code on a Mac, I stumbled on various things, so I will leave the steps I took to make it work.

Mac version

$ sw_vers
ProductName:	Mac OS X
ProductVersion:	10.15.5
BuildVersion:	19F101

Compiler installation

$ brew install gcc

From header file download to make

$ curl -O http://www.apuebook.com/src.3e.tar.gz
$ tar xvfz src.3e.tar.gz
$ cd apue.3e/
$ make
$ ls
DISCLAIMER           include
Make.defines.freebsd intro
Make.defines.linux   ipc1
Make.defines.macos   ipc2
Make.defines.solaris lib
Make.libapue.inc     printer
Makefile             proc
README               pty
advio                relation
daemons              signals
datafiles            sockets
db                   standards
environ              stdio
exercises            systype.sh
figlinks             termios
filedir              threadctl
fileio               threads

Library and header placement

$ cp include/apue.h /usr/local/include/
$ cp lib/libapue.a /usr/local/lib/

Compiling sample code and executing files

$cd The path of the directory where the files you wrote are located
#This time, myls.Suppose you compile code c
#Compile with apue library
$ gcc -lapue myls.c
# a.A file called out will be generated, so check that it can be executed
$ ./a.out

Recommended Posts

Detailed explanation How to run the sample code of UNIX programming 3rd edition on Mac
How to run the practice code of the book "Creating a profitable AI with Python" on Google Colaboratory
How to access the contents of a Linux disk on a Mac (but read-only)
How to enjoy Python on Android !! Programming on the go !!
How to run the Export function of GCP Datastore automatically
How to run Python on Windows without polluting the environment as much as possible (Scoop edition)
How to implement Java code in the background of RedHat (LinuxONE)
How to use Jupyter on the front end of supercomputer ITO
How to update the python version of Cloud Shell on GCP
How to install mysql-connector-python on mac
How to install OpenCV on Mac
How to run matplotlib on heroku
How to run TensorFlow 1.0 code in 2.0
Supplement to the explanation of vscode
Load_data self-made to run Python MNIST sample code on your own dataset
How to play a video while watching the number of frames (Mac)
How to install drobertadams / toggl-cli on Mac
How to check the version of Django
How to erase Python 2.x on Mac.
Run Python code on A2019 Community Edition
How to run Cython on OSX Memo
How to make VS Code aware of the venv environment and its benefits
How to build an environment for using multiple versions of Python on Mac
Checklist on how to avoid turning the elements of numpy's array with for
How to calculate the volatility of a brand
How to find the area of the Voronoi diagram
Preparing to run ImageMagick + im4java on Mac OS
How to run MeCab on Ubuntu 18.04 LTS Python
[Mac] Run the RealSense D415 sample in Python
Command to check the total number of CPU physical cores / logical cores / physical memory on Mac
The world's most easy-to-understand explanation of how to make a LINE BOT (1) [Account preparation]
A memo on how to overcome the difficult problem of capturing FX with AI
[Implementation explanation] How to use the Japanese version of BERT in Google Colaboratory (PyTorch)