Bug 175872

Summary: databases/mysql55-client: Static linking to libmysqlclient_r.a results in charset is not a compiled character set error
Product: Ports & Packages Reporter: mack
Component: Individual Port(s)Assignee: Alex Dupre <ale>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Latest   
Hardware: Any   
OS: Any   

Description mack 2013-02-06 05:40:00 UTC
Trying to connect to a mysql database through C works fine, as long as the program is linked dynamically.

Linking statically (gcc -static ...) results in the error:

Character set 'latin1' is not a compiled character set and is not specified in the '/usr/local/share/mysql/charsets/Index.xml' file
Error 2: Can't initialize character set latin1 (path: /usr/local/share/mysql/charsets/)

even though the charset is at least included in /usr/local/share/mysql/charsets/Index.xml:

[mack@admin ~/sources]$ grep -w latin1 /usr/local/share/mysql/charsets/Index.xml
<charset name="latin1">
  <alias>latin1</alias>
[mack@admin ~/sources]$

Tested on mysql-client-5.5.29.

How-To-Repeat: Just try to connect to a MySQL database from C:
=====================================================
#include <stdio.h>
#include <stdlib.h>
#include <mysql.h>

int main(int argc, char *argv[]) {
 MYSQL *mysql;

 if (mysql_library_init(0, NULL, NULL)) {
        fprintf(stderr, "Error 1: %s\n", mysql_error(mysql));
        exit(-1);
 }
 mysql = mysql_init(NULL);
 if (!mysql_real_connect(mysql, "db_server.host.name","dbuser","password", "db_name", 0,NULL,0)) {
        fprintf(stderr, "Error 2: %s\n", mysql_error(mysql));
        exit(-1);
 }
}
===================================================================

and compile it statically:

gcc -static -o mt -I/usr/local/include/mysql -L/usr/local/lib/mysql mt.c -lmysqlclient_r -lz -lm
Comment 1 Mark Linimon 2013-02-06 08:00:57 UTC
To which port does this PR apply?
Comment 2 Edwin Groothuis freebsd_committer freebsd_triage 2013-02-07 06:12:07 UTC
Responsible Changed
From-To: freebsd-ports-bugs->ale

Over to maintainer (via the GNATS Auto Assign Tool)
Comment 3 Alex Dupre freebsd_committer freebsd_triage 2013-02-07 08:29:47 UTC
State Changed
From-To: open->closed

You should add '-pthread' to compile command.