4

This is the situation.

I have a library project A that uses and manipulates other third party libraries, we call them T1 and T2.

However when I use this library A in any of my other projects it complains that it cannot open the third party libraries T1 and T2 even though it does not directly uses them. Ofcourse it indirectly uses them through library A because A did the appropriate work to link and include against that library etc.

Do I really need to add these other libraries to the projects that use library A or is there a way to lets say concatenate libraries such that the user of library A only ever needs to worry about that one instead of what its made of.

Edit:

Found some related questions but the answers do not quite solve the issue;

linking-static-libraries-to-other-static-libraries

how-to-combine-several-c-c-libraries-into-one

Edit2:

Thanks for the answers so far. Let me clearify my situation.

I have a .lib project in VS2015 which we call MathLib. This MathLib uses lets say a boost library internally to do its calculations, lets call this library BoostMath. The property files are all set to include and use this BoostMath and this works perfectly in the library project itself.

I am now making another project User that uses the MathLib to do its calculations. It does the appropriate includes and all to use this library. However it complains about the fact that it does not know the BoostMath library and thus cannot work with the MathLib library.

One could argue why not just include BoostMath into project User in the same manner that the MathLib library did this, but that is missing the point. I want to create a library of my own that may or may not use other libraries internally but this should not be of any concern to the end user of my library.

I probably have to set something in VS Librarian to make this happen, concatenate the libs together or some. But I cannot seem to figure it out. Any thoughts?

Edit3: I even found the exact same commandline in the property files as mentioned in this answer.

/OUT:"MathLib.lib" "BoostMath.lib" /NOLOGO /LIBPATH:"path\lib" 

However it does not work for some reason. If I run it with and without the Librian property setting, the .lib binary stays the same.

Appearantly this functionality is broken since VS2010? According to this answer. Usefull other question. Edit4:

I basically want to do this, but it does not seem to work in VS2015

+---------------+ | End user exe | +---------------+ | | some api call | +---------------+ | My MathLib | +---------------+ | | +---------------+------------+---- | | | +-----+------+ +-----+-----+ | BoostMath | | OtherMath | +------------+ +-----------+ 
1
  • 2
    If this answer at the question you linked to doesn't answer your question you'll have to clarify your question as to why not. Commented May 6, 2016 at 15:46

2 Answers 2

1

I am not sure how you link the library to the project...but it should not complain the compiler could not open the library T1 and T2 unless you have included those in the compiler setting.

Normally if you don't have the library, it will report could not find the function example T1_xxxx (this function is defined in T1). I would suggest you check the compiler setting of the project

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

2 Comments

Reading between the lines, the complaint that "it cannot open the third party libraries" probably is by reporting that it can't find methods in them. But the OP should clarify this.
The thing is I am using VS2015. If I follow what is specified in the answers, setting the librarian setting in VS, it just does not work.
1

Basically static libraries do not undergo linkage, and in particular static libraries have no way to specify their own dependencies. You can partially hack around this by spreading #pragma comment(lib)'s around individual obj files (i.e., individual source files), but not at the library level - and it seems you don't intend to modify the lib sources anyway.

Your best option seems to be combining the lib along with its dependencies into a single lib, as specified e.g. here:

lib.exe /OUT:compositelib.lib lib1.lib lib2.lib

Note that you'd have to re-package whenever any of the dependencies change. I myself, as a user, would prefer to include all the referenced libs in my consumer solution.

3 Comments

Turns out that this used to be in the GUI of previous versions of VS but the removed it from 2010 onwards..
You mention that you would prefer to include all the referenced libs in your consumer solution. But that means that you have to put all the dependencies everywhere, instead of having them in one place and just reference that. I mean that creates many possible points of failure, and way more maintenance issues doesnt it
@Montaldo it essentially amounts to the expected number of 'consumers' vs the estimated number of library updates. More accurately, the estimated growth in the number of consumers (since setting up the dependencies in a consumer is a one-time task), and personally I find it rarely exceeds the rate at which the dependent library itself changes.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.