LNK2019 & LNK2001 when compiling plugin DLL - Visual Studio 2019

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • Tim.Gadzella
    Junior Member
    • Jan 2021
    • 28

    LNK2019 & LNK2001 when compiling plugin DLL - Visual Studio 2019

    Hi folks, pretty new recruit to FEBio here.

    I'm working on implementing a couple plugins for custom material models in Visual Studio 2019. I've been following along with the dev manual and the suggestions here in the forum but I'm still having trouble getting my plugins to run. Most of what I am doing is heavily dependent on pre-existing code from the NeoHookean plugin and the core code on Github. So far I have:

    - Made sure that the libraries and include folders from the SDK are included in the solution properties for both Debug and Release;
    - Included the WIN32 macro in the preprocessor (just typed it in to the field, which I think does the trick); and
    - Included the FECore and FEBioMech libraries in the Linker input.

    When I try to build my solution, I get the LNK2019 and LNK2001 "unresolved external symbol" errors for some of the pre-existing classes and parameters from the FEBio SDK. I'm at a total loss. Can anyone suggest what I might be missing? I have 30 errors in total, some examples being:

    1>AdaptedVW.obj : error LNK2019: unresolved external symbol "public: void __thiscall FEParamContainer::AddParameter(double &,char const *)" (?AddParameter@FEParamContainer@@QAEXAANPBD@Z) referenced in function "protected: virtual void __thiscall FEAdaptedVW::BuildParamList(void)" (?BuildParamList@FEAdaptedVW@@MAEXXZ)

    or

    1>dllmain.obj : error LNK2001: unresolved external symbol "public: virtual class FEParam * __thiscall FEParamContainer::GetParameter(char const *)" (?GetParameter@FEParamContainer@@UAEPAVFEParam@@PB D@Z)

    Thanks!
  • maas
    Lead Code Developer
    • Nov 2007
    • 3691

    #2
    Hi,

    The libraries in the SDK are built with Visual Studio 2017. I suspect that's why you are running into linker issues.
    I haven't tried VS2019 myself, but I think there is way to build executables or dlls that are compatible with VS2017, so maybe try looking into that. Let me know what you find, or if you don't think that's the issue.

    Cheers,

    Steve
    Department of Bioengineering, University of Utah
    Scientific Computing and Imaging institute, University of Utah

    Comment

    • Tim.Gadzella
      Junior Member
      • Jan 2021
      • 28

      #3
      Hi Steve, thanks for your response.

      I remade the project in VS2017 and it seems like the linker errors have resolved. However, I'm getting the following syntax errors:

      1>dllmain.cpp
      1>w:\febio\include\fecore\fecore_enum.h(34): error C2143: syntax error: missing ';' before 'enum [tag]'
      1>w:\febio\include\fecore\fecore_enum.h(34): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

      I saw in a previous post that this could be caused by missing the precompiled headers and WIN32 macro, which I made sure are included. Thoughts?

      Thanks again!

      Comment

      • maas
        Lead Code Developer
        • Nov 2007
        • 3691

        #4
        Hmm, not sure about this one. Since it's a compiler error, you haven't reached the linker stage, so the linker issues might still be there, although, hopefully not.

        These errors make no sense to me. That location simply defines an enum, so it would not depend on any macros. It is possible that the error is actually caused by the file that includes this file. Are you including this file directly into dllmain?

        Also, are you including <windows.h> anywhere? It might be in a precompiled header, if you are using them.

        Steve

        Department of Bioengineering, University of Utah
        Scientific Computing and Imaging institute, University of Utah

        Comment

        • Tim.Gadzella
          Junior Member
          • Jan 2021
          • 28

          #5
          Hi Steve,

          I'm including <FECore/FECoreKernel> in my dllmain but not that file specifically. I do have <windows.h> in my precompiled headers.

          Thanks!

          Tim

          Comment

          • maas
            Lead Code Developer
            • Nov 2007
            • 3691

            #6
            Hi Tim,

            Try removing the <windows.h> header file and see if that helps.

            Steve
            Department of Bioengineering, University of Utah
            Scientific Computing and Imaging institute, University of Utah

            Comment

            • Tim.Gadzella
              Junior Member
              • Jan 2021
              • 28

              #7
              Hi Steve,

              Still no luck. I haven't really changed anything in the SDK but I can try reinstalling it in case I did something wrong.

              Tim

              Comment

              • maas
                Lead Code Developer
                • Nov 2007
                • 3691

                #8
                If you send me your plugin code, I can try it on my end, and see if I can spot any issues. You may email it to steve dot maas at utah dot edu.

                Thanks,

                Steve
                Department of Bioengineering, University of Utah
                Scientific Computing and Imaging institute, University of Utah

                Comment

                Working...
                X