-1

Everybody, I am a beginner and I have still have some things I am confusing about.

I have a program qt which I want to include a extern library. Generaly, to include a extern library I use the macros :

INCLUDEPATH += "path/to/the/include/headers/file"
LIBS += -L"path/to/where/the/lib/are" \
        -llibname   // .a for gcc .lib for mscv

Then I can use the library in my program. But at the end the qt aplication program use the .dll associated to the lib name. So my question, why can't we use directly the .dll in Qt ? I don't know very much the difference between a ".lib" and ".dll" execpt a ".dll" is used at the runtime.

My problemen is have a library with only the dll and the include headers file. Is there a way to use this library like this or I must have the .a or .lib associated ?

EDIT : Ok now,thanks to the useful advice, I understand better the difference between, .lib and .dll and how to use a dll without a .lib with only header. But I am having a issue. With the header, I can create the object, the compilator doesn't bother about it can't find the object and its method, but When I compile, I have some problems about "undefined reference to a method".

If I correctly understand, the reference cannot be found because the reference are defined in the .lib, that's why it can't find it. So my question :

How can I say to the compilator that the reference to a method will be defined at runtime and not at compile time ?

EDIT2 : Ok so apparently you can get a pointer of an object with a dll but you can't use its methods, so I think I am facing the wrong way. Thanks again for you answer.

Best regards,

user3627590
  • 281
  • 1
  • 4
  • 10

1 Answers1

1

There are 2 types of lib file, see this asnwer: https://stackoverflow.com/a/2375144/2064646

You can just use a .dll without .lib file, but through GetProcAddress function.

Community
  • 1
  • 1
so61pi
  • 780
  • 2
  • 7
  • 21