cspec icon indicating copy to clipboard operation
cspec copied to clipboard

Missing symbols (unclear how to build and install)

Open nilbus opened this issue 10 years ago • 4 comments

The Readme is very lacking in the specifics of how to get started with building cspec. Here's what I tried:

$ ./autogen.sh
$ ./configure # also attempted with --prefix=/usr
$ make
$ sudo make install

In my project that I'll be testing, I created a test.c file as described in your README, with code copied from examples/sample/main.c:

#include <stdio.h>
#include <string.h>
#include <cspec.h>
#include <cspec_output_header.h>
#include <cspec_output_verbose.h>
#include <cspec_output_unit.h>

DESCRIBE(strcmp, "int strcmp ( const char * str1, const char * str2 )")

  IT( "returns 0 only when strings are equal" )
    SHOULD_EQUAL( strcmp("hello", "hello"), 0)
    SHOULD_NOT_BE_NULL( strcmp("hello", "world") )
  END_IT

  IT( "returns a negative integer when str1 is less than str2"  )
    SHOULD_BE_TRUE( strcmp("hello", "world") < 0 )
    SHOULD_BE_TRUE( strcmp("0123", "1321431") < 0 )
  END_IT

  IT( "returns a positive integer if str1 is greater than str2"  )
    SHOULD_BE_TRUE( strcmp("yellow", "world") > 0 )
    SHOULD_BE_TRUE( strcmp("9", "789") > 0 )
  END_IT

END_DESCRIBE

int main() {
  CSpec_Run( DESCRIPTION( strcmp ), CSpec_NewOutputHeader() );
  return 0;
}

Building test.c with gcc -o test test.c yields the following errors:

test.o: In function `strcmp_describe':
/vagrant/gtthreads/test.c:14: undefined reference to `CSpec_StartDescribe'
/vagrant/gtthreads/test.c:16: undefined reference to `CSpec_StartIt'
/vagrant/gtthreads/test.c:17: undefined reference to `CSpec_Eval'
/vagrant/gtthreads/test.c:18: undefined reference to `CSpec_Eval'
/vagrant/gtthreads/test.c:19: undefined reference to `CSpec_EndIt'
/vagrant/gtthreads/test.c:21: undefined reference to `CSpec_StartIt'
/vagrant/gtthreads/test.c:22: undefined reference to `CSpec_Eval'
/vagrant/gtthreads/test.c:23: undefined reference to `CSpec_Eval'
/vagrant/gtthreads/test.c:24: undefined reference to `CSpec_EndIt'
/vagrant/gtthreads/test.c:26: undefined reference to `CSpec_StartIt'
/vagrant/gtthreads/test.c:27: undefined reference to `CSpec_Eval'
/vagrant/gtthreads/test.c:28: undefined reference to `CSpec_Eval'
/vagrant/gtthreads/test.c:29: undefined reference to `CSpec_EndIt'
/vagrant/gtthreads/test.c:31: undefined reference to `CSpec_EndDescribe'
test.o: In function `main':
/vagrant/gtthreads/test.c:34: undefined reference to `CSpec_NewOutputHeader'
/vagrant/gtthreads/test.c:34: undefined reference to `CSpec_Run'
collect2: ld returned 1 exit status
make: *** [test] Error 1```

I attempted these steps on both OSX 10.9.2 and Ubuntu Linux with standard build tools installed and had the same results.

Am I installing cspec properly? Are there build flags that I am missing? Please point me in the right direction.

nilbus avatar Apr 21 '14 15:04 nilbus

Looks like I forgot to link with -lcspec.

That said, could you please update the readme with how to build and link this library rather than leaving that as assumed knowledge?

nilbus avatar Apr 21 '14 15:04 nilbus

Or if you prefer, I can put together a pull request based on my attempt.

nilbus avatar Apr 21 '14 15:04 nilbus

Hi,

thank you for your feedback. Please create a pull request and I'll process it with github.

Arnaud

On Mon, Apr 21, 2014 at 5:17 PM, Edward Anderson [email protected]:

Or if you prefer, I can put together a pull request based on my attempt.

Reply to this email directly or view it on GitHubhttps://github.com/arnaudbrejeon/cspec/issues/2#issuecomment-40943050 .

arnaudbrejeon avatar Apr 27 '14 10:04 arnaudbrejeon

Sorry I haven't followed through on this. The project I was using this with is finished, and I won't have time to update the readme anymore. Feel free to take care of this yourself or close the issue. Thanks!

nilbus avatar Jun 06 '14 00:06 nilbus