1

I have a library foo.a compiled in MinGW. It should work in Windows, because it's cross-platform library (LibVNCServer). When configure, I used the flags -static and --disable-shared. But when I tried to include foo.a in Visual Studio, I got errors such as these:

unresolved external symbol ___chkstk_ms unresolved external symbol _snprintf unresolved external symbol _jpeg_CreateCompress 

How do I compile a source file in MinGW so that the resulting library file would work in Windows? I just need library with all dependencies included, so I could link it without errors in Visual Studio on Windows. Help, please.

1

1 Answer 1

2

A library is not only platform dependent but also tool set dependent. When you have a library compiled with compiler A you can't assume that it will work with a program compiled with compiler B.

There are differences between compilers like different from functions names.

  • calling conventions
  • heap ownership
  • register saves

Any non-trivial algebra can cause the reference to compiler specific run-time functions for division and so on.

The most secure way to make the static library foo.a available to VS is to compile it from source with VS.

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

1 Comment

And compile it from the same version of Visual Studio. Mixing versions of Visual Studio will cause more than 1 independent heap where you can not allocate memory in the application and free in the dll or viseversa without corrupting one or more of these heaps along with possible CRT incompatibilities. It's not save to pass objects from the standard library either for both the heap and possible different implementation reasons.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.