OlivierJG / botansqlite3

Sqlite3 encryption codec to allow full database encryption using the algorithms supported by Botan.
85 stars 28 forks source link

Undefined symbols for architecture x86_64 #6

Closed lragon closed 10 years ago

lragon commented 10 years ago

hi,when i run test_sqlite.cpp,i got this error g++ test_sqlite.cpp -o test_sqlite botan-config-1.10 --libs ./libbotansqlite3.a Undefined symbols for architecture x86_64: "_sqlite3_key_v2", referenced from: _sqlite3Pragma in libbotansqlite3.a(botansqlite3.o) "_sqlite3_rekey_v2", referenced from: _sqlite3Pragma in libbotansqlite3.a(botansqlite3.o) ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) am i miss something?

OlivierJG commented 10 years ago

Looks like the codec needs an update to support the new sqlite3key_v2 and sqlite3rekey_v2. I'm not sure when sqlite3 added those functions... what version are you using?

lragon commented 10 years ago

hi OlivierJG,sorry,there is something wrong when i copy terminal output to here,it is "sqlite3_key_v2()" not "sqlite3key_v2",here is the output use "-v"

Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn) Target: x86_64-apple-darwin12.5.0 Thread model: posix "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" -cc1 -triple x86_64-apple-macosx10.8.0 -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name test_sqlite.cpp -mrelocation-model pic -pic-level 2 -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu core2 -target-linker-version 224.1 -v -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/5.0 -fdeprecated-macro -fdebug-compilation-dir /Users/apple/Downloads/sqlite-amalgamation-3080200 -ferror-limit 19 -fmessage-length 82 -stack-protector 1 -mstackrealign -fblocks -fobjc-runtime=macosx-10.8.0 -fobjc-dispatch-method=mixed -fobjc-default-synthesize-properties -fencode-extended-block-signature -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o /var/folders/89/qqggppv53rl860s8wly5w4rc0000gn/T/test_sqlite-bKuvL8.o -x c++ test_sqlite.cpp clang -cc1 version 5.0 based upon LLVM 3.3svn default target x86_64-apple-darwin12.5.0 ignoring nonexistent directory "/usr/include/c++/4.2.1/i686-apple-darwin10/x86_64" ignoring nonexistent directory "/usr/include/c++/4.0.0" ignoring nonexistent directory "/usr/include/c++/4.0.0/i686-apple-darwin8/" ignoring nonexistent directory "/usr/include/c++/4.0.0/backward"

include "..." search starts here:

include <...> search starts here:

/usr/include/c++/4.2.1 /usr/include/c++/4.2.1/backward /usr/local/include /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/5.0/include /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include /usr/include /System/Library/Frameworks (framework directory) /Library/Frameworks (framework directory) End of search list. "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version_min 10.8.0 -o test_sqlite /var/folders/89/qqggppv53rl860s8wly5w4rc0000gn/T/test_sqlite-bKuvL8.o -lbotan-1.10 -lpthread ./libbotansqlite3.a -lstdc++ -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/5.0/lib/darwin/libclang_rt.osx.a Undefined symbols for architecture x86_64: "_sqlite3_key_v2", referenced from: _sqlite3Pragma in libbotansqlite3.a(botansqlite3.o) "_sqlite3_rekey_v2", referenced from: _sqlite3Pragma in libbotansqlite3.a(botansqlite3.o) ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

OlivierJG commented 10 years ago

I just pushed a potential fix, it's up to you to see if it compiles ;).

lragon commented 10 years ago

thanks,but it came another error when run test, Undefined symbols for architecture x86_64: "_sqlite3_key", referenced from: _main in test_sqlite-EkETun.o ld: symbol(s) not found for architecture x86_64 by the way,functions you just added sqlite3_key_v2() and sqlite3_rekey_v2(),when i run "gcc -c sqlite3.c -o botansqlite3.o", it said "parameter name omitted",and i add a name to them

OlivierJG commented 10 years ago

sqlite3key is a nonexistant function which should not be referenced anywhere, did you modify test_sqlite3.cpp? It should only be using sqlite3_key (which is defined in codecext.c).

OlivierJG commented 10 years ago

(the parameter name is supposed to be omitted to /avoid/ a warning about an unused parameter, what kind of warning warns about omitting parameter names?)

lragon commented 10 years ago

no,it is sqlite3_key not sqlite3key,i did not do any thing to test_sqlite3.cpp,here is some screenshot 2014-01-17 10 56 16 2014-01-17 10 56 37

lragon commented 10 years ago

it seems sqlite3_key did not be declared,did I miss some thing?

OlivierJG commented 10 years ago

It's been declared in sqlite3.h (it wouild fail to compile otherwise), the linker says it has not been /defined/, which it should be in codecext.c. It seems you are compiling with a C compiler, and not a C++ compiler, I've not tested this.

lragon commented 10 years ago

hi! OlivierJG,I just got it worked!,I think define SQLITE_HAS_CODEC did not work with patch,I define in sqlite3.c manually and build again,then it worked,All Seems Good! thanks very much! this issue can be close now.

lragon commented 10 years ago

final question,how to open a encrypt db file in command line,in your test case,I did this

sqlite3 testdb pragma key=anotherkey; SELECT * FROM test; Error: file is encrypted or is not a database but it not work

corytrese commented 10 years ago

Do you have a patch applied to shell.c?

I found that the sqlite3 command line needed shell.c patched to support .key commands.

Your use, above, is very similar to how I use use it.

Cory Trese

937-609-9644 http://www.tresebrothers.com/

Try Our Android Games https://play.google.com/store/apps/developer?id=Cory+Trese

On Fri, Jan 17, 2014 at 8:53 AM, ryan li notifications@github.com wrote:

final question,how to open a encrypt db file in command line,in your test case,I did this $ sqlite3 testdb

pragma key=anotherkey; SELECT * FROM test; Error: file is encrypted or is not a database but it not work

— Reply to this email directly or view it on GitHubhttps://github.com/OlivierJG/botansqlite3/issues/6#issuecomment-32622815 .

lragon commented 10 years ago

hi corytrese,very nice style of your game!I will try patch shell.c and try again.thanks!