Thread: Nignx + Mysql: Problem linking on Linux (gcc/ld)

  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    10

    Unhappy Nignx + Mysql: Problem linking on Linux (gcc/ld)

    Hello Everyone,

    I.m kindy new to linux&nginx development, so please excuse any nub questions...

    Im having a problem linking nginx with mysql client libraries. Libraries are there and were installed with yum on my centos 5.0.

    Nginx uses a configuration file to append further customized modules to its source, the configuration file can go lot more complex but for the sake of sanity the line that matter for the problem is this one:

    CORE_LIBS="$CORE_LIBS -L/usr/lib/mysql -lmysqlclient"

    ..which instructs the compiler to add the library to the nginx compilation plan..

    all libs looks fine and are indeed on the right location:

    [root@localhost mysql]# cd /usr/lib/mysql
    [root@localhost mysql]# ll
    total 8268
    -rw-r--r-- 1 root root 1498 Mar 30 19:13 libdbug.a
    -rw-r--r-- 1 root root 50704 Mar 30 19:13 libheap.a
    -rw-r--r-- 1 root root 378224 Mar 30 19:13 libmyisam.a
    -rw-r--r-- 1 root root 30730 Mar 30 19:13 libmyisammrg.a
    -rw-r--r-- 1 root root 1640064 Mar 30 19:13 libmysqlclient.a
    -rw-r--r-- 1 root root 1652652 Mar 30 19:13 libmysqlclient_r.a
    lrwxrwxrwx 1 root root 26 Apr 27 11:21 libmysqlclient_r.so -> libmysqlclient_r.so.15.0.0
    lrwxrwxrwx 1 root root 26 Apr 15 14:20 libmysqlclient_r.so.15 -> libmysqlclient_r.so.15.0.0
    -rwxr-xr-x 1 root root 1462820 Mar 30 19:13 libmysqlclient_r.so.15.0.0
    lrwxrwxrwx 1 root root 24 Apr 27 11:21 libmysqlclient.so -> libmysqlclient.so.15.0.0
    lrwxrwxrwx 1 root root 24 Apr 15 14:20 libmysqlclient.so.15 -> libmysqlclient.so.15.0.0
    -rwxr-xr-x 1 root root 1451932 Mar 30 19:13 libmysqlclient.so.15.0.0
    -rw-r--r-- 1 root root 1368506 Mar 30 19:13 libmystrings.a
    -rw-r--r-- 1 root root 330274 Mar 30 19:13 libmysys.a
    -rw-r--r-- 1 root root 14312 Mar 30 19:13 libvio.a
    -rwxr-xr-x 1 root root 13169 Mar 30 19:01 mysqlbug
    -rwxr-xr-x 1 root root 6215 Mar 30 19:01 mysql_config

    but when I try to compile nginx with my module I get the following error
    ...
    objs/ngx_modules.o \
    -lpcre -lssl -lcrypto -ldl -lzl -lmysqlclient
    /usr/bin/ld: cannot find -lmysqlclient

    collect2: ld returned 1 exit status
    make[1]: *** [objs/nginx] Error 1
    make[1]: Leaving directory `/opt/nginx-1.0.0'
    make: *** [build] Error 2

    I have also created a symlink to the lib inside system /lib, didnt work..
    Ldd on the lib shows that all dependencies are ok.
    Did a ldconfig inside the path.
    The package mysql-devel is installed as well.
    I have also created a mysql-devel.conf file inside ld.so.conf.d with the correct path as well.

    I have also tried to use the last library from the Mysql C API directly from mysql website (instead of using the version installed by yum). Didnt work as well..

    It seems that LD simply cant find the library no matter what...

    Any ideas whats going on here? I'm over two days now stuck in this silly matter, have googled & read lots of threads in the subject but most of them are related to using wrong lib names. I'm start considering a fresh centos installation :-(


    cheers,
    Arley

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Well this line
    -lpcre -lssl -lcrypto -ldl -lzl -lmysqlclient

    Didn't come from expanding this variable
    CORE_LIBS="$CORE_LIBS -L/usr/lib/mysql -lmysqlclient"

    Perhaps look through the makefile to see how CORE_LIBS is used (or should be used).
    It kinda looks like it worked by accident rather than design until you added mysql to the project.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    May 2006
    Posts
    10
    Salem,

    Sorry for such late reply. Indeed you were right, the make file is not being build correctly, editing and adding the -L manually fix the problem.

    Right on the spot.

    Many thx,
    Arley

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem connecting to MySQL Database?
    By MrLucky in forum C++ Programming
    Replies: 5
    Last Post: 01-30-2006, 11:30 AM
  2. Problem with MYSQL
    By maxorator in forum C++ Programming
    Replies: 9
    Last Post: 08-25-2005, 02:33 AM
  3. problem in MySQL with VC++6 in Win2000
    By psa_cprog in forum C Programming
    Replies: 4
    Last Post: 05-26-2005, 03:29 AM
  4. linker problem with mysql
    By august_01 in forum C++ Programming
    Replies: 1
    Last Post: 04-24-2005, 11:04 AM
  5. Mysql Problem
    By gvector1 in forum C# Programming
    Replies: 1
    Last Post: 10-22-2003, 01:55 PM