Archived Forum Post

Index of archived forum posts

Question:

Cannot link C sample code pgms with XCode 6.1

Jun 11 '15 at 12:31

Hello,

I'm trying to compile and link the sample C programs provided on the web site. I followed the install lib instructions, but despite my efforts i cannot solve the numerous linker errors i get :

Undefined symbols for architecture x86_64:
  "_CkEmail_AddTo", referenced from:
      _main in main.o
  "_CkEmail_Create", referenced from:
      _main in main.o
  "_CkEmail_Dispose", referenced from:
      _main in main.o
  "_CkEmail_putBody", referenced from:
      _main in main.o
  "_CkEmail_putFrom", referenced from:
      _main in main.o
  "_CkEmail_putSubject", referenced from:
      _main in main.o
  "_CkMailMan_CloseSmtpConnection", referenced from:
      _main in main.o
  "_CkMailMan_Create", referenced from:
      _main in main.o
  "_CkMailMan_Dispose", referenced from:
      _main in main.o
  "_CkMailMan_SendEmail", referenced from:
      _main in main.o
  "_CkMailMan_UnlockComponent", referenced from:
      _main in main.o
  "_CkMailMan_lastErrorText", referenced from:
      _main in main.o
  "_CkMailMan_putSmtpHost", referenced from:
      _main in main.o
  "_CkMailMan_putSmtpPassword", referenced from:
      _main in main.o
  "_CkMailMan_putSmtpUsername", referenced from:
      _main in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Any idea ? Thks


Answer

Is your "main.o" compiled from "main.c" or "main.cpp"?

In other words, is your program C++ or "C"? If C++, then you would probably want to encapsulate any Chilkat "C" headers in "extern "C" { ... }".

(If your program is C++, I would also wonder why you would choose to use the "C" API vs. the Chilkat C++ classes.)


Answer

Also see: How to Link with a Static Library in XCode