ATL linker error: Cannot open input file ***.obj - c++

I am trying to use the ATL library in my program. I am using Qt 5.2.
After adding the header files path to the Qt .pro file:
INCLUDEPATH += "C:/WinDDK/7600.16385.1/inc/at171/"
the first error was:
LNK1104: cannot open file 'atls.lib'
This was solved by adding path to the atls.lib:
LIBS += "C:/WinDDK/7600.16385.1/lib/ATL/i386/"
Now I get the error:
LNK1181: cannot open input file 'C:/WinDDK/7600.16385.1/lib/ATL/i386/.obj'
There are no object files in this folder, but why does it look for one when it requested the atls.lib?
I need some help to solve this problem.

I'm not sure exactly how your Makefile is setup, but LIBS is generally reserved to be a list of .a, .so, or .lib files. You would want to set LIBPATH to specify what directory to search for all the libraries in LIBS
INCLUDEPATH += "C:/WinDDK/7600.16385.1/inc/at171/"
LIB += "atls.lib" # shouldn't be needed: it's already looking for atls.lib.
LIBPATH += "C:/WinDDK/7600.16385.1/lib/ATL/i386/"

Related

How to use third-party libraries in Qt 6.3.2

I wanted to use a library in my Qt project which it has three files: One header file (.h file), One static file (.lib), and finally a Dll file which I have to use it along my executable.
I added .h file content to my project but I should introduce .lib file to the Qt linker. I use the following comment for the linker in configuration file:
LIBS += Path to lib file
But it frequently gives me the following error:
Parse error. Expected "(", got unquoted argument with text "+=".
Then I try the following one again:
LIBS += "Path"
It gives me the above error again, I used the following code too:
LIBS += ("Path")
But it is not work again. However, How can I introduce .lib file to the linker in Qt 6.3.2?
Thank you.

Qt automatically generated .rc file cannot open include file 'windows.h'

In my Qt 5.9.1 project, I wanted to add version info to the executable to help with debugging. So, I added VERSION = 1.0.0 to the 'Project.pro' file, which automatically generated a 'Project_resource.rc' file, as expected from Qt Version.
However, the project now fails to compile, giving the error RC1015: cannot open include file 'windows.h' on the line #include <windows.h> in 'Project_resource.rc'. I know that windows.h is known by the compiler at another point in the program, because in main.cpp I #include <windows.h> and use a function from there, and that successfully compiles. I just can't figure out why the 'Project_resource.rc' can't find that same file.
Note: I have the following above the VERSION = 1.0.0 line in 'Project.pro', which is how my main.cpp can find <windows.h>.
INCLUDEPATH += "C:/Program Files (x86)/Windows Kits/10/Include/10.0.10240.0/ucrt"
LIBS += -L"C:/Program Files (x86)/Windows Kits/10/Lib/10.0.10240.0/ucrt/x64"
INCLUDEPATH += "C:/Program Files (x86)/Windows Kits/10/Include/10.0.10240.0/um"
LIBS += -L"C:/Program Files (x86)/Windows Kits/10/Lib/10.0.10240.0/um/x64"
INCLUDEPATH += "C:/Program Files (x86)/Windows Kits/10/Include/10.0.10240.0/shared"
Remember .rc files have their own AdditionalIncludeDirectories.
It's possible that your project had set the Windows SDK properly set as one of the Include Directories values (hence your .cpp file resolves the windows.h header file) but not the .rc file (which would explain why windows.h can't be resolved from it).
If you're using Visual Studio 2019, try this:
Right click your .rc file on the Solution Explorer
Go to Resources -> General
Edit the Additional Include Directories
Include $(WindowsSDK_IncludePath) Macro
Be sure to accept and save the change.
You should stop seeing this error right after having done this.
If the ".rc file cannot open include file" was referring to a different file, just try the same but use the proper macro/path value on step 4.

Qt using .dll in .dll

I want to use one .dll file in another. But it seems like I'm doing something wrong with it. I have two library project ScaraControlGUI and ScaraLogic, and I want to use ScaraLogic into ScaraControlGUI, so I added appropriate lines in ScaraControlGUI's .pro file:
DEPENDPATH += . ../ScaraLogic
INCLUDEPATH += ../ScaraLogic
LIBS += -L../ScaraLogic/debug -lScaraLogic
And I receive:
scaralogic.h: No such file or directory
When I want to include this file. I'm sure that this file exist so I bet that I'm doing something wrong around .pro files.
What I'm doing wrong ? Adding ScaraControlGUI .dll to main executable project works fine like this.
Thanks in advace for help.
As your header is in ScaraLogic/Headers directory, you have to include it as #include <Headers/scaralogic.h>, or, which is better, set INCLUDEPATH as
DEPENDPATH += . ../ScaraLogic
INCLUDEPATH += ../ScaraLogic/Headers
LIBS += -L../ScaraLogic/debug -lScaraLogic
in the project file, and still use #include <scaralogic.h>.
I resolved my problem. My ScaraControlGUI subproject was building properly. Problem was in my main project ScaraControl and to solve this I needed to add LIBS and INCLUDEPATH too.

Qt5: Poppler weird linker error

I downloaded pre-built win32 poppler binaries from this page. Added the path for the include folder and lib folder in the .pro file:
INCLUDEPATH += "C:\\test_folder\\poppler-0.24.5-win32\\include\\poppler-qt5"
LIBS += -L/"C:\\test_folder\\poppler-0.24.5-win32\\lib"
In main.cpp i include "poppler-qt5.h" without errors, so I would think that poppler was added correctly. However when testing it by opening a pdf file, as described here,
QString path = "C:\\Windows\\System32\\spool\\PRINTERS\\test_file.pdf";
Poppler::Document *doc = Poppler::Document::load(path);
I receive a linker error:
Can someone help me out here?
I am missing the -l in yout LIBS line
LIBS += -L/"C:\\test_folder\\poppler-0.24.5-win32\\lib" -lpoppler-qt5
Eventually rename the lib since .dll.a is not a standard extension in windows.
Edit: Works without renaming the library:
.pro File:
INCLUDEPATH += $$quote(D:\Users\username\Downloads\poppler-0.24.5-win32\poppler-0.24.5-win32\include\poppler-qt5)
LIBS += -L$$quote(D:\Users\username\Downloads\poppler-0.24.5-win32\poppler-0.24.5-win32\lib) -lpoppler-qt5
.cpp File:
#include <QApplication>
#include <mycpp.h>
#include <poppler-qt5.h>
/* Some Code here */
QString path = "D:\\SomePDF.pdf";
Poppler::Document *doc = Poppler::Document::load(path);
/* More Code here */
I had the same problem and I resolved it with this method:
Copy dll file if you find in folder \poppler-0.24.5-win32\bin\ to folder where Qt generate executable file. Then download zlib1.dll and insert this dll to folder where Qt generate executable file. Try now.
This works for me. I compiled with qt 5.3 in Windows XP SP3.

Qt Creator and static libraries

I'm quite a newbie with C++ and maybe that's a very stupid question, but how do one include a header from a static linked library?
I've created a static library in Qt Creator with the following .pro file:
QT -= gui
TARGET = Foobar
TEMPLATE = lib
CONFIG += staticlib
SOURCES += thefoobar.cpp \
sub/subbar.cpp
HEADERS += thefoobar.h \
sub/subbar.h
compiled it and put the resulting libFoobar.a into the "extstaticlibs" folder of my target project.
In my target projects .pro file i've added the following lines:
LIBS += -L$$PWD/extstaticlibs/ -lFoobar
INCLUDEPATH += $$PWD/extstaticlibs
The target project compiles without problems. But when I try to include the header thefoobar.h in one of my code files:
#include "thefoobar.h"
it always results in an error:
error: thefoobar.h: No such file or directory
Any suggestions for the correct syntax would be very much appreciated.
Kristoffer
Check where you have placed your "thefoobar.h" header file . Place it in the "extstaticlibs/" folder .
If I follow your description correctly, you ONLY put the static library into your extstaticlibs directory.
You need to carry over your thefoobar.h file too. If you follow the common structure you could make:
extstaticlibs/include <- thefoobar.h goes here
extstaticlibs/lib <- libFoobar.a goes here
You then need to modify your project file like this:
LIBS += -L$$PWD/extstaticlibs/lib -lFoobar
INCLUDEPATH += $$PWD/extstaticlibs/include
Of course you can all throw it in one directory, if you want, but it may be helpful to sort things out in the beginning.