• C

cannot find -lib file

Hi! Experts,
I'm trying to run this code. I'm using dev-c++ to run this.

//== main.c ====================
#include <stdio.h>
#include <string.h>
#include "CUnit/Basic.h"

/* Pointer to the file used by the tests. */
static FILE* temp_file = NULL;

/* The suite initialization function.
 * Opens the temporary file used by the tests.
 * Returns zero on success, non-zero otherwise.
 */
int init_suite1(void)
{
   if (NULL == (temp_file = fopen("temp.txt", "w+"))) {
      return -1;
   }
   else {
      return 0;
   }
}

/* The suite cleanup function.
 * Closes the temporary file used by the tests.
 * Returns zero on success, non-zero otherwise.
 */
int clean_suite1(void)
{
   if (0 != fclose(temp_file)) {
      return -1;
   }
   else {
      temp_file = NULL;
      return 0;
   }
}

/* Simple test of fprintf().
 * Writes test data to the temporary file and checks
 * whether the expected number of bytes were written.
 */
void testFPRINTF(void)
{
   int i1 = 10;

   if (NULL != temp_file) {
      CU_ASSERT(0 == fprintf(temp_file, ""));
      CU_ASSERT(2 == fprintf(temp_file, "Q\n"));
      CU_ASSERT(7 == fprintf(temp_file, "i1 = %d", i1));
   }
}

/* Simple test of fread().
 * Reads the data previously written by testFPRINTF()
 * and checks whether the expected characters are present.
 * Must be run after testFPRINTF().
 */
void testFREAD(void)
{
   unsigned char buffer[20];

   if (NULL != temp_file) {
      rewind(temp_file);
      CU_ASSERT(9 == fread(buffer, sizeof(unsigned char), 20, temp_file));
      CU_ASSERT(0 == strncmp(buffer, "Q\ni1 = 10", 9));
   }
}

/* The main() function for setting up and running the tests.
 * Returns a CUE_SUCCESS on successful running, another
 * CUnit error code on failure.
 */
int main()
{
   CU_pSuite pSuite = NULL;

   /* initialize the CUnit test registry */
   if (CUE_SUCCESS != CU_initialize_registry())
      return CU_get_error();

   /* add a suite to the registry */
   pSuite = CU_add_suite("Suite_1", init_suite1, clean_suite1);
   if (NULL == pSuite) {
      CU_cleanup_registry();
      return CU_get_error();
   }

   /* add the tests to the suite */
   /* NOTE - ORDER IS IMPORTANT - MUST TEST fread() AFTER fprintf() */
   if ((NULL == CU_add_test(pSuite, "test of fprintf()", testFPRINTF)) ||
       (NULL == CU_add_test(pSuite, "test of fread()", testFREAD)))
   {
      CU_cleanup_registry();
      return CU_get_error();
   }

   /* Run all tests using the CUnit Basic interface */
   CU_basic_set_mode(CU_BRM_VERBOSE);
   CU_basic_run_tests();
   CU_cleanup_registry();
   return CU_get_error();
}
//============================================

It's giving error when I compile it, even I have already provided the path of "lib" folders.
Result of make file:
====================================
Compiler: Default compiler
Building Makefile: "C:\working\Dev-Cpp\essconfig_api\Makefile.win"
Executing  make...
make.exe -f "C:\working\Dev-Cpp\essconfig_api\Makefile.win" all
gcc.exe -D__DEBUG__ objs/conn_man.o objs/reach_pbx_config.o objs/reach_pbx_extn_map.o objs/sip_app_log_config.o objs/sip_call_config.o objs/sip_call_logs.o objs/sip_dial_plan.o objs/sip_dial_plan_dest.o objs/sip_license_config.o objs/sip_proxy_config.o objs/sip_proxy_domain.o objs/sip_proxy_server.o objs/sip_trunk_grp.o objs/sip_trunk_grp_member.o objs/sip_users.o objs/main.o objs/api_initializer.o  -o "exec\essconfig_api.exe" -L"C:/working/Dev-Cpp/lib" -L"C:/Program Files/CUnit-2.1-0/lib" -lmySQL  -libcunit -libcunit_dll  -g3
c:\MinGW\bin\..\lib\gcc-lib\mingw32\3.2.3\..\..\..\..\mingw32\bin\ld.exe: cannot find -libcunit

make.exe: *** [exec/essconfig_api.exe] Error 1
Execution terminated
=====================================

Please tell me where I'm doing wrong. :(

rrahulguptaAsked:
Who is Participating?
 
jkrConnect With a Mentor Commented:
According to the naming conventions that gcc usually follows, make that read

-lcunit -lcunit_dll
0
 
rrahulguptaAuthor Commented:
Thanks :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.