views:

68

answers:

3

I have to compile a .c file that came with a matlab toolbox.

To this end I downloaded xcode 3.1.4, and now I am trying commands like

gcc -o solvemc solvemc.c

and getting errors like

Undefined symbols:
  "_N_VFree", referenced from:
      _main in cca0ChgX.o
      _main in cca0ChgX.o
      _main in cca0ChgX.o
      _main in cca0ChgX.o
      _main in cca0ChgX.o
      _main in cca0ChgX.o
  "_CVDiag", referenced from:
      _integrate in cca0ChgX.o
      _docollapse in cca0ChgX.o
      _mcwfalg in cca0ChgX.o
  "_CVode1", referenced from:
      _integrate in cca0ChgX.o
      _docollapse in cca0ChgX.o
      _mcwfalg in cca0ChgX.o
      _mcwfalg in cca0ChgX.o
  "_setall", referenced from:
      _main in cca0ChgX.o
  "_CVodeFree", referenced from:
      _integrate in cca0ChgX.o
      _docollapse in cca0ChgX.o
      _mcwfalg in cca0ChgX.o
  "_genunf", referenced from:
      _docollapse in cca0ChgX.o
      _mcwfalg in cca0ChgX.o
      _mcwfalg in cca0ChgX.o
      _mcwfalg in cca0ChgX.o
  "_CVodeMalloc", referenced from:
      _integrate in cca0ChgX.o
      _docollapse in cca0ChgX.o
      _mcwfalg in cca0ChgX.o
  "_N_VNew", referenced from:
      _mcwfalg in cca0ChgX.o
      _main in cca0ChgX.o
      _main in cca0ChgX.o
      _main in cca0ChgX.o
      _main in cca0ChgX.o
      _main in cca0ChgX.o
      _main in cca0ChgX.o
      _main in cca0ChgX.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
+1  A: 

You probably need to link in the math library. Add a -lm to your gcc line.

jkoelker
so that may be true... but adding -lm on its own doesn't fix it, and i'm not sure how to download/find the libraries i need
atp
Look at the includes in the .c file. They will usually lead you to what libraries it uses.
jkoelker
+2  A: 

Looks like you're missing one or more libraries - check the Matlab docs as to which libraries are required in order to compile your code.

Will A
+2  A: 

You're missing some libraries. Look at what libraries your code uses and add link parameters to your gcc line: -l<libname>. You may have to add paths too: -L/path/to/libdir.

Nathon