Include webp.lib to project
-
My project loads and displays (jpeg, png) images in several formats. everything works fine.
In order to add web, I put ".lib" for Windows and Linux in one folder as shown in the picture, and set up and compiled the pro file as above.
I did "include/encode.h" and "include/decode.h".win32:CONFIG(release, debug|release): LIBS += -L$$PWD/webp -lwebp else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/webp -lwebp else:unix: LIBS += -L$$PWD/webp -lwebp INCLUDEPATH += $$PWD/webp LIBS += -L$$PWD/webp DEPENDPATH += $$PWD/webp
Compiled in MinGW environment. Compilation itself works.
If I don't link to the .pro file, I get an error, but the compilation doesn't invoke a message like "Cannot find -lwebp".So I put the following sentence.
Compiling at this point crashes and the window doesn't show up.
If I delete the WebPConfig statement below and recompile it works fine.
What could be the problem?WebPConfig config; if (!WebPConfigInit(&config)) { QMessageBox::information(this, "title", tr("Failed initialize WebPConfig.")); return false; }
I create the project with qmake and debug it in MingGW environment.
Thanks for your time. -
@MyNameIsQt said in Include webp.lib to project:
Compiled in MinGW environment. Compilation itself works.
and
Compiling at this point crashes and the window doesn't show up.- Compile == each source code file is syntactically correct and complete
- Link == the object files from compile plus any included libraries produce a result with no undefined references (i.e. between files or libraries)
- Run == The result of linking can find everything it is dynamically linked to in order to start.
If the compiler and linker were happy (your first statement) then this sounds like running your program crashes at start. Crashing a compiler or linker is a rare thing.
The most likely reason for the program failing after adding a new run-time dependency is that the dependency is not met at run-time. The webp.dll (matching the libwebp.a link library) must either be in the current working directory of your running program, on the system PATH, or in one of the few standard locations that Windows looks. If the other libraries in your directory are directly, or indirectly, required then this applies to them as well.
-
@MyNameIsQt said in Include webp.lib to project:
If I don't link to the .pro file, I get an error, but the compilation doesn't invoke a message like "Cannot find -lwebp".
There is no such thing as "link to the
.pro
file", so don't know what that means.Compiling at this point crashes and the window doesn't show up.
How does "compiling crash"? The compiler crashes?? I doubt it.
Do you mean "code always compiles and links fine, but when run it crashes on the call to
WebPConfigInit(&config)
"? If so any number of things might be wrong. Bad code, incompatible versions, incompatible compiler options, incorrect usage of function call, etc. You might (or might not) glean something by looking through the stack trace from the debugger when it crashes. -
@JonB
I'm sorry. English isn't my native language. sorry about that.
Are you means the .pro file is wrong? Is -lwebp not linked?
Compiling and loading the .jpg or png , etc works fine.
But "WebPConfig config;" If this statement is inserted into the code and debugged,
The execution window does not even appear and the following message appears in "application output".
_Qt_6_0_0_MinGW_64_bit-Debug\debug\WebpEditor.exe crashed. -
@MyNameIsQt said in Include webp.lib to project:
Compiled in MinGW environment. Compilation itself works.
and
Compiling at this point crashes and the window doesn't show up.- Compile == each source code file is syntactically correct and complete
- Link == the object files from compile plus any included libraries produce a result with no undefined references (i.e. between files or libraries)
- Run == The result of linking can find everything it is dynamically linked to in order to start.
If the compiler and linker were happy (your first statement) then this sounds like running your program crashes at start. Crashing a compiler or linker is a rare thing.
The most likely reason for the program failing after adding a new run-time dependency is that the dependency is not met at run-time. The webp.dll (matching the libwebp.a link library) must either be in the current working directory of your running program, on the system PATH, or in one of the few standard locations that Windows looks. If the other libraries in your directory are directly, or indirectly, required then this applies to them as well.
-
@ChrisW67 said in Include webp.lib to project:
The most likely reason for the program failing after adding a new run-time dependency is that the dependency is not met at run-time.
Although this is a true statement, and I see others have upvoted your post, I don't see this as the case here for the OP. Once linked against the
.lib
file for the DLL that DLL will be required by the executable at start up, and if not found it would not run but produce an error when invoked.That is not what the OP reports. It looks like the compilation/linking has gone find and the DLL has been found at runtime. (This could be verified by having the
WebPConfigInit()
call somewhere in code but not actually executing it.) Now the code fails on calling anythingWebPConfig
. This suggests to me one of the many possible runtime issues suggested in my previous post. If allowed to crash inside the debugger the stack trace might give a clue. -
@JonB Without knowing exactly what
WebPConfigInit
is doing internally, who can say. It may be trying to dynamically load one of the other DLLs and failing badly, or returning false and this being called "crashing" by the OP. I agree that more information would be useful. -