使用-static的未定义引用? [英] Undefined reference with -static?
问题描述
当我尝试使用 CFLAGS = -static
编译程序时,收到错误的未定义引用。
When I try to compile my program with CFLAGS = -static
i receive an error undefined reference.
当没有静态编译时,完美地工作了。
When compiling without static works perfectly.
我的问题是为什么静态错误会给我未定义的引用?
我用 pkg安装mysql57-server
并链接了 mysql_config --libs
My question is why the static error gives me undefined reference?
I installed with pkg install mysql57-server
And linked mysql_config --libs
帮助?
推荐答案
链接静态库时,它们的顺序命令行问题(至少在FreeBSD上如此)。尝试在所有库之前/之后放置 -lmysqlclient
。
When linking static libs, the order in which they come in command line matters (well, at least on FreeBSD). Try putting -lmysqlclient
before/after all libraries.
并确保其中有 /当然也是usr / local / lib / mysql / libmysqlclient.a
。
这篇关于使用-static的未定义引用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!