Reputation: 3
I am trying to use sqlite3 in my Eclipse C project, I have added sqlite3.h and its address: /usr/include/ to linker, but still get this error message:
make all
Building target: SQLiteTest
Invoking: GCC C Linker
gcc -L/usr/include/ -o "SQLiteTest" ./hello.o -lsqlite3.h
/usr/bin/ld: cannot find -lsqlite3.h
collect2: error: ld returned 1 exit status
make: *** [SQLiteTest] Error 1
I guess I have to add it to compiler as well, have tried many ways, but none of them worked.
Thanks for help
Upvotes: 0
Views: 1898
Reputation: 753675
When compiling and linking C programs:
-I/some/where/include
option is used to specify where headers (include files) are found,-L/some/where/lib
option is used to specify where libraries are found,-lname
option is used to say "link with the library libname.so
or libname.a
"The suffixes on libraries vary by platform — choose from .sl
, .sa
, .dll
, .lib
, .dylib
, .bundle
, to name but a few alternative extensions.
The -L/usr/include
option is unlikely to be correct. Headers are stored in /usr/include
, and not libraries. Changing that to -I/usr/include
is unnecessary; the compiler will search in /usr/include
anyway. If the sqlite3.h
header is in /usr/include
, it will be found without options. If it is somewhere else, like perhaps /usr/local/include
or /opt/sqlite3/include
, then you may well need to specify -I/usr/local/include
or -I/opt/sqlite3/include
on the command line. In each case, you might also need -L/usr/local/lib
or -L/opt/sqlite3/lib
as well. (Note that your compiler might, but probably won't, search in /usr/local
automatically.)
As noted in the comments, you would not specify -lsqlite3.h
on the command line. It would mean that there was a library such as libsqlite3.h.so
somewhere on your system, which is an implausible name. Most likely, you should just specify -lsqlite3
on the linking command line.
Upvotes: 1