I was able to create a DLL file in the Debug mode, but due to this error I was unable to use it.
Just a message that I wanted to display at the command line.
I was able to create a DLL file in the Debug mode, but due to this error I was unable to use it.
Just a message that I wanted to display at the command line.
What would you like us to do about it? Apart from being able to guess you are use a Microsoft compiler on a Windows machine we have absolutely no information to work with.
Here's the code, really nothing. Just trying to create DLL and use it
File Name : createDLL.h
#ifndef CREATEDLL_H
#define CREATEDLL_H
#include "createdll_global.h"
class CREATEDLLSHARED_EXPORT CreateDLL
{
public:
CreateDLL();
void Message();
};
#endif // CREATEDLL_H
File Name : createdll_global.h
#ifndef CREATEDLL_GLOBAL_H
#define CREATEDLL_GLOBAL_H
#include <QtCore/qglobal.h>
#if defined(CREATEDLL_LIBRARY)
# define CREATEDLLSHARED_EXPORT Q_DECL_EXPORT
#else
# define CREATEDLLSHARED_EXPORT Q_DECL_IMPORT
#endif
#endif // CREATEDLL_GLOBAL_H
File Name : createdll.cpp
#include "createdll.h"
#include "qDebug.h"
CreateDLL::CreateDLL()
{
}
void CreateDLL::Message()
{
qDebug() << "Hello from inside DLL";
}
Compiled it, just noticed now, exited with error code -1 ?
M:\QtExamples\build-createDLL-Desktop_Qt_5_5_0_MSVC2012_32bit-Debug exited with code -1
DLL File Size = 46KB
For using the DLL file I created a Console Application.
I loaded the header files createdll.h & createll_global.h into the usingDLL project.
Included the LIBS += "DLL File Path i.e. output from the code given"
Compiled and got the error LNK1107 invalid or corrupt file: cannot read at 0x2D0
Post the actual pro file you are using for your consumer program. If you have explicitly listed the DLL file in the LIBS variable then that would explain why the linker gets confused. The linker is not expecting the runtime library, it is expecting the link library created at the same time.
Here's the pro file :
#-------------------------------------------------
#
# Project created by QtCreator 2015-08-26T16:31:15
#
#-------------------------------------------------
QT += core
QT -= gui
TARGET = usingDLL
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app'
LIBS += "D:\Testing\build-createDLL-Desktop_Qt_5_5_0_MSVC2012_32bit-Debug\debug\createDLL.dll"
SOURCES += main.cpp
HEADERS += \
../createDLL/createdll.h \
../createDLL/createdll_global.h
Qt Code:
LIBS += "D:\Testing\build-createDLL-Desktop_Qt_5_5_0_MSVC2012_32bit-Debug\debug\createDLL.dll"To copy to clipboard, switch view to plain text modeThe DLL file is a run-time library. In the same folder you will likely find a "createDLL.lib", which is the import or link library. It contains stubs and data about the run-time library that the linker can attach to the remainder of your program so it can access the run-time library at (you guessed it) run time. Your PRO file could look like:Originally Posted by Me
although you could use the other syntax (something like):Qt Code:
LIBS += "D:/Testing/build-createDLL-Desktop_Qt_5_5_0_MSVC2012_32bit-Debug/debug/createDLL.lib"To copy to clipboard, switch view to plain text mode
Qt Code:
LIBS += -L"D:/Testing/build-createDLL-Desktop_Qt_5_5_0_MSVC2012_32bit-Debug/debug" -lcreateDLLTo copy to clipboard, switch view to plain text mode
Bookmarks