Reputation: 16373
I need to use a C library to access and older file format used by a legacy application. The library I installed was libdbf. (Did ./configure && make && make install). It was installed under /usr/local/lib:
libdbf.0.0.1.dylib
libdbf.0.dylib
libdbf.a
libdbf.dylib
libdbf.la
I'm loosely familiar with C syntax and have done some very trivial things in C and C++, but don't know how to include the library.
How can I include this library in my project? Sorry for the noobie question.
Upvotes: 1
Views: 370
Reputation: 22135
When you compile your project use -ldbf
The -l
means link, and the dbf
is the name of the library (you don't need to include the lib
part of the name).
Edit:
I haven't used Qt, but it looks like you can add
unix:LIBS += -ldbf
To your .pro
file. Sources 1, 2
By default, gcc will look in /usr/local/include
for the headers and in /usr/local/lib
for the library. In case it you need to make it explicit, you can also add:
-I/usr/local/include -L/usr/local/lib
Upvotes: 2
Reputation: 11726
If you'd like to compile your project with symbols exported by the library you have to add -I /usr/local/include
, assuming that the headers were properly installed. For linking you'll need to add -L /usr/local/lib -ldbf
. You can also pass the path to the library explicitly, so instead of -L /usr/local/lib -ldbf
add /usr/local/libdbf.0.dylib
.
See GCC's linking options.
Upvotes: 1