Couchbase
  • Why NoSQL?
  • Couchbase Server
  • Download
  • Resources
  • Careers
Home | Forums | Couchbase | Couchbase Server 1.8.x

"undefined reference" linker compaints with Couchbase C SDK

4 replies [Last post]
  • Login or register to post comments
Mon, 11/12/2012 - 01:35
Dronz
Offline
Joined: 09/17/2011
Groups: None

I have tried to build some basic Couchbase calls into my C++ application using the Couchbase C 1.0 SDK on Ubuntu 12.04, which I seemed to install fine.

The linker is finding the lcouchbase library, but when I refer to any couchbase methods, the linker says "undefined reference". Did I miss an SDK install step? Is there a typo in my build command-line? I don't expect I need a namespace since I haven't seen one in the examples I've seen. Any other tips?

Thanks in advance for any help!

Details:

My SDK install steps were:

sudo wget -O/etc/apt/sources.list.d/couchbase.list http://packages.couchbase.com/ubuntu/couchbase-ubuntu1110.list

wget -O- http://packages.couchbase.com/ubuntu/couchbase.key | sudo apt-key add -

sudo apt-get update && sudo apt-get install libcouchbase-dev

My build command-line and the linker complaints I'm seeing are:

g++ -o ge -lcouchbase GameEngine.cpp ProcessEvents.cpp ProcessMessages.cpp ../comms/SocketServer.cpp Database.cpp
/tmp/ccv5pAOg.o: In function `Database::SetUp(char const*, char const*, char const*, char const*)':
Database.cpp:(.text+0x172): undefined reference to `libcouchbase_create'
Database.cpp:(.text+0x1c1): undefined reference to `libcouchbase_set_error_callback'
Database.cpp:(.text+0x1d5): undefined reference to `libcouchbase_set_get_callback'
Database.cpp:(.text+0x1e4): undefined reference to `libcouchbase_connect'
Database.cpp:(.text+0x221): undefined reference to `libcouchbase_wait'
/tmp/ccv5pAOg.o: In function `Database::Store(char*, char*)':
Database.cpp:(.text+0x2a1): undefined reference to `libcouchbase_store'
Database.cpp:(.text+0x2e9): undefined reference to `libcouchbase_wait'
Database.cpp:(.text+0x2f8): undefined reference to `libcouchbase_get_last_error'
/tmp/ccv5pAOg.o: In function `Database::Read(char*, char*)':
Database.cpp:(.text+0x3b9): undefined reference to `libcouchbase_mget'
Database.cpp:(.text+0x401): undefined reference to `libcouchbase_wait'
collect2: ld returned 1 exit status

Edit: I tried to edit this question before with an update, and the update got caught by the spam filter, and the whole thread was hidden and never restored. I'm trying to edit it again to see if I can get it to show up. Sadly, my update seems to have vanished. I think I may be missing a step to get this to build and link correctly. Any tips?

Thanks!

Top
  • Login or register to post comments
Sat, 12/08/2012 - 23:19
xrobledo
Offline
Joined: 12/08/2012
Groups: None

Did you ever find a solution for this? I'm having the exact same problem on Ubuntu. The linker finds the library but can't find the Couchbase functions.

Top
  • Login or register to post comments
Sun, 12/09/2012 - 12:58
Dronz
Offline
Joined: 09/17/2011
Groups: None

Hi xrobledo,

I didn't find a solution, but just because I let myself get sidetracked when my forum update vanished into the spam filter. I switched to working on another project.

However I do need to get a solution to this, so let's do share when we figure this out.

My current guess is that we are missing a step in the API setup process. I think we may have both installed the source for the API, but not yet built it. I think we may need to do the steps listed in the video tutorial now before it can link. However I wasn't sure exactly how to find the directory the demonstrator was doing the build in. Either that, or we probably need to set some path so the linker can find the API.

Or maybe someone who knows will see us floundering and help us out with the magic words. ;-)

Thanks for bringing my attention back to this.

Top
  • Login or register to post comments
Sun, 12/09/2012 - 19:38
xrobledo
Offline
Joined: 12/08/2012
Groups: None

I figured out what the problem was. Apparently in Ubuntu the -lcouchbase needs to be the last option. I figured it out from here http://stackoverflow.com/questions/7773811/gcc-compile-has-undefined-ref...

Hopefully that helps you. Good luck.

Top
  • Login or register to post comments
Sun, 12/09/2012 - 23:53
Dronz
Offline
Joined: 09/17/2011
Groups: None

Aha! Thanks xrobledo! That's the kind of thing I just need to be told about.

Top
  • Login or register to post comments
  • Login or register to post comments
  • Login
  • Register

Company

  • About Us
  • Leadership
  • Customers
  • Partners
  • Contact Us

Product

  • Couchbase Server
  • Couchbase SDKs
  • Use Cases
  • Documentation
  • Forums

Open Source

  • Couchbase Project
  • Couchbase vs. CouchDB

Commercial

  • Subscriptions & Support
  • Training & Services

News

  • Blog
  • Newsletter
  • Press Releases
  • Buzz

Follow Us

    
  • Customer Login
  • Terms of Service
  • Privacy Policy
  • Trademark Policy
  • Site Map

© 2013 COUCHBASE All rights reserved.

Sign in to Couchbase Community

close
  • Create new account
  • Request new password
You are logging into the Forums, Wiki and Issue Tracker