Procedures for linking user DLL to exe project

Procedures for linking user DLL to exe project

12
Basic UserBasic User
12

    Sep 29, 2015#1

    This question regards the setup in UEStudio for linking user created DLL to an active exe project.

    Assuming the DLL is compiled and built correctly, I am starting a blank console exe project and wish to link my DLL to this newly created exe project.

    My first step is go to the Set Compiler Options ..., then I go down to the linker options, and under the library = option, I added the DLL file name using the switch -I as in -ICustomDLL at the end, i.e. -lstdc++ -lkernel32 -user32 -lgdi32 -lcomctl32 -lcomdlg32 -ITestDLL

    Just to make things very simple, I also copied the TestDLL file into my active exe project directory under debug or release (depending on build preference) to isolate this linking issue. I also added the #include "TestDLL.h" header statement to my main exe source file, and I also copied the DLL header file into my active exe directory to isolate this single issue.

    However, when I attempted to call the function (std::cout << fnTestDLL();) in the active exe project file, I got the message:

    Code: Select all

    undefined reference to `_imp__z9fnFunctionv`
    Something is wrong in the settings, please help :).

    Thanks.

    6,675585
    Grand MasterGrand Master
    6,675585

      Sep 30, 2015#2

      This time it would be really helpful if you let us know which compiler you use.

      Have you really appended -ITestDLL with an upper case i instead of a lower case L as all standard libraries are specified for link process?

      Try compilation with -lTestDLL using l for link.

      -I with an upper case i is usually the option to specify an Include directory containing public *.h files included with
      #include <PublicHeaderFile.h>
      as such header files are not referenced relative to file with the include statement like local header files are included with
      #include "LocalHeaderFile.h"

      Well, most C/C++ programmers have never learned what is the difference in including a header file with angle brackets or with double quotes as for compilation it often does not make a difference because compilers include the directory of the file dynamically to list of public include directories in case of a local header file is included with angle brackets instead of double quotes. And compilers look also in public include directories for a header file included with double quotes when it can't be found in directory of the file containing the include statement. But for other applications like static code analysis tools it makes a big difference if a header file is a local or a public header file.
      Best regards from an UC/UE/UES for Windows user from Austria

      12
      Basic UserBasic User
      12

        Sep 30, 2015#3

        Hi Mofi,

        Thanks for all your valuable feedback and answers. I get it working now. At first I tried using l(link), got an error, said it couldn't find the file, then I tried using I(Include) and got the error _imp__z9fnFunctionv which is more formidable. :) Based on your answers I went back and changed it to l(link), put in the correct path (sorry, UEStudio setting is still somewhat new to me), and now I got it to work. The compiler used was was MinGW. :)

        Thank you again.