我对这里一无所知。我想问一下错误在哪里。我创建了自己的dll (通过代码库),我想在另一个qt项目中使用它--我设置和执行qmake的所有内容,但它仍然抛出了LNK2019和LNK1120。我附上一个代码库和qt项目。
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)使用
#-------------------------------------------------
#
# 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/Debugmain.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();
}误差
LNK2019: main.obj:-1: Chyba: LNK2019: unresolved external symbol "__declspec(dllimport) int __cdecl text_pozdrav(int)" (__imp_?text_pozdrav@@YAHH@Z) referenced in function _main
LNK1120: debug\usingdll3.exe:-1: Chyba: LNK1120: 1 unresolved externals谢谢你的回答
发布于 2015-02-08 00:54:11
在VisualC++中编译gcc和qt的解析代码块
https://stackoverflow.com/questions/28381823
复制相似问题