-
Notifications
You must be signed in to change notification settings - Fork 6.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't build simple program #114
Comments
Hmm looking. How did you build rocksdb? |
just "make" |
Hey, I just tried the same thing and it works for me: icanadi@icanadi-mbp1 rocksdb $ g++ -c -I./include -std=c++11 mytest.cc Can you please try |
I just tried again after "make clean; make" and got the same results (the build didn't work in the same way). I guess my environment must be screwed up (but how?). I'm building with g++ 4.7.2 on ubuntu 12.10. Do I need g++ 4.8? |
You shouldn't need g++ 4.8. Can you try:
|
Let me try the same thing on ubuntu 12.10 |
Reproed the issue on ubuntu 12.10. Looking |
It looks like you have to specify library after your .o file. So your second command should be: g++ -o mytest mytest.o -L. -lrocksdb -lsnappy -lpthread -lbz2 -lz -lrt (also added other libraries you need to link with) |
You're right--that works for me. Sorry for the bother. |
I must be doing something stupid, but I can't build a simple program with rocksdb. I get a bunch of undefined references from standard functions. Can anyone give me some help? Any help would be appreciated!!
I compile and build with the following commands:
g++ -c -I./include -std=c++11 mytest.cc
g++ -o mytest -L. -lrocksdb mytest.o
The program (mytest.cc) is as follows:
include <assert.h>
include <iostream>
include "rocksdb/db.h"
int
main(int argc, char *argv[])
{
rocksdb::DB *db;
rocksdb::Options options;
options.create_if_missing = true;
options.error_if_exists = true;
rocksdb::Status status = rocksdb::DB::Open(options, "/tmp/testdb", &db);
assert(status.ok());
delete db;
return 0;
}
I get back the following complaints:
mytest.o: In function main':
mytest.cc:(.text+0x11b): undefined reference torocksdb::DB::Open(rocksdb::Options const&, std::string const&, rocksdb::DB**)'
mytest.o: In function rocksdb::Options::Options()':
mytest.cc:(.text._ZN7rocksdb7OptionsC2Ev[_ZN7rocksdb7OptionsC5Ev]+0x15): undefined reference torocksdb::DBOptions::DBOptions()'
mytest.cc:(.text._ZN7rocksdb7OptionsC2Ev[_ZN7rocksdb7OptionsC5Ev]+0x27): undefined reference to `rocksdb::ColumnFamilyOptions::ColumnFamilyOptions()'
collect2: error: ld returned 1 exit status
The text was updated successfully, but these errors were encountered: