How to Fix the ‘argp.h’ Not Found Error on macOS

When compiling a Linux-oriented tool written in C/C++ on macOS, you might encounter the following error:

fatal error: ‘argp.h’ file not found
#include <argp.h>
^~~~~~~~
1 error generated.

This means that the library for parsing …


This content originally appeared on DEV Community and was authored by kojix2

When compiling a Linux-oriented tool written in C/C++ on macOS, you might encounter the following error:

fatal error: 'argp.h' file not found
#include <argp.h>
         ^~~~~~~~
1 error generated.

This means that the library for parsing command-line arguments, argp.h, is missing.

Solution

Fortunately, you can install this library using Homebrew.

brew install argp-standalone

After installing, verify the files:

brew ls argp-standalone
/opt/homebrew/Cellar/argp-standalone/1.3/include/argp.h
/opt/homebrew/Cellar/argp-standalone/1.3/lib/libargp.a
/opt/homebrew/Cellar/argp-standalone/1.3/sbom.spdx.json

Since there is no .pc file, you can't use pkg-config. Instead, you need to specify the paths directly.

cc hoge.c \
  -largp \
  -L /opt/homebrew/Cellar/argp-standalone/1.3/lib/ \
  -I /opt/homebrew/Cellar/argp-standalone/1.3/include/ \
  -o hoge

With these steps, you should be able to resolve the issue of missing argp.h on macOS.


This content originally appeared on DEV Community and was authored by kojix2


Print Share Comment Cite Upload Translate Updates
APA

kojix2 | Sciencx (2024-07-24T02:24:38+00:00) How to Fix the ‘argp.h’ Not Found Error on macOS. Retrieved from https://www.scien.cx/2024/07/24/how-to-fix-the-argp-h-not-found-error-on-macos/

MLA
" » How to Fix the ‘argp.h’ Not Found Error on macOS." kojix2 | Sciencx - Wednesday July 24, 2024, https://www.scien.cx/2024/07/24/how-to-fix-the-argp-h-not-found-error-on-macos/
HARVARD
kojix2 | Sciencx Wednesday July 24, 2024 » How to Fix the ‘argp.h’ Not Found Error on macOS., viewed ,<https://www.scien.cx/2024/07/24/how-to-fix-the-argp-h-not-found-error-on-macos/>
VANCOUVER
kojix2 | Sciencx - » How to Fix the ‘argp.h’ Not Found Error on macOS. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/07/24/how-to-fix-the-argp-h-not-found-error-on-macos/
CHICAGO
" » How to Fix the ‘argp.h’ Not Found Error on macOS." kojix2 | Sciencx - Accessed . https://www.scien.cx/2024/07/24/how-to-fix-the-argp-h-not-found-error-on-macos/
IEEE
" » How to Fix the ‘argp.h’ Not Found Error on macOS." kojix2 | Sciencx [Online]. Available: https://www.scien.cx/2024/07/24/how-to-fix-the-argp-h-not-found-error-on-macos/. [Accessed: ]
rf:citation
» How to Fix the ‘argp.h’ Not Found Error on macOS | kojix2 | Sciencx | https://www.scien.cx/2024/07/24/how-to-fix-the-argp-h-not-found-error-on-macos/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.