getting unknown type name uint8_t errors when using libgit2 as a shared library

112 Views Asked by At

I'm trying to use the third-party library libgit2 in my C project, but I'm encountering errors when trying to compile. While using systems like github codespaces, Windows, or my MacOS X ventura workstation, I've tried the following command to compile:

$ gcc-13 -L./libgit2-1.6.4/build -I./libgit2-1.6.4/include/git2 main.c ini.c

However, this results in the following error:

In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/usr/include/sys/wait.h:110,
                 from /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/usr/include/stdlib.h:66,
                 from main.c:3:
/Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/usr/include/sys/resource.h:203:9: error: unknown type name 'uint8_t'
  203 |         uint8_t  ri_uuid[16];
      |         ^~~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/usr/include/sys/resource.h:204:9: error: ...

and running

clang -L./libgit2-1.6.4/build -I./libgit2-1.6.4/include/git2 -I./inih-r56 main.c                                                       

gives me

In file included from main.c:3:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/stdlib.h:66:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/wait.h:110:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/resource.h:203:2: error: unknown type name 'uint8_t'
        uint8_t  ri_uuid[16];
        ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/resource.h:204:2: error: unknown type name 'uint64_t'
        uint64_t ri_user_time;
        ^
.....

for context, my tree -L 2 looks like

├── inih-r56
│   ├── LICENSE.txt
│   ├── README.md
│   ├── cpp
│   ├── examples
│   ├── fuzzing
│   ├── ini.c
│   ├── ini.h
│   ├── meson.build
│   ├── meson_options.txt
│   └── tests
├── libgit2-1.6.4
│   ├── AUTHORS
│   ├── CMakeLists.txt
│   ├── COPYING
│   ├── README.md
│   ├── SECURITY.md
│   ├── api.docurium
│   ├── build
│   ├── ci
│   ├── cmake
│   ├── deps
│   ├── docs
│   ├── examples
│   ├── fuzzers
│   ├── git.git-authors
│   ├── include
│   ├── package.json
│   ├── script
│   ├── src
│   └── tests
└── main.c

and inside libgit2-1.6.4/build looks like

├── CMakeCache.txt
├── CMakeFiles
│   ├── 3.26.3
│   ├── CMakeConfigureLog.yaml
│   ├── CMakeDirectoryInformation.cmake
│   ├── CMakeRuleHashes.txt
│   ├── CMakeScratch
│   ├── Makefile.cmake
│   ├── Makefile2
│   ├── TargetDirectories.txt
│   ├── cmake.check_cache
│   ├── pkgRedirects
│   └── progress.marks
├── CTestTestfile.cmake
├── Makefile
├── cmake_install.cmake
├── deps
│   ├── http-parser
│   └── ntlmclient
├── include
│   ├── git2
│   └── git2.h
├── libgit2.pc
├── src
│   ├── CMakeFiles
│   ├── Makefile
│   ├── cli
│   ├── cmake_install.cmake
│   ├── libgit2
│   └── util
└── tests
    ├── CMakeFiles
    ├── CTestTestfile.cmake
    ├── Makefile
    ├── cmake_install.cmake
    ├── headertest
    ├── libgit2
    └── util

I've also successfully used the static header source pair for inih, but I'm not sure what I'm doing wrong with libgit2. Can someone help me figure out what the issue might be? Thank you in advance for any help yoyour textu can provide.

0

There are 0 best solutions below