[CMake] unable to include a source file for all sub directories

David.Karr at L-3COM.COM David.Karr at L-3COM.COM
Fri May 15 10:26:28 EDT 2009


ankit jain <ankitguddu at gmail.com> wrote:

> My source tree structure is:
> Main_folder
>.. Ident.c
>..folder1
>........f11.c
>........f12.c
> [...]
>
> Now I am able to get all the source files from all the folders. but
the
> problem is that all folder source files uses one variable v1 of this
Ident.c
> file..
>
> So the error iam getting while building the library is :
> unresolved external symbol: v1  (iam working on windows VC++)

I suggest the following exercise: use VC++ to create a very simple
workspace/"solution" with just one VC++ "project" in it that builds a
library.  Add Ident.c and just a few of your other files (maybe just
f11.c) to this project.  Then try to build this project.

Now either one of two things will happen:

1. You will get the same link errors as before.  Then you know your
problem is that you have incorrect C++ code; CMake did not cause the
problem and cannot solve it.  You might then try asking a C/C++ forum
what is wrong, but before you do that you should delete as much code
from Ident.c and f11.c as possible while making sure you still get the
same error when you try to build the code.  Then you can post the
complete contents of these files when asking your question.  (You will
probably not get an answer if you don't post code, or if you post more
than a couple of pages of code.  Many people are willing to help, but
not if they have to do a lot of work that you could have done yourself.)

2. You will not get the same link errors.  Then you may be able to find
some difference in the settings of the projects (between the project
created by CMake and the one you created directly in VC++) that explains
why there is an error only in the CMake project.

I have a very strong hunch you will get the first result.

David A. Karr



More information about the CMake mailing list