LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-19-2011, 04:47 PM   #1
james_b
LQ Newbie
 
Registered: Nov 2011
Posts: 8

Rep: Reputation: Disabled
Linker Issue


Hiya,

I'm trying to build the MySQL Connector/C++ on Oracle Linux and gcc.

Code:
$ g++ --version
g++ (GCC) 4.4.5 20110214 (Red Hat 4.4.5-6)

$ cmake .
(snip)
-- MySQL Library dir: /usr/lib64
(snip)

$ make clean
$ make
(snip...)
/usr/bin/ld: cannot find -lmysqlclient_r
collect2: ld returned 1 exit status
I'm fairly new to cmake and gcc, but this seems to be saying it can't find the libmysqlclient_r library.

I can verify that libmysqlclient_r.a is in /usr/lib64/mysql, not /usr/lib64/. Is there anyway I can pass this directory to cmake and/or ld so that it finds the library?

Any suggestions are much appreciated!

Cheers

Last edited by james_b; 12-19-2011 at 04:50 PM.
 
Old 12-20-2011, 10:07 AM   #2
dwhitney67
Senior Member
 
Registered: Jun 2006
Location: Maryland
Distribution: Kubuntu, Fedora, RHEL
Posts: 1,541

Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
Try something like:
Code:
LDFLAGS=-L/usr/lib64/mysql make
If this does not work, then take a peek at the Makefile to see what variable is used to store the -L/usr/lib64 path. Then check to see if it is assigned using a "+=" (versus a mere "="). If the variable name is different from LDFLAGS, then substitute the proper name within the command above.

You may also want to read the following (which I was able to Google): http://www.vtk.org/Wiki/CMake:How_To_Find_Libraries
 
Old 12-20-2011, 10:10 AM   #3
hj1967
Member
 
Registered: Jun 2011
Location: Nunspeet, The Netherlands
Distribution: Slackware x64
Posts: 39

Rep: Reputation: Disabled
Quote:
Originally Posted by james_b View Post
Hiya,

I'm trying to build the MySQL Connector/C++ on Oracle Linux and gcc.

Code:
$ g++ --version
g++ (GCC) 4.4.5 20110214 (Red Hat 4.4.5-6)

$ cmake .
(snip)
-- MySQL Library dir: /usr/lib64
(snip)

$ make clean
$ make
(snip...)
/usr/bin/ld: cannot find -lmysqlclient_r
collect2: ld returned 1 exit status
I'm fairly new to cmake and gcc, but this seems to be saying it can't find the libmysqlclient_r library.

I can verify that libmysqlclient_r.a is in /usr/lib64/mysql, not /usr/lib64/. Is there anyway I can pass this directory to cmake and/or ld so that it finds the library?

Any suggestions are much appreciated!

Cheers
You can use the -L/<path> option to tell the linker to look in other directies.
The commandline will look like:

g_+ -o myprog myprog.o -L/usr/lib64/mysql -lmysqlclient

I don't know cmake but it should be possible to use specify the -Lpath in the cmake file.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] cryptic linker error (i really dont like linker errors); smeezekitty Programming 2 09-19-2009 02:21 AM
linker issue hua Slackware 5 09-01-2009 05:15 AM
linker issue - undefined reference error asif.kalim Programming 3 04-19-2008 05:18 AM
autotools/gcc linker issue fibbi Linux - Software 2 05-08-2006 10:38 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:10 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration