问题描述:

I'm new here. I would like to ask where the error is.

I made my own dll (via codeblocs), and I wanted to use it in another qt project

Everything I set up and perform qmake, but it still throws me LNK2019 and LNK1120.

I attach a code library and qt project

dll6.dll

main.h

using namespace std;

#ifdef BUILD_DLL

#define DLL_EXPORT __declspec(dllexport)

#else

#define DLL_EXPORT __declspec(dllimport)

#endif

#ifdef __cplusplus

#endif

DLL_EXPORT void SomeFunction(const LPCSTR sometext);

DLL_EXPORT int text_pozdrav(int i);

#ifdef __cplusplus

#endif

#endif // __MAIN_H__

main.cpp

DLL_EXPORT int text_pozdrav(int i)

{

return i;

}

usingdll3(QT)

usingdll3.pro

#-------------------------------------------------

#

# Project created by QtCreator 2015-02-06T13:47:38

#

#-------------------------------------------------

QT += core

QT -= gui

TARGET = usingdll3

CONFIG += console

CONFIG -= app_bundle

TEMPLATE = app

SOURCES += main.cpp

HEADERS += \../dll6/main.h

win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../dll6/bin/Debug/libdll6.a

else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../dll6/bin/Debug/libdll6.a

else:unix: LIBS += -L$$PWD/../dll6/bin/Debug/ -adll6

LIBS += -LC:/Users/Jakub/Documents/Projekty/dll6/bin/Debug/dll6.dll

INCLUDEPATH += $$PWD/../dll6/bin/Debug

DEPENDPATH += $$PWD/../dll6/bin/Debug

main.cpp

#include <QCoreApplication>

#include <iostream>

#include <Windows.h>

#include <stdio.h>

#include "main.h"

using namespace std;

DLL_EXPORT int text_pozdrav(int i);

int main(int argc, char *argv[])

{

QCoreApplication a(argc, argv);

cout << text_pozdrav(22) << endl;

return a.exec();

}

Errors

LNK2019: main.obj:-1: Chyba: LNK2019: unresolved external symbol "__declspec(dllimport) int __cdecl text_pozdrav(int)" ([email protected]@[email protected]) referenced in function _main

LNK1120: debug\usingdll3.exe:-1: Chyba: LNK1120: 1 unresolved externals

thank you for your answers

网友答案:

resolved, codeblock compiled in gcc and qt in Visual C++

相关阅读:
Top