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.
Related
Environment
I am on Windows 7 64bit
Qt Creator 3.4.2 (opensource)
Based on Qt 5.5.0 (MSVC 2013, 32 bit)
Goal
I am using a 3rd party library. I need to #include the library files like that since that is how the library files include their dependencies.
What I have tried
in myFunction.h (in same directory as .pro file)
#include <lib_header.h>
...
in .pro file
LIBS += -L"$$PWD/Debug/" -llib_name
SUBDIRS += "$$PWD/Include"
DEPENDPATH += "$$PWD/Include"
INCLUDEPATH += "$$PWD/Include"
DEPENDPATH += "C:/Users/Steves Laptop/UX3D/Include"
INCLUDEPATH += "C:/Users/Steves Laptop/UX3D/Include"
VPATH += "$$PWD/Include"
VPATH += "C:/Users/Steves Laptop/UX3D/Include"
...
lib_header.h is in /Include
Results
I get tool tip when hovering over the #include line of the exact location of the file. On compile it says it can't be found. I expect this is a newbie mistake but have spent 3 hrs wasted so far. If in my files I do it like this #include <Include/lib_header.h> it works. I need a way to reference them directly though in order for the rest of the library to work.
Even if someone could provide a link or reference source file that documents Qt's implementation of the #include <> tag that would be sufficient.
I just started with Qt and some issues came up. I'm sure it must be a simple solution but I just can't find it.
I have two Projects, ProjectOne and ProjectTwo. I'd like you use the class foo from ProjectOne in main.cpp from ProjectTwo. When I run my Programm The Files are copied/referenced into ProjectTwo, but when i try to include foo in my main.cpp (#include "foo.h") i recieve the following error:
> main.cpp:3: error: C1083: Cannot open include file: 'foo.h':
> No such file or directory
Here's my Structure:
-ProjectOne
-ProjectOne.pro
-Headers
-foo.h
-Source
-foo.cpp
-Other files
-ProjectOne.pri
-ProjectTwo
-ProjectTwo.pro
-ProjectOne
-ProjectOne.pri
-Headers
-foo.h
-Sources
-foo.cpp
-Sources
main.cpp
Here's what i edited on my .pro and .pri files
**ProjectOne.pri**
INCLUDEPATH += $$PWD
SOURCES += $$PWD/foo.cpp
HEADERS += $$PWD/foo.h
**ProjectTwo.pro:**
include(../ProjectOne/ProjectOne.pri)
QT += core
SOURCES += foo.cpp
HEADERS += foo.h
I'm using Qt Creator 3.1.2 on Windows 7. My Programming Language is C++ and I'm compiling with VisualStudio 10 Express.
Any help is greatly appreciated!
When including a file that isn't directly in you project folder you need to include it with full or relative path.
i.e.
#include "bar/foo.h"
or
#include "../../bar/foo.h"
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/"
i try to use yaml-cpp in cmake with windows 7
I followed the tutorial and build the cmake and get yaml-cpp.dll , yaml-cpp.lib , yaml-cpp.exp
i saved them inside the libs directory in my project.
with
LIBS += -L$$PWD/libs -lyaml-cpp
i add in in my pro file. The include files are added with
INCLUDEPATH +=$$PWD\includes
inside this is my yaml-cpp directory with all include files.
On my program I use
#include <yaml-cpp/yaml.h>
This all is compiling without an error. But when I add
YAML::Node doc;
i get the undefiened reference to Yaml::Node ERROR
i dont know what i have forgot to link.
Do you have an idea? thank you for help
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.