Undefined reference with -static?
问题 When I try to compile my program with CFLAGS = -static i receive an error undefined reference. When compiling without static works perfectly. My question is why the static error gives me undefined reference? I installed with pkg install mysql57-server And linked mysql_config --libs Help ? 回答1: 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. And make sure there is /usr/local/lib