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

ankit jain ankitguddu at gmail.com
Fri May 15 06:57:54 EDT 2009


2009/5/15 Hendrik Sattler <post at hendrik-sattler.de>

> Zitat von ankit jain <ankitguddu at gmail.com>:
>
>> Linker error for many objects files that have created
>>
>
> So either the object file that contains the symbol is not part of your link
> command or you have a coding error.
> Since you release neither an example nor further information, you will
> probably not get any other answer.
>
> HS
>
Eg:

main
...Ident.c
....folder1
.......f11.c
.......f12.c
...folder2
......f21.c
......f22.c

Now if this Ident.c is there in each folder1 and folder2 then it works
well.. but since it is outside folder1 and fodler2 so while linking neither
f11 f12 f21 f22 will be able to link Ident.c

iam making library main as:
...CMakeLists of main folder.

foreach(fname ${folder1_srcs})
list(APPEND main_srcs folder1/${fname})
endforeach(fname)

foreach(fname ${folder2_srcs})
list(APPEND main_srcs folder2/${fname})
endforeach(fname)

list(APPEND main_srcs Ident.c)
add_library(main SHARED ${main_srcs})


CMakelist of folder1...

set(folder1_srcs f11.c f12.c)
set(folder1_srcs ${folder1_srcs} PARENT_SCOPE)

CMakelist of folder2...

set(folder2_srcs f21.c f22.c)
set(folder2_srcs ${folder2_srcs} PARENT_SCOPE)

Now all files iam getting from folder1 and folder2 and objects of all files
including Ident.c is created... But while linking f11.obj f12.obj f21.obj
f22.obj all show error undefined symbol:
char *v1

where Ident .c contains..

char v1[]="Hello";


I this example give you idea what iam trying to do...

Ankit
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090515/aefc6016/attachment.htm>


More information about the CMake mailing list