CUDA 7.0 Error while compiling samples - cuda

I'm trying to install CUDA 7.0 on Ubuntu 14.04. I've followed the installation instructions as outlined here. Specifically, I've followed steps in section 3.6 and Chapter 6. While compiling the examples (Section 6.2.2.2) using make, I'm getting the following error:
make[1]: Entering directory `/usr/local/cuda-7.0/samples/3_Imaging/cudaDecodeGL'
/usr/local/cuda-7.0/bin/nvcc -ccbin g++ -m64 -gencode arch=compute_20,
code=compute_20 -o cudaDecodeGL FrameQueue.o ImageGL.o VideoDecoder.o
VideoParser.o VideoSource.o cudaModuleMgr.o cudaProcessFrame.o
videoDecodeGL.o -L../../common/lib/linux/x86_64 -L/usr/lib/"nvidia-346"
-lGL -lGLU -lX11 -lXi -lXmu -lglut -lGLEW -lcuda -lcudart -lnvcuvid
/usr/bin/ld: cannot find -lnvcuvid
collect2: error: ld returned 1 exit status
make[1]: *** [cudaDecodeGL] Error 1
make[1]: Leaving directory `/usr/local/cuda-7.0/samples/3_Imaging/cudaDecodeGL'
make: *** [3_Imaging/cudaDecodeGL/Makefile.ph_build] Error 2

If you notice, there is -L/usr/lib/"nvidia-346". In my case, I have installed nvidia-349. What worked for me is to edit NVIDIA_CUDA-7.0_Samples/3_Imaging/cudaDecodeGL/findgllib.mk and change UBUNTU_PKG_NAME = "nvidia-346" to nvidia-349.

In order to properly install CUDA 7.0 on Ubuntu 14.04, you need a nvidia driver version 346 or higher.
If you're using the .deb installation method, the nvidia graphics driver is installed automatically.
If you used the .run file installation method and chose not to install the nvidia driver, you can manually install the driver afterwards through the package manager:
sudo apt-add-repository ppa:xorg-edgers/ppa && sudo apt-get update
sudo apt-get install nvidia-346 nvidia-346-dev nvidia-346-uvm libcuda1-346 nvidia-libopencl1-346 nvidia-icd-346
In my case, I installed nvidia-352 afterwards due to a bug in nvidia-346 and I stumbled upon the same error.
andoum's approach of manually changing the hard-coded UBUNTU_PKG_NAME = "nvidia-346" to UBUNTU_PKG_NAME = "nvidia-352" in NVIDIA_CUDA-7.0_Samples/3_Imaging/cudaDecodeGL/findgllib.mk worked fine for me.

I met the same issue and solution is that put path of nvidia into system path:
sudo gedit /etc/environment
add these path into environment
LIBRARY_PATH=/usr/lib/your_nvidia_edition:$LIBRARY_PATH

In fact I have encountered this problem when I made a make. I installed Cuda 8.0 under my Ubuntu 16.04. This problem had been confusing me for several weeks and I was almost tending to reinstall ubuntu for that after reviewing many suggestions via google, but finally I addressed it myself recently.
First of all, you should replace all the UBUNTU_PKG_NAME= ##nvidia-3xx## to the one of your actually installed nvidia driver version as recommended above. Then you will probably get compiling error after you do a new make. In my case, I have the link errors like
/usr/bin/ld: warning: libGLX.so.0, needed by /usr/lib/nvidia-
375/libGL.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libGLdispatch.so.0, needed by /usr/lib/nvidia-
375/libGL.so, not found (try using -rpath or -rpath-link)
....
or whatever contains missing link errors. Do locate the files you miss like
$ locate libGLX.so.
/usr/lib/nvidia-375/libGLX.so.0
/usr/lib32/nvidia-375/libGLX.so.0
$ locate libGLdispatch.so.0
/usr/lib/nvidia-375/libGLdispatch.so.0
/usr/lib32/nvidia-375/libGLdispatch.so.0
The error above is probably caused the compiling files cannot find in the default cuda libraries as you set, so you just need to copy the missing files to /usr/lib/nvidia-3xx/ (the actual path in your case) and this should work(it works in my case), if it doesn't maybe you could try to link the new add files to the one that need using a
$ sudo ln -s (requested file) (requesting file).
Hope this will help.

Related

Caffe compilation fails: Undefined symbols for architecture x86_64?

If I try building the newest version of Caffe, it leads to this error:
$ make all
CXX/LD -o .build_release/tools/caffe.bin
clang: warning: argument unused during compilation: '-pthread'
Undefined symbols for architecture x86_64:
"caffe::Net<float>::Forward(float*)", referenced from:
test() in caffe.o
time() in caffe.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [.build_release/tools/caffe.bin] Error 1
I'm building on osx, OpenBLAS, and CPU_ONLY. I found a kind of similar issue on here but it appears to have been a resolved issue, and I'm not getting the exact same error, though perhaps it's related? I can also build and run an older version of Caffe from a month ago, so I think something has changed very recently.
Any ideas on how to overcome this error?
It shows a link problem when compile.On osx this problem will happen usually.I guess the problem happened in Makefile.config.You can change to
# To customize your choice of compiler, uncomment and set the following.
# N.B. the default for Linux is g++ and the default for OSX is clang++
CUSTOM_CXX := g++
and confirm some path is correct.
I had exactly the same problem. Its now resolved.
Do check if you already have a libcaffe.so in your system library paths (maybe /usr/local/lib). If so, delete the existing libcaffe.so and build again.

I think OSX-gcc-installer broke some things and I'm not sure what to do

Long story short is I foolishly installed OSX-gcc-installer about a month ago and at first it prevented me, I believe, from installing Ruby gems on my machine. With the help of someone I did get this one issue fixed. Going through other the other posts on this website I was not able to find the solution that I'm looking for, so I decided to post here.
When I run brew doctor I get the following:
albys-mbp:folder alby$ brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry and just ignore them. Thanks!
Warning: You have an outdated version of /usr/bin/install_name_tool installed.
This will cause binary package installations to fail.
This can happen if you install osx-gcc-installer or RailsInstaller.
To restore it, you must reinstall OS X or restore the binary from
the OS packages.
Warning: Broken symlinks were found. Remove them with `brew prune`:
/usr/local/bin/aclocal
/usr/local/bin/aclocal-1.14
/usr/local/bin/autoconf
/usr/local/bin/autoheader
/usr/local/bin/autom4te
/usr/local/bin/automake
/usr/local/bin/automake-1.14
/usr/local/bin/autoreconf
/usr/local/bin/autoscan
/usr/local/bin/autoupdate
/usr/local/bin/cscope
/usr/local/bin/erb
/usr/local/bin/gem
/usr/local/bin/glibtool
/usr/local/bin/glibtoolize
/usr/local/bin/gpg-error
/usr/local/bin/gpg-error-config
/usr/local/bin/ifnames
/usr/local/bin/irb
/usr/local/bin/ksba-config
/usr/local/bin/ocs
/usr/local/bin/pkg-config
/usr/local/bin/rake
/usr/local/bin/rdoc
/usr/local/bin/ri
/usr/local/bin/ruby
/usr/local/bin/testrb
/usr/local/include/gpg-error.h
/usr/local/include/ksba.h
/usr/local/include/libltdl
/usr/local/include/ltdl.h
/usr/local/include/ruby-2.1.0
/usr/local/include/yaml.h
/usr/local/lib/libgpg-error.0.dylib
/usr/local/lib/libgpg-error.dylib
/usr/local/lib/libksba.8.dylib
/usr/local/lib/libksba.dylib
/usr/local/lib/libltdl.7.dylib
/usr/local/lib/libltdl.a
/usr/local/lib/libltdl.dylib
/usr/local/lib/libruby.2.1.0-static.a
/usr/local/lib/libruby.2.1.0.dylib
/usr/local/lib/libruby.2.1.dylib
/usr/local/lib/libruby.dylib
/usr/local/lib/libyaml-0.2.dylib
/usr/local/lib/libyaml.a
/usr/local/lib/libyaml.dylib
/usr/local/lib/pkgconfig/ruby-2.1.pc
/usr/local/lib/pkgconfig/yaml-0.1.pc
/usr/local/lib/ruby/2.1.0
/usr/local/lib/ruby/gems
/usr/local/share/aclocal/README
/usr/local/share/aclocal/argz.m4
/usr/local/share/aclocal/dirlist
/usr/local/share/aclocal/gpg-error.m4
/usr/local/share/aclocal/ksba.m4
/usr/local/share/aclocal/libtool.m4
/usr/local/share/aclocal/ltdl.m4
/usr/local/share/aclocal/ltoptions.m4
/usr/local/share/aclocal/ltsugar.m4
/usr/local/share/aclocal/ltversion.m4
/usr/local/share/aclocal/lt~obsolete.m4
/usr/local/share/aclocal/pkg.m4
/usr/local/share/aclocal-1.14
/usr/local/share/autoconf
/usr/local/share/automake-1.14
/usr/local/share/common-lisp
/usr/local/share/doc/automake
/usr/local/share/doc/pkg-config/pkg-config-guide.html
/usr/local/share/emacs
/usr/local/share/info/gpgrt.info
/usr/local/share/info/ksba.info
/usr/local/share/info/libtool.info
/usr/local/share/info/libtool.info-1
/usr/local/share/info/libtool.info-2
/usr/local/share/libtool
/usr/local/share/man/man1/aclocal-1.14.1
/usr/local/share/man/man1/aclocal.1
/usr/local/share/man/man1/autoconf.1
/usr/local/share/man/man1/autoheader.1
/usr/local/share/man/man1/autom4te.1
/usr/local/share/man/man1/automake-1.14.1
/usr/local/share/man/man1/automake.1
/usr/local/share/man/man1/autoreconf.1
/usr/local/share/man/man1/autoscan.1
/usr/local/share/man/man1/autoupdate.1
/usr/local/share/man/man1/config.guess.1
/usr/local/share/man/man1/config.sub.1
/usr/local/share/man/man1/cscope.1
/usr/local/share/man/man1/erb.1
/usr/local/share/man/man1/glibtool.1
/usr/local/share/man/man1/glibtoolize.1
/usr/local/share/man/man1/gpg-error-config.1
/usr/local/share/man/man1/ifnames.1
/usr/local/share/man/man1/irb.1
/usr/local/share/man/man1/pkg-config.1
/usr/local/share/man/man1/rake.1
/usr/local/share/man/man1/ri.1
/usr/local/share/man/man1/ruby.1
/usr/local/Library/LinkedKegs/autoconf
/usr/local/Library/LinkedKegs/automake
/usr/local/Library/LinkedKegs/cscope
/usr/local/Library/LinkedKegs/libgpg-error
/usr/local/Library/LinkedKegs/libksba
/usr/local/Library/LinkedKegs/libtool
/usr/local/Library/LinkedKegs/libyaml
/usr/local/Library/LinkedKegs/pkg-config
/usr/local/Library/LinkedKegs/ruby
Warning: You seem to have osx-gcc-installer installed.
Homebrew doesn't support osx-gcc-installer. It causes many builds to fail and
is an unlicensed distribution of really old Xcode files.
Please run `xcode-select --install` to install the CLT.
Warning: Some installed formula are missing dependencies.
You should `brew install` the missing dependencies:
brew install openssl
Run `brew missing` for more details.
alby-mbp:folder alby$
As you can also see above, I am missing openssl. This is because I uninstalled it and attempted to reinstall it thinking that this would help, but I was not able to reinstall. Here is what I get when I try to do brew install openssl:
albys-mbp:folder alby$ brew install openssl
Warning: You seem to have osx-gcc-installer installed.
Homebrew doesn't support osx-gcc-installer. It causes many builds to fail and
is an unlicensed distribution of really old Xcode files.
Please run `xcode-select --install` to install the CLT.
Warning: You have an outdated version of /usr/bin/install_name_tool installed.
This will cause binary package installations to fail.
This can happen if you install osx-gcc-installer or RailsInstaller.
To restore it, you must reinstall OS X or restore the binary from
the OS packages.
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/openssl-1.0.1j_1.mavericks.bottle.tar.gz
Already downloaded: /Library/Caches/Homebrew/openssl-1.0.1j_1.mavericks.bottle.tar.gz
Error: SHA1 mismatch
Expected: 65e125a4777eb6dfb63f01a18f724246123dd79e
Actual: eac5e2d21af64224fc533ebb793b99a2aea434c7
Archive: /Library/Caches/Homebrew/openssl-1.0.1j_1.mavericks.bottle.tar.gz
To retry an incomplete download, remove the file above.
Warning: Bottle installation failed: building from source.
==> Installing openssl dependency: makedepend
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/makedepend-1.0.5.mavericks.bottle.tar.gz
Already downloaded: /Library/Caches/Homebrew/makedepend-1.0.5.mavericks.bottle.tar.gz
Error: SHA1 mismatch
Expected: 83db1daee01e4eb752c711934eb88850b3ee70d6
Actual: eac5e2d21af64224fc533ebb793b99a2aea434c7
Archive: /Library/Caches/Homebrew/makedepend-1.0.5.mavericks.bottle.tar.gz
To retry an incomplete download, remove the file above.
Warning: Bottle installation failed: building from source.
Error: /usr/local/opt/pkg-config not present or broken
Please reinstall pkg-config. Sorry :(
albys-mbp:folder alby$
Another issue is that when I try and run mysql in bash, I get the following:
albys-mbp:folder alby$ mysql
dyld: Library not loaded: ##HOMEBREW_PREFIX##/opt/openssl/lib/libssl.1.0.0.dylib
Referenced from: /usr/local/bin/mysql
Reason: image not found
Trace/BPT trap: 5
albys-mbp:folder alby$
I am mostly new to programming and am not sure where to begin to solve this issue. I was able to backup my HD to an external HD, but this is after installing the gcc-installer which overwrote my Command Line Tools. So even if I were to do a reinstall, would that even work? I've never had to reinstall my OS X before; would I be able to pick and choose files from the external HD or is it all restored?
Also, I have OS X 10.9.
Thanks!

Apache Axis2/C Installation

i have tried installing Apache Axis2/C on Linux but no success.. with libxml2
Here are my efforts
1) libxml2 was installed successfully
Flags : LIBXML2_CFLAGS = -I/usr/local/include/libxml2
LIBXML2_LIBS='-L/usr/local/lib/hpux32 -lxml2 -lz -lpthread -liconv -lm'
AXIS2C_HOME = /tmp
LD_LIBRARY_PATH = {$LD_LIBRARY_PATH}:$AXIS2C_HOME/lib
Ran --prefix=${AXIS2C_HOME} --enable-libxml2=yes
Installation fails with following error:
checking whether to build libxml2 xml parser library... checking pkg-config is at least version 0.9.0... ./configure[21268]: /local/lib/hpux32.
no
yes
checking for LIBXML2... configure: error: The pkg-config script could not be found or is too old. Make sure it
is in your PATH or set the PKG_CONFIG environment variable to the full
path to pkg-config.
Alternatively, you may set the environment variables LIBXML2_CFLAGS
and LIBXML2_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
i do not hold pkg-config utility but i have set LIBXML2_CFLAGS and LIBXML2_LIBS, configuration file does not have any information.
can someone please assist here?
Thanks,
Hilesh

Setting up Mysql++ in linux

I want to connect to a mysql database with C++ in linux. On my local machine I am running Ubuntu, and installed the mysql server and client packages:
sudo apt-get install mysql-server mysql-client
I came across Mysql++ but have some problems when running ./configure from their binary package. The error says:
checking for MySQL library directory... configure: error: Didn't find mysqlclient library in '/usr/lib64 /usr/lib /usr/lib64/mysql /usr/lib/mysql /usr/local/lib64 /usr/local/lib /usr/local/lib/mysql /usr/local/mysql/lib /usr/local/mysql/lib/mysql /usr/mysql/lib/mysql /opt/mysql/lib /opt/mysql/lib/mysql /sw/lib /sw/lib/mysql'
I see where I can use this command to specify the path:
./configure --with-mysql-lib=/...
but I do not know where to point it to. I used whereis mysql but cannot find any mysql directory that contains a lib subdirectory. Where would the mysqlclient libraries be installed?
EDIT:
After doing locate libmysqlclient I got back
/usr/lib/i386-linux-gnu/libmysqlclient.so.18
/usr/lib/i386-linux-gnu/libmysqlclient.so.18.0.0
/usr/lib/i386-linux-gnu/libmysqlclient_r.so.18
/usr/lib/i386-linux-gnu/libmysqlclient_r.so.18.0.0
/usr/share/doc/libmysqlclient18
/usr/share/doc/libmysqlclient18/changelog.Debian.gz
/usr/share/doc/libmysqlclient18/copyright
/var/cache/apt/archives/libmysqlclient18_5.5.22-0ubuntu1_i386.deb
/var/lib/dpkg/info/libmysqlclient18:i386.list
/var/lib/dpkg/info/libmysqlclient18:i386.md5sums
/var/lib/dpkg/info/libmysqlclient18:i386.postinst
/var/lib/dpkg/info/libmysqlclient18:i386.postrm
/var/lib/dpkg/info/libmysqlclient18:i386.shlibs
So, I tried ./configure --with-mysql-lib=/usr/lib/i386-linux-gnu and it seems to complete without any complaining.
Although this solves the problem of getting ./configure to complete, I still have further troubles. When I run make things go fine until this point:
In file included from ./lib/sql_buffer.h:31:0,
from ./lib/sql_buffer.cpp:26: ./lib/refcounted.h:258:2: error: ‘size_t’ does not name a type
./lib/refcounted.h: In constructor ‘mysqlpp::RefCountedPointer::RefCountedPointer()’: ./lib/refcounted.h:89:2: error:
class ‘mysqlpp::RefCountedPointer’ does not have any
field named ‘refs_’ ./lib/refcounted.h: In constructor
‘mysqlpp::RefCountedPointer::RefCountedPointer(T*)’:
./lib/refcounted.h:100:2: error: class ‘mysqlpp::RefCountedPointer’ does not have any field named ‘refs_’
./lib/refcounted.h:104:4: error: ‘refs_’ was not declared in this
scope ./lib/refcounted.h:104:16: error: expected type-specifier before
‘size_t’ ./lib/refcounted.h:104:16: error: expected ‘;’ before
‘size_t’ ./lib/refcounted.h: In constructor
‘mysqlpp::RefCountedPointer::RefCountedPointer(const
ThisType&)’: ./lib/refcounted.h:112:2: error: class
‘mysqlpp::RefCountedPointer’ does not have any field
named ‘refs_’ ./lib/refcounted.h:115:8: error: ‘refs_’ was not
declared in this scope ./lib/refcounted.h: In destructor
‘mysqlpp::RefCountedPointer::~RefCountedPointer()’:
./lib/refcounted.h:125:7: error: ‘refs_’ was not declared in this
scope ./lib/refcounted.h: In member function ‘void
mysqlpp::RefCountedPointer::swap(mysqlpp::RefCountedPointer::ThisType&)’: ./lib/refcounted.h:246:13: error: ‘refs_’ was
not declared in this scope make: *** [mysqlpp_sql_buffer.o] Error 1
I'm not really familiar with C++, so I'm not sure what the error means exactly. Any help or direction on how to get Mysql++ setup from this point would be much appreciated. Although, I admit that I'm also starting to look for alternative libraries to use.
this problem is caused because size_t depends on the inclusion of stddef namespace before it is called in the configuration (make) files.
i had the very same problem (using an amazon EC2 ubuntu 12.04 cloud server) and solved it by editing the offending file (sql_buffer.cpp located, in my case, /home/ubuntu/mysql++-3.1.0/lib) and including stddef (while also moving string namespace up):
#include <stddef.h>
#include <string.h>
#include "sql_buffer.h"
your question is answered with this correction. BUT, you might have additional problems, like i did. so i explain how i solved some subsequent problems, which you might or might not have also.
you might have to use
sudo chown username sql_buffer.cpp
to be able to edit the file, depending on how your install is setup (i am user ubuntu, for example).
i then bumped into another problem:
./ssx/genv2.cpp: In function âbool generate_ssqls2(const char*, const ParseV2*)â:
./ssx/genv2.cpp:70:28: error: âstrcmpâ was not declared in this scope
so i edited the offending file (genv2.cpp) and included string namespace
#include <string.h>
then i had ANOTHER problem with:
./libmysqlpp_ssqls2parse.a(ssqls2parse_parsev2.o): In function `Type':
/home/ubuntu/mysql++-3.1.0/./ssx/parsev2.cpp:256: undefined reference to `mysqlpp::internal::str_to_lwr
i could have edited Makefile.in but chose to simply run in command line:
sudo g++ -o test_ssqls2 test_ssqls2_ssqls2.o -lmysqlpp_ssqls2parse -L. -lmysqlclient -L/usr/lib/x86_64-linux-gnu -lmysqlpp
i then continued the make process.
that worked for me: mysql++ installed and running.
You need to install the header (dev) files, I assume one of these:
apt-cache search mysql
...
libmysqlclient-dev - MySQL database development files
libmysqlclient16 - MySQL database client library
libmysql++-dev - MySQL C++ library bindings (development)
libmysqlcppconn-dev - MySQL Connector for C++ (development files)
...
--with-mysql-lib should not be necessary because the files will be installed in the default locations.

Installation error for DBD::MySQL on OSX v10.6.6

I'm attempting to get DBD::MySQL working on Snow Leopard (v10.6.6). The default version of Perl that comes with the OS is v5.10.0. Since I've read that's 64-bit, I went ahead and downloaded and installed a 64-bit version of MySQL (mysql-5.5.8-osx10.6-x86_64).
Installing and setting up MySQL went smoothly, here's my config and version number for reference.
I used CPAN to download DBI and the DBD::MySQL drivers. I then:
Installed DBI
Setup a Makefile.PL
Ran the make command from the command line
The Makefile.PL said it would use the following settings for compiling and testing:
I will use the following settings for compiling and testing:
cflags (mysql_config ) = -I/usr/local/mysql/include -Os -g -fno-common -fno-strict-aliasing -arch x86_64
embedded (mysql_config ) =
libs (mysql_config ) = -L/usr/local/mysql/lib -lmysqlclient -lpthread
mysql_config (guessed ) = mysql_config
nocatchstderr (default ) = 0
nofoundrows (default ) = 0
ssl (guessed ) = 0
testdb (default ) = test
testhost (default ) =
testpassword (User's choice) = r00t!
testsocket (default ) =
testuser (User's choice) = root
To change these settings, see 'perl Makefile.PL --help' and
'perldoc INSTALL'.
Multiple copies of Driver.xst found in: /Library/Perl/5.10.0/darwin-thread-multi-2level/auto/DBI/ /System/Library/Perl/Extras/5.10.0/darwin-thread-multi-2level/auto/DBI/ at Makefile.PL line 907
Using DBI 1.616 (for perl 5.010000 on darwin-thread-multi-2level) installed in /Library/Perl/5.10.0/darwin-thread-multi-2level/auto/DBI/
Writing Makefile for DBD::mysql
Everything seemed to be going fine, until I tried to run make test :
t/00base....................NOK 2/6# Tried to use 'DBD::mysql'.
# Error: Can't load '/Users/swm/.cpan/build/DBD-mysql-4.018-Pnd2qz/blib/arch/auto/DBD/mysql/mysql.bundle' for module DBD::mysql: dlopen(/Users/swm/.cpan/build/DBD-mysql-4.018-Pnd2qz/blib/arch/auto/DBD/mysql/mysql.bundle, 2): Library not loaded: libmysqlclient.16.dylib
# Referenced from: /Users/swm/.cpan/build/DBD-mysql-4.018-Pnd2qz/blib/arch/auto/DBD/mysql/mysql.bundle
# Reason: image not found at /System/Library/Perl/5.10.0/darwin-thread-multi-2level/DynaLoader.pm line 207.
# at (eval 7) line 2
# Compilation failed in require at (eval 7) line 2.
# BEGIN failed--compilation aborted at (eval 7) line 2.
FAILED--Further testing stopped: Unable to load DBD::mysql
make: *** [test_dynamic] Error 9
It's failing because it can't seem to find the mysql.bundle for DBD. Has anyone come across this problem? Or can point me in the right direction on what to try next? I need DBI/DBD::MySQL for my new job and I'm scrambling to find a solution.
Many thanks in advance.
I got around the "Library not loaded: libmysqlclient.16.dylib" problem by placing a symbolic link in /usr/lib/" to /usr/local/mysql-5.5.8-osx10.6-x86_64/lib/libmysqlclient.16.dylib
I worked around the same or a similar issue. Somehow I could build and test DBD::mysql with cpan but when I tried to use it in a script it said things like
dyld: lazy symbol binding failed: Symbol not found: _mysql_init
Referenced from: /Library/Perl/5.10.0/darwin-thread-multi-2level/auto/DBD/mysql/mysql.bundle
Expected in: flat namespace
Apparently, it's a 64-bit vs 32-bit issue.
Installing the fink dbd-mysql-pm5100 package made it work though it took kind of a long time. I also removed the cpan-installed version:
sudo rm -rf /Library/Perl/5.10.0/darwin-thread-multi-2level/auto/DBD/mysql
sudo rm -rf /Library/Perl/5.10.0/darwin-thread-multi-2level/DBD/mysql
sudo rm -rf /Library/Perl/5.10.0/darwin-thread-multi-2level/DBD/mysql.pm
also include in .profile
export VERSIONER_PERL_PREFER_32_BIT=yes;
Besides creating the link the executions of the program with DBI::mysql generated an error, thus including this variable on the environment make it works
I know this is an old post. But I suppose the best solution would be to add the library directory to the DYLD_FALLBACK_LIBRARY_PATH env variable. (reason here: https://stackoverflow.com/a/3172515/119958 )
There is no ldconfig in mac, so just add the path to this env var and rerun the install process for DBD::mysql
Donato-Vianas-MacBook-Pro:Invoicer donato$ cpanm DBD::mysql
--> Working on DBD::mysql
Fetching http://www.cpan.org/authors/id/C/CA/CAPTTOFU/DBD-mysql-4.022.tar.gz ... OK
Configuring DBD-mysql-4.022 ... OK
Building and testing DBD-mysql-4.022 ... FAIL
! Installing DBD::mysql failed. See /Users/donato/.cpanm/build.log for details.
# Failed test 'use DBD::mysql;'
# at t/00base.t line 21.
# Tried to use 'DBD::mysql'.
# Error: Can't load '/Users/donato/.cpanm/work/1359948144.491/DBD-mysql-4.022/blib/arch/auto/DBD/mysql/mysql.bundle' for module DBD::mysql: dlopen(/Users/donato/.cpanm/work/1359948144.491/DBD-mysql-4.022/blib/arch/auto/DBD/mysql/mysql.bundle, 2): Library not loaded: libmysqlclient.18.dylib
Donato-Vianas-MacBook-Pro:Invoicer donato$ export DYLD_FALLBACK_LIBRARY_PATH=/usr/local/mysql/lib/:$DYLD_FALLBACK_LIBRARY_PATH
Donato-Vianas-MacBook-Pro:Invoicer donato$ cpanm DBD::mysql--> Working on DBD::mysql
Fetching http://www.cpan.org/authors/id/C/CA/CAPTTOFU/DBD-mysql-4.022.tar.gz ... OK
Configuring DBD-mysql-4.022 ... OK
Building and testing DBD-mysql-4.022 ... OK
Successfully installed DBD-mysql-4.022
1 distribution installed
Donato's solution works for install, but the var has to be present at runtime as well or I get the same error. The following fixes this at runtime for shell and _www user:
# For command line use, add following line to ~/.bash_profile:
export DYLD_FALLBACK_LIBRARY_PATH=/usr/local/mysql/lib/:$DYLD_FALLBACK_LIBRARY_PATH
# If Apache needs it, add following line to /etc/apache2/httpd.conf:
# On Lion Server, I put it after <IfDefine MACOSXSERVER>, but shouldn't matter
SetEnv DYLD_FALLBACK_LIBRARY_PATH /usr/local/mysql/lib/:$DYLD_FALLBACK_LIBRARY_PATH
It's somewhat of an aside, but I strongly recommend setting up a separate perl on the machine -- either by fink / macports, or from source -- and leaving the Mac's system perl (and its libraries) alone.
Once I did this on my own Mac, I had very few troubles installing modules thereafter, and I didn't have to worry about accidentally blowing a hole in my OS by breaking the perl that the system uses.
If it were my Mac, I'd install a new perl from source (the Perl source distribution is smart enough to install itself see that it's on a Mac and install itself safely into /usr/local/bin) and the proceed from thee to install DBD::Mysql (and the other modules you require).