An unresolved external symbol from a static library in one project, and not another. (C ++)

I have a static library that compiles fine (lets call it A), and it depends on another static library (lets call it B).

I also have a project X that uses library A. So, in X, I turn on B and then, below, turn on A, as in stdafx.h. I do this with #pragma comments. Project X compiles fine.

However, then I have a project Y, which also uses the library A. But, although the project Y stdafx.h is IDENTICAL for X, Y does not compile, giving errors of "unresolved external characters". Even stranger, the errors relate to the function in library B from the function specified in library A.

Does anyone know why this is happening? Sorry if I was not clear; there is so much code, I would not know where to start it here. Thank!

+3
source share
2 answers

I am going to assume that you are using MSVS based on the stdafx.h header. When you enable static libraries, you need to not only include the necessary header files, but you must reference the static library file, that is, the .lib file. I assume that project X has access to this .lib file, while project Y does not work.

Perhaps through properties-> general properties-> Links, and then β€œadd a new link” to point to both libraries.

Y, Project X, A, B ? , Y, . , , , . ( ) MSVS. , , . ( , "properties- > common properties- > References" ..).

.lib , "properties- > Configuration Properties- > Linker- > Input- > Additional dependencies" , "properties- > - > Linker- > General- > "

,

+4

lib, , .

*.c *.h . ( , ) ...

, , , , googled, .

0

All Articles