I am trying to make QT application using C++ language which will record the video from analogue camera. so I included the videoInput.h and videoInput.lib files in my project but when i am trying to run the my project then the following error occurs.
the error is:
mingw32-make[1]: No rule to make target path/to/videoInputd.lib', needed by 'debug\test.exe'. Stop.
please give me the solution.
thanks for help.
Thanks for your reply. I already added LIBS.
My .pro file is
QT += core gui
QT += widgets
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = test
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h \
../../../"Qt Projects/Test projects/test" \
videoInput.h
FORMS += mainwindow.ui
INCLUDEPATH += E:\\ImageProcessing\\opencv_cmake_binaries\\install\\include
LIBS += -LE:\\ImageProcessing\\opencv_cmake_binaries\\install\\lib \
-lopencv_core244.dll \
-lopencv_highgui244.dll \
-lopencv_imgproc244.dll \
-lopencv_features2d244.dll \
-lopencv_calib3d244.dll
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/ -lvideoInput
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/ -lvideoInputd
INCLUDEPATH += $$PWD/../../../"Qt Projects/Test projects/test/videoInput"
DEPENDPATH += $$PWD/../../../"Qt Projects/Test projects/test/videoInput"
win32:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/videoInput.lib
else:win32:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/videoInputd.lib
end of .pro file.
and I changed the build mode to release mode and then try to run then new error comes. The error is
error: redefinition of 'bool comInit'
error: 'bool comInit' previously declared here
static bool comInit;
error: redefinition of 'class videoInput'
class videoInput{
error: previous definition of 'class videoInput'
class videoInput{
These four errors are in videoinput.h file the compiler shows me like this.
And I know the file name is videoInput.h but compile output shows me that videoInputd.lib, needed by debug\test.exe
Do as Sebastian tells (add videoInput.lib to LIBS) and switch build mode to release, since you have only release version of this library (videoInput.lib, not videoInputd.lib).
I got the solution. When I was trying to include videoInput.lib file in Qt creator, at that time it was displayed above mention error.
So I used qt-vs-addin which is available here. qt-vs-addin.
I designed GUI in qt-vs-addin using visual studio 2010 for my application and include videoInput.lib file in visual studio 2010 and now my application is ready. This will be helpful for someone.
Thanks to all.
I had similare problem "No tule ro mske tsrgrt. Th rrason was syntax error like
testwx:($(OBJS).... Check your syntax line by line
Related
When trying to run a simple program using the hdf5-file format i get these messages and the program crashes:
I found posts to other problems like this, but most of them refer to linux and python. I use C++ (Qt Creator) and Windows (Windows 7 64bit) with the MSVC17 64bit Compiler, so these solutions dont work for me.
I don't understand why this occurs, because i simply donwloaded the HDF5 version 1.10.2 and installed it, i don't know why it says something about the version 1.8.15. Where could this come from?
I guess "library version" (1.8.15) is the version of my hdf5.lib file, right?
What does "header version" (1.10.2) mean? I simply #include <hdf5.h> and #include <H5Cpp.h> in the main.cpp and added paths in the hdf5_test_2.pro (my project) file.
Here is my code:
hdf5_test.pro:
TEMPLATE = app
CONFIG += console c++11
CONFIG -= app_bundle
CONFIG -= qt
SOURCES += \
main.cpp
win32: LIBS += -L'C:/Program Files/HDF_Group/HDF5/1.10.2/lib/' -lhdf5 -lhdf5_cpp -lhdf5_hl_cpp
INCLUDEPATH += 'C:/Program Files/HDF_Group/HDF5/1.10.2/include'
DEPENDPATH += 'C:/Program Files/HDF_Group/HDF5/1.10.2/include'
win32:!win32-g++: PRE_TARGETDEPS += 'C:/Program Files/HDF_Group/HDF5/1.10.2/lib/libhdf5.lib'
else:win32-g++: PRE_TARGETDEPS += 'C:/Program Files/HDF_Group/HDF5/1.10.2/lib/liblibhdf5.a'
main.cpp:
#include <iostream>
#include <hdf5.h>
#include <H5Cpp.h>
using namespace std;
using namespace H5;
int main()
{
hid_t file_id;
herr_t status;
file_id = H5Fcreate("file.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
status = H5Fclose(file_id);
cout << "Hello World!" << endl;
return 0;
}
The code example i tried to use comes from High Level Introduction to HDF5 (Pages 16/17).
Solved (meaning next error)
I think i solved the problem: There was another Version of HDF5 installed (1.8.15) on the system (the one who used this PC before me installed it).
I told my programm to link my lib (1.10.2) and passed the path, but somehow he found the 1.8.15 version previously installed. I now told my program to link the old version and it worked.
My hdf5_test_2.pro (my project) looks now like this:
TEMPLATE = app
CONFIG += console c++11
CONFIG -= app_bundle
CONFIG -= qt
SOURCES += \
main.cpp
win32: LIBS += -LC:/Anaconda2/Library/lib/ -lhdf5 -lhdf5_cpp
INCLUDEPATH += C:/Anaconda2/Library/include
DEPENDPATH += C:/Anaconda2/Library/include
Nice so far, but i get these two warnings now:
Any ideas, what that means?
I am trying to compile a Qt project and it seems like OpenCV is having problems. From what I have read so far, this could likely be a compiler/linkage problem. I have tried a couple different compilers without any success. Other libraries seem to be fine (libtiff, STD, other Qt libraries), but OpenCV is causing problems. I haven't for the life of me been able to make any progress on fixing it, any suggestions would be much appreciated. Posted below are things that I believe might be valuable in finding a solution.
Qt Makefile (.pro):
QT += core gui multimedia widgets multimediawidgets opengl
TARGET = LAUWebCalTag
TEMPLATE = app
DEFINES += QT_DEPRECATED_WARNINGS
SOURCES += \
main.cpp \
laumemoryobject.cpp \
lauwebcamerawidget.cpp \
lauvideosurface.cpp \
lauvideoglwidget.cpp \
laucaltagglwidget.cpp \
laucaltagglobject.cpp
HEADERS += \
laumemoryobject.h \
lauwebcamerawidget.h \
lauvideosurface.h \
lauvideoglwidget.h \
laucaltagglwidget.h \
laucaltagglobject.h
RESOURCES += lauwebcameracapture.qrc
CONFIG(release, debug|release):DEFINES += QT_NO_DEBUG_OUTPUT
win32 {
INCLUDEPATH += $$quote(C:\Users\Sam\Downloads\opencv\build\include) $$quote(C:/usr/include)
INCLUDEPATH += $$quote(C:\Users\Sam\Downloads\tiff-4.0.9\tiff-4.0.9\libtiff)
DEPENDPATH += $$quote(C:\Users\Sam\Downloads\opencv\build\include) $$quote(C:/usr/include)
LIBS += -L$$quote(C:\usr\libs) -lopengl32
LIBS += -L$$quote(C:\Users\Sam\Downloads\opencv\build\x64\vc12\lib)
LIBS += -L$$quote(C:\Users\Sam\Downloads\tiff-4.0.9\tiff-4.0.9\libtiff) -llibtiff_i
CONFIG(release, debug|release): LIBS += -lopencv_world310
CONFIG(debug, debug|release): LIBS += -lopencv_world310d
}
Issues:
[Screenshot of Resulting Compile Issues]
Build and Run:
[Build and Run Kit Options]
[CMake (Not 100% sure if CMake is necessary for this project or right)]
I also thought the way cv:: was being declared was strange for this:
namespace cv
{
using std::vector;
}
I apologize for the dumb question, I am brand new to both Qt and OpenCV
I have bee trying to get assimp running in QT 5.2 in order to import some 3D objects, but Im having a problem with (I believe) the linker.
I installed it via cmake, first downloading the source files from here http://sourceforge.net/projects/assimp/files/assimp-3.0/, then using cmake to compile and install.
Then, I have tried to run the example they provide in the documentation
#include <assimp/cimport.h> // Plain-C interface
#include <assimp/scene.h> // Output data structure
#include <assimp/postprocess.h> // Post processing flags
bool DoTheImportThing( const char* pFile)
{
// Start the import on the given file with some example postprocessing
// Usually - if speed is not the most important aspect for you - you'll t
// probably to request more postprocessing than we do in this example.
const aiScene* scene = aiImportFile( pFile,
aiProcess_CalcTangentSpace |
aiProcess_Triangulate |
aiProcess_JoinIdenticalVertices |
aiProcess_SortByPType);
// If the import failed, report it
if( !scene)
{
// DoTheErrorLogging( aiGetErrorString());
return false;
}
return true;
}
But when trying to compile this piece of code, I get the error
error: undefined reference to `aiImportFile'
error: collect2: error: ld returned 1 exit status
I am using a 32 bit linux mint. Does anybody have any idea why is it not linking? Should I have compiled with cmake using a specific flag? i havent been able to found any special flags in any posts around.
Thanks!
I finally solved it! Apparently, QT has a tool for importing external libraries. I just had to right click on the project, click add library, and add the file located at /user/local/libassimp.a
This added the following lines to my .pro file:
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../../../usr/local/lib/release/ -lassimp
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../../../usr/local/lib/debug/ -lassimp
else:unix: LIBS += -L$$PWD/../../../../../usr/local/lib/ -lassimp
INCLUDEPATH += $$PWD/../../../../../usr/local/include
DEPENDPATH += $$PWD/../../../../../usr/local/include
win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/../../../../../usr/local/lib/release/libassimp.a
else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/../../../../../usr/local/lib/debug/libassimp.a
else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/../../../../../usr/local/lib/release/assimp.lib
else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/../../../../../usr/local/lib/debug/assimp.lib
else:unix: PRE_TARGETDEPS += $$PWD/../../../../../usr/local/lib/libassimp.a
Theres possibly a more elegant way of coding that, but at least it worked.
Resolved. When I add my library as a normal internal library everything is fine. What I had failed to do was use the MY_LIBRARY_EXPORT macro on some free functions defined in a namespace. Somehow I had manipulated the library import in such a way to get those functions working, but it broke in other ways as described here.
I have not been able to use a shared library using the Qt Creator wizard. I have tried with dynamic linkage, and have failed, and cannot use as a static lib either. In both cases I get an 'undefined reference to `IMP_*' error.
Here are my pro files. They are both in the same SUB_DIR parent project and the paths are correct.
Relevant parts of the library pro file:
TARGET = Prospec
TEMPLATE = lib
CONFIG += staticlib
QMAKE_CXXFLAGS += -std=c++11
DEFINES += PROSPEC_LIBRARY
The entirety of the user .pro file. (ProspecTest is a unit test project for Prospec).
#-------------------------------------------------
#
# Project created by QtCreator 2013-12-12T15:04:30
#
#-------------------------------------------------
QT += testlib
QT -= gui
TARGET = prospectest
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
QMAKE_CXXFLAGS += -std=c++11
SOURCES += prospectest.cpp \
mltest.cpp \
convertertest.cpp \
numericitemtest.cpp
DEFINES += SRCDIR=\\\"$$PWD/\\\"
HEADERS += \
utilities.h \
mltest.h \
convertertest.h \
numericitemtest.h
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../Prospec/release/ -lProspec
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../Prospec/debug/ -lProspec
INCLUDEPATH += $$PWD/../Prospec/debug
DEPENDPATH += $$PWD/../Prospec/debug
win32:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/../Prospec/release/libProspec.a
else:win32:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/../Prospec/debug/libProspec.a
# Boost
INCLUDEPATH += C:/boost/boost_1_55_0/
LIBS += "-LC:/boost/boost_1_55_0/stage/lib/"
EDIT: the undefined reference errors happen only where I invoke functionality in a source file. For instance, if I construct a library object I get the error, but if I move that objects constructor into a header file, then compile is OK. Right now I'm not sure if the problem is due to the Qt environment, or me not understanding shared libraries in general.
The error you describe points to a linker error. It happens when a necessary object/lib file is not specified. The most likely scenario is this: you include a header and use a function from that header, but don't specify in which library that function is defined.
Small example:
//test.c
#include <winsock.h>
int main() { gethostbyname("localhost"); }
'undefined reference' linker error:
>gcc test.c
cczICEqq.o:test.c:(.text+0x1e): undefined refer ence to `gethostbyname#4'
collect2.exe: error: ld returned 1 exit status
In this case you would have to specify libwsock32.a like this:
gcc test.c -lwsock32
Also, note that a libsomething.a is not the only place where a reference can be resolved. You might have missed an object file.
Unfortunately without more details I am not able to tell you the exact problem.
You probably forgot to export your symbols, as described here on MSDN and in various questions on this website. It's a pain in general, and there are a few ways to handle this, none much better than the other.
This makes it so that the DLL and import library actually contain a reference to the symbols you compiled into it. You can compare it partially to GCC's symbol visibility, although that only works in Linux, and GCC also supports the stuff described on MSDN for Windows.
Had the same problem just now. Build was working fine on macOS/OSX but not on Windows with the same codebase. Thanks to rubenvb, who pointed me in the right direction. Here the full solution, how to do it for Qt:
Use Q_DECL_EXPORT on functions when building the lib. And use Q_DECL_IMPORT when using the functions from the lib.
Example how to do this here: https://wiki.qt.io/How_to_create_a_library_with_Qt_and_use_it_in_an_application#Creating_a_shared_library
Solved the problem in my case, hope it helps!
I'm having a simple yet extremely annoying problem with adding the external library files in QtCreator. I'm adding them via the following lines in .pro file:
INCLUDEPATH += $$quote(D:/dcmtk-3.6.0/Prefix Files/include)
LIBS += $$quote(-LD:/dcmtk-3.6.0/Lib files/Release/) \
-ladvapi32 \
-ldcmdata\
-loflog\
-lofstd\
-lws2_32\
-lnetapi32\
-lwsock32\
LIBS += $$quote(-LD:/dcmtk-3.6.0/Lib files/Debug/) \
-ladvapi32 \
-ldcmdata\
-loflog\
-lofstd\
-lws2_32\
-lnetapi32\
-lwsock32\
But every time it's giving the error :-1: error: LNK1181: cannot open input file 'files/Release).obj'.
I know the problem is occuring because of the spaces there, despite trying to follow the documentation it doesn't seem to work. I also think that may be QtCreator doesn't update the changes I'm trying to make. Any suggestions please? Thanks.
EDIT WITH SOLVED ANSWER:
I changed the codes in .pro file to this:
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TEMPLATE = app
TARGET = NewApp
##QMAKE_CXXFLAGS_DEBUG += /MTd
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui
DEFINES += _REENTRANT
QMAKE_CFLAGS_RELEASE -= -MD
QMAKE_CFLAGS_RELEASE = -MT
QMAKE_CFLAGS_DEBUG -= -MDd
QMAKE_CFLAGS_DEBUG = -MTd
QMAKE_CXXFLAGS_RELEASE -= -MD
QMAKE_CXXFLAGS_RELEASE += -MT
QMAKE_CXXFLAGS_DEBUG -= -MDd
QMAKE_CXXFLAGS_DEBUG += -MTd
QMAKE_LFLAGS_DEBUG += /NODEFAULTLIB:msvcrtd.lib
QMAKE_LFLAGS_RELEASE += /NODEFAULTLIB:msvcrt.lib
INCLUDEPATH += $$quote(D:/dcmtk-3.6.0/Prefix Files/include/)
CONFIG( debug, debug|release ) {
LIBS += $$quote(-LD:/dcmtk-3.6.0/LibFiles/Debug/) \
-ladvapi32\
-ldcmdata\
-loflog\
-lofstd\
-lws2_32\
-lnetapi32\
-lwsock32\
}
else {
LIBS += $$quote(-LD:/dcmtk-3.6.0/LibFiles/Release/) \
-ladvapi32\
-ldcmdata\
-loflog\
-lofstd\
-lws2_32\
-lnetapi32\
-lwsock32\
}
Here I had to add the lines:
QMAKE_LFLAGS_DEBUG += /NODEFAULTLIB:msvcrtd.lib
QMAKE_LFLAGS_RELEASE += /NODEFAULTLIB:msvcrt.lib
Because, if you turn on MT, you must use /NODEFAULTLIB switch to ignore these libraries: libc.lib, msvcrt.lib, libcd.lib, libcmtd.lib, msvcrtd.lib, otherwise you will get link problem.
And I also found the answer to LIB problems via this link where it's quoted:
"The normal
debug:LIBS += ...
else:LIBS += ...
solution breaks when users naively use CONFIG += debug or CONFIG += release to switch between debug and release builds (and they do; no-one remembers to say CONFIG -= release release_and_debug before CONFIG += debug :).
This is the canonical way to scope on debug:
CONFIG( debug, debug|release ) {
# debug
} else {
# release
}
"
Anyways, thanks a lot.
The right way to specify library link locations in a .pro file is actually via the QMAKE_LIBDIR variable:
QMAKE_LIBDIR += "D:/dcmtk-3.6.0/Lib files/Release/"
Your issue above is almost certainly because of missing quotes (the space is being interpreted as a argument break and you need it to be one argument).