3

I have come across quite a few similar questions, however I didn't really get my answer.

So, I have an App.exe that depends on Static.lib, which in turn depends on a dynamic library Dynamic.dll. In Static.lib I link to Dynamic.lib import library. I do understand that now the App.exe has to have Dynamic.dll in it's directory in order to run successfully, however when I try to link the code I get an error that the App project can't find Dynamic.lib import library.

My question is, why does the App project have to link to Dynamic.lib import library when it is already linked in Static.lib?

3
  • I work under Linux OS, so what I would do at this point is to point LD_LIBRARY_PATH to the location of my shared lib. under windows I found this msdn.microsoft.com/en-us/library/windows/desktop/… Commented Sep 7, 2014 at 1:39
  • @Kam: My application does find the DLL, however my question was why do I have to have it's import library in both the Static.lib and App project? If it's in Static.lib and App depends on it, shouldn't the Dynamic.lib be linked to App too? Commented Sep 7, 2014 at 1:43
  • Because with Visual Studio static libraries do not link to other libraries. Commented Sep 7, 2014 at 2:48

1 Answer 1

2

My question is, why does the App project have to link to Dynamic.lib import library when it is already linked in Static.lib?

At first, you need to generate your static library, so you compile with the shared library's header files and you link with the shared library.

Then to generate an .exe you compile with the static library's header files; Then you need to link with the shared library because some of the methods found in the static library are implemented in the shared library.

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.