【发布时间】:2017-01-23 21:26:01
【问题描述】:
这是我的包括:
#include <iostream>
#include <string>
#include <cstring>
#include <stdio.h> //for snprintf
#include <libscrypt.h>
#include <sqlite3.h>
#include "generator.h" //has no dependencies
这是我的 g++ 4.2.1 命令编译错误:
# g++ -I/usr/local/include -L /usr/local/lib test.cpp generator.cpp -o test -lscrypt -lsqlite3
/tmp//cctxmw4C.o: In function `insertUser()':
test.cpp:(.text+0x607): undefined reference to `libscrypt_salt_gen(unsigned char*, unsigned long)'
test.cpp:(.text+0x6c3): undefined reference to `libscrypt_scrypt(unsigned char const*, unsigned long, unsigned char const*, unsigned long, unsigned long long, unsigned int, unsigned int, unsigned char*, unsigned long)'
collect2: ld returned 1 exit status
类似的 C 代码用 GCC 编译得很好。 我不认为参数的顺序是问题 -- 我尝试了多种变体,包括移动 -I、-L 和两个 -l 标志。 scrypt 和 sqlite3 都是 C 库,尽管在 -I 和 -L 中分别具有标头和共享库,但 sqlite3 不会引发错误。
【问题讨论】:
标签: c++ sqlite undefined-reference