From owner-freebsd-questions@FreeBSD.ORG Tue Apr 20 11:42:07 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C33FE16A4CE for ; Tue, 20 Apr 2004 11:42:07 -0700 (PDT) Received: from clanbuckbuck.org (c-67-160-113-101.client.comcast.net [67.160.113.101]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4030A43D4C for ; Tue, 20 Apr 2004 11:42:07 -0700 (PDT) (envelope-from freebsd@fbsdsolutions.com) Received: from RYALLS1 (iustsecurc1202-ge-1-0.msft.net [207.46.238.133]) (AUTH: LOGIN ryallsd, TLS: TLSv1/SSLv3,128bits,RC4-MD5) by clanbuckbuck.org with esmtp; Tue, 20 Apr 2004 11:42:06 -0700 From: "Derrick Ryalls" To: freebsd-questions@freebsd.org Date: Tue, 20 Apr 2004 11:41:19 -0700 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.6626 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 Importance: Normal Subject: Accessing MySQL from C X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Apr 2004 18:42:07 -0000 I am trying to write a little program that will talk to my existing mysql db server (4.1.1), but am having compile issues. The code is: #include #include #define HOST "localhost" #define USERNAME "test" #define PASSWORD "test" #define DB "pollphp" MYSQL *conn; int main() { conn = mysql_init(NULL); } And here are various compile attempts: # gcc -o sqltest sqltest.c sqltest.c:2: mysql.h: No such file or directory # gcc -L/usr/local/include/mysql -o sqltest sqltest.c sqltest.c:2: mysql.h: No such file or directory If I change the above include to: #include I get this on compile: # gcc -o sqltest sqltest.c /tmp/ccrC5KFf.o: In function `main': /tmp/ccrC5KFf.o(.text+0xc): undefined reference to `mysql_init' And if I and the -l flag: # gcc -o sqltest -l/usr/local/lib/mysql/libmysqlclient.so sqltest.c /usr/libexec/elf/ld: cannot find -l/usr/local/lib/mysql/libmysqlclient.so (I also tried libmysqlclient.a and libmysqlclient) I have gotten as far as I can with the man pages for gcc, and google isn't helping much. Does anyone know how I can compile a program that talks to mysql? TIA -Derrick