1

I'm trying to set up CUnit for use on Red Hat Enterprise Linux. This is my test file in c:

#include <CUnit/CUnit.h>

int main() {
    return 0;
}

At first, I was getting an error when using gcc cunit-test.c -lcunit:

/usr/bin/ld: cannot find -lcunit
collect2: error: ld returned 1 exit status

So I made a symlink so that /usr/lib64/libcunit.so points to /usr/lib64/libcunit.so.1, which fixed that error.

However, I'm still not able to use the CUnit files. When I compile my test file, with gcc cunit-test.c -lcunit I get the error

cunit-test.c:1:10: fatal error: CUnit/CUnit.h: No such file or directory
 #include <CUnit/CUnit.h>
          ^~~~~~~~~~~~~~~
compilation terminated.
grevans
  • 11
  • 2
  • I bet you forgot to install the CUnit-devel package. – Shawn Aug 08 '23 at 18:21
  • @Shawn I can't find CUnit-devel in the repositories, only CUnit (in x64_86 and i686 flavors) shows up. However, I can see the CUnit-devel package and others in https://access.redhat.com/downloads/content/package-browser. Do you know why these packages aren't showing up on my machine? – grevans Aug 08 '23 at 18:26
  • Don't have the right repositories being used? Dunno, I don't use red hat. – Shawn Aug 08 '23 at 18:32

1 Answers1

0

I was able to solve this question thanks to @Shawn.

To use CUnit, you need two packages: CUnit and CUnit-devel. The CUnit package is in the default RHEL repositories, but the CUnit-devel package is in a repository called codeready-builder. To use CUnit on RHEl, you need to run sudo subscription-manager repos --enable codeready-builder-for-rhel-8-x86_64-rpms (or rhel-9 if you are using RHEL 9, etc.) to enable the repository, then install the CUnit-devel package. Then you should be able to compile your program with gcc cunit-test -lcunit.

grevans
  • 11
  • 2