开发者

Mac proj.4 compile error

I installed proj.4 library with homebrew on my Mac 10.7 (using gcc-4.2). When trying to compile the following code:

#include <proj_api.h>


int main(void) {
    projPJ pj_merc;
    pj_merc = pj_init_plus("+proj=merc");
    pj_free(pj_merc);
    return 0;
}

I'm getting this error:

$ gcc-4.2 test.c 
Undefined symbols for architecture x86_64:
  "_pj_init_plus", referenced from:
      _main in cccf4vey.o
  "_pj_free", referenced from:
      _main in c开发者_StackOverflow社区ccf4vey.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status

EDIT: The library file is 64bit (gcc-4.2 -m32 test.c lead to the same error):

$ file /usr/local/lib/libproj.dylib 
/usr/local/lib/libproj.dylib: Mach-O 64-bit dynamically linked shared library x86_64

Any ideas what's wrong?

Thank you!


You should link against the library.

gcc-4.2 test.c -L/usr/local/lib -lproj

This is what the error is complaining about

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜