0

I have an application that has been worked on for several decades and I was provided .h and .a files. My program is mainly in C/C++ and when I try to link to these .a files, I get:

Error LINK2019: unresolved external symbol referenced un function
Fatal error LINK1136: invalid or corrupt file.

I'm using Visual Studio 2022 on Windows.

All my other static library files are .libs, but this is an .a file. Is there a way to link to .a static library files?

My .vcxproj files looks like this:

<Link>
    <AdditionalDependancies>...;NewLibrary.a;$(AdditionalDependancies)</AdditionalDependancies>
    ....
</Link>

This is my .props file:

<AdditionalIncludeDirectories>...$(THIRDPARTYLIB)/NewLibraries</AdditionalIncludeDirectories>
<AdditionalLibraryDirectories>...$(THIRDPARTYLIB)/NewLibraries</AdditionalLibraryDirectories>
1
  • 1
    It depends on how that .a file was compiled. .a static libraries are typically the format that linux or MinGW libraries will come in, so there's pretty low chance that the Microsoft C++ compiler will support the .a file. Commented Sep 4, 2024 at 15:20

1 Answer 1

-1

Is your .a file compatible with VS Code tools? If so you can convert it into .lib file by going to the directory where the lib file was and running the below command:

lib /def:NewLibrary.a /out:NewLibrary.lib

If the project is not too long or made completely by you, you can make a .def file that describes the exported functions for that file and then create a .lib file with it.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.