Undefined refence to '_imp__FunctionName'
-
Hello, i am trying to build a simple Qt project which is calling dll (dll built from Embarcadero C++ Builder) function but i have a undefined reference to that function.
Checked for function declaration , definition everything looks good.
i am using QT 5.15.2 Windows, MinGW 32 bit.This is how my .pro looks
QT -= gui
CONFIG += c++11 console
CONFIG -= app_bundleYou can make your code fail to compile if it uses deprecated APIs.
In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES +=
main.cppDefault rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target#LIBS += "..\MyDll\DLLProj.dll"
HEADERS +=
myDll.hDISTFILES +=
DLLProj1.a# \DllProj1.def
#win32: LIBS += -L$$PWD/./ -lDLLProj
#INCLUDEPATH += $$PWD/.
#DEPENDPATH += $$PWD/. -
Hi,
Where the symbols of that method properly exported ?
Is that compiler compatible with the one you are using currently ? You can't mix and match libraries from different compilers. For example MinGW and VS cannot be mixed.
Is the library of the same architecture as your main application ? -
Hi,
Where the symbols of that method properly exported ?
Is that compiler compatible with the one you are using currently ? You can't mix and match libraries from different compilers. For example MinGW and VS cannot be mixed.
Is the library of the same architecture as your main application ?Hi, Thanks for reply!!
I am new to C++ builder not sure about the compiler compatible need to check on that.
this is how i am exporting the function in dll source code using Emberacadero C++ builder.
extern "C" __declspec(dllexport) void myfun ( int * a);
-
Hi,
Where the symbols of that method properly exported ?
Is that compiler compatible with the one you are using currently ? You can't mix and match libraries from different compilers. For example MinGW and VS cannot be mixed.
Is the library of the same architecture as your main application ? -
You seem to be doing some pretty convoluted things here.
Your method seems to be a pure C method that you try to wrap in a C++ library so you should rather build a C dll that does not have the same constraints as a C++ dll. As for your use of the __declspec instruction, it's wrong. You have to export the symbol on build and then import the symbol when linking to the library.
For building C++ shared library, the dedicated chapter in Qt's documentation explains it pretty well.
-
You seem to be doing some pretty convoluted things here.
Your method seems to be a pure C method that you try to wrap in a C++ library so you should rather build a C dll that does not have the same constraints as a C++ dll. As for your use of the __declspec instruction, it's wrong. You have to export the symbol on build and then import the symbol when linking to the library.
For building C++ shared library, the dedicated chapter in Qt's documentation explains it pretty well.
i tried as below aswell but still have same issue
#ifdef IN_DLL
#define EXPORT_IMPORT __export
#else
#define EXPORT_IMPORT Q_DECL_IMPORT //__import
#endif#ifdef BORLANDC
extern "C" void __stdcall EXPORT_IMPORT myfun( int * a);
#else
extern "C" void __stdcall EXPORT_IMPORT myfun( int * a);
#endifEarlier i was using:
i was exporting on C++ builder side and importing in QT using following
QT:
extern "C" __declspec(dllimport) void myfun( int * a);C++ Builder:
extern "C" __declspec(dllexport) void myfun( int * a); -
Again: why are you trying to make a C++ library if you have only C functions ? It really complicate things for nothing.
-
Again: why are you trying to make a C++ library if you have only C functions ? It really complicate things for nothing.
-
That starts to make things a bit clearer.
On a side note, you used the Qt macros wrongly.
So your original dll is a C dll that you would like to port to C++ and you are using the technique you saw from the use of the library by the Borland compiler ?
-
That starts to make things a bit clearer.
On a side note, you used the Qt macros wrongly.
So your original dll is a C dll that you would like to port to C++ and you are using the technique you saw from the use of the library by the Borland compiler ?
-
You did not use Q_DECL_EXPORT.