Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Undefined refence to '_imp__FunctionName'
QtWS25 Last Chance

Undefined refence to '_imp__FunctionName'

Scheduled Pinned Locked Moved Unsolved General and Desktop
12 Posts 2 Posters 675 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • SGaistS SGaist

    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 ?

    M Offline
    M Offline
    MNag
    wrote on last edited by
    #3

    @SGaist

    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);

    1 Reply Last reply
    0
    • SGaistS SGaist

      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 ?

      M Offline
      M Offline
      MNag
      wrote on last edited by
      #4

      @SGaist

      BCC32C this is the compiler name which is used in Embarcadero C++ builder

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #5

        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.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        M 1 Reply Last reply
        0
        • SGaistS SGaist

          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.

          M Offline
          M Offline
          MNag
          wrote on last edited by MNag
          #6

          @SGaist

          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);
          #endif

          Earlier 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);

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #7

            Again: why are you trying to make a C++ library if you have only C functions ? It really complicate things for nothing.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            M 1 Reply Last reply
            0
            • SGaistS SGaist

              Again: why are you trying to make a C++ library if you have only C functions ? It really complicate things for nothing.

              M Offline
              M Offline
              MNag
              wrote on last edited by
              #8

              @SGaist

              Actually i want to migrate old dll project (big project) to C++ Builder in that they are using above mentioned method soi thought it will be convenient to do the same.

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #9

                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 ?

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                M 1 Reply Last reply
                0
                • SGaistS SGaist

                  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 ?

                  M Offline
                  M Offline
                  MNag
                  wrote on last edited by
                  #10

                  @SGaist

                  Yes, that's Correct.

                  What's wrong with Qt macros?

                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #11

                    You did not use Q_DECL_EXPORT.

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    M 1 Reply Last reply
                    0
                    • SGaistS SGaist

                      You did not use Q_DECL_EXPORT.

                      M Offline
                      M Offline
                      MNag
                      wrote on last edited by
                      #12

                      @SGaist said in Undefined refence to '_imp__FunctionName':

                      Q_DECL_EXPORT.

                      Thought of using the C++ builder macro for exporting since i am exporting in C++ builder and importing in Qt so i used Qt macro for importing.

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved