Solved

cannot find -lib file

Posted on 2006-11-27
2
545 Views
Last Modified: 2007-12-19
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. :(

0
Comment
Question by:rrahulgupta
2 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
ID: 18020906
According to the naming conventions that gcc usually follows, make that read

-lcunit -lcunit_dll
0
 

Author Comment

by:rrahulgupta
ID: 18021540
Thanks :)
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Need example 5 122
Socket Programming (Unix) 8 142
change colour of repeater control in asp.net c# 7 113
Raspberry Pi 3 to send text message 9 151
Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question