compile and link C/CPP programs on Mac

Posted sonictl

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了compile and link C/CPP programs on Mac相关的知识,希望对你有一定的参考价值。

ref: https://stackoverflow.com/questions/29987716/cannot-use-gsl-library-on-macos-ld-symbols-not-found-for-architecture-x86-6

Indeed, as @trojanfoe and @bergercookie said you have to compile your file and then link it to the library. As explained in compile and link, for that particular example:
First compile the file:
gcc -Wall -I/usr/local/include -c example.c -o example.o
second, link it to the library:
gcc -L/usr/local/lib example.o -lgsl -o example
where of course, /usr/local/lib should be replaced for the path where you have gsl installed.
The example file is excutable.
EDIT: in macOS, from Yosemite the default location for the installation is /opt/local/lib (and /opt/local/include)

以上是关于compile and link C/CPP programs on Mac的主要内容,如果未能解决你的问题,请参考以下文章

Fatal Python error: pycurl: libcurl link-time version is older than compile-time version

c_cpp CPP-Datatypes_Size_and_Range

angular之link和compile的区别

angularjs link compile与controller的区别详解,了解angular生命周期

CF821 C. Okabe and Boxes 栈模拟

directive(指令里的)的compile,pre-link,post-link,link,transclude