Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8652241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:15:48+00:00 2026-06-12T14:15:48+00:00

I started experimenting with the MySQL C API today, which I compiled today from

  • 0

I started experimenting with the MySQL C API today, which I compiled today from source on my 10.6.8 macbook, and rolled out a quick makefile + app skeleton. I feel a bit rusty, though, because I can’t seem to get it to link properly (fixed, now, it seems) or dynamically load the library (problem stated below).

The exact error I receive is below:

$ make clean && make
gcc -L/usr/local/mysql/lib -I/usr/local/mysql/include -lmysql -lpthread -ggdb -Wall -o adapter main.c adapter.c 

$ ./adapter
dyld: Library not loaded: libmysql.16.dylib
  Referenced from: /tmp/./adapter
  Reason: image not found
Trace/BPT trap

I looked around, and a lot of results regarding an install_name_tool came up. After reading through a few of those, though, I still don’t completely understand what this actually does. There was a lot of talk about Frameworks, which didn’t really fit into what I would expect to be involved in such a simple project..

Anyway, here is my code (including makefile).

main.c:

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "adapter.h"

int main (int argc, char *argv[]) {
    printf("Version: %s\n", get_version());
    return 0;
}

adapter.c:

#include <mysql.h>

char *get_version () {
    return (char *)mysql_get_client_info();
}

adapter.h:

char *get_version ();

Makefile:

CC = gcc
MYSQL_FLAGS = -L/usr/local/mysql/lib -I/usr/local/mysql/include -lmysql -lpthread
CFLAGS = -ggdb -Wall
OBJS = 

adapter: $(OBJS)
    $(CC) $(MYSQL_FLAGS) $(CFLAGS) -o adapter main.c adapter.c $(OBJS)

clean:
    @rm -f *~ *.o adapter
    @rm -rf *.dSYM

And, a side note, the files really do exist:

$ ls /usr/local/mysql/lib
libmysql.16.0.0.dylib   libmysql.dylib      libmysqlclient.dylib
libmysql.16.dylib       libmysqlclient.a    libmysqlclient_r.dylib

$ ls /usr/local/mysql/include
atomic          my_atomic.h     my_md5.h        myisampack.h        sslopt-case.h
base64.h        my_attribute.h  my_net.h        mysql.h             sslopt-longopts.h
config-win.h    my_base.h       my_no_pthread.h mysql_com.h         sslopt-vars.h
decimal.h       my_bit.h        my_nosys.h      mysql_time.h        t_ctype.h
errmsg.h        my_bitmap.h     my_pthread.h    mysql_version.h     thr_alarm.h
hash.h          my_charsets.h   my_stacktrace.h mysqld_error.h      thr_lock.h
keycache.h      my_config.h     my_sys.h        mysys               typelib.h
lf.h            my_dbug.h       my_time.h       mysys_err.h         violite.h
m_ctype.h       my_dir.h        my_tree.h       queues.h            waiting_threads.h
m_string.h      my_getopt.h     my_trie.h       service_versions.h  wqueue.h
my_aes.h        my_global.h     my_uctype.h     sha1.h
my_alarm.h      my_libwrap.h    my_vle.h        sha2.h
my_alloc.h      my_list.h       my_xml.h        sql_common.h

I have a gut feeling that something is wrong with my Makefile or it’s an issue particular to Mac OS X, but in reality, I’m really not sure what the problem is.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T14:15:49+00:00Added an answer on June 12, 2026 at 2:15 pm

    This is a dynamic linker error and has nothing to do with source code. There are a lot of ways to fix it. The simplest perhaps is to add /usr/local/mysql/lib to the DYLD_LIBRARY_PATH before you run adapter. For example:

    $ export DYLD_LIBRARY_PATH="${DYLD_LIBRARY_PATH}:/usr/local/mysql/lib"
    $ ./adapter
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Today I started experimenting with PHP-based PDF generators. I tried TCPDF and it works
I have just started learning MySQL and am having trouble extracting matching flights from
Today I have been experimenting with SQL binary objects. I started by storing an
I just started experimenting with Android app development and so I decided to give
I just started experimenting with java today (have experience with javascript and PHP) and
Greetings! Started experimenting with sIFR3 today and am in love! So great! For the
a couples days ago i started experimenting with Farseer, which is a simple and
I started experimenting with C# and HTML5 today. I thought this question would be
Today I started reading the documentation for django.forms . The API seems easy to
I've started experimenting with Hudson as a build server. I'm using subversion and have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.