<br><br><div class="gmail_quote">2009/5/15 <span dir="ltr"><<a href="mailto:David.Karr@l-3com.com">David.Karr@l-3com.com</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im">ankit jain <<a href="mailto:ankitguddu@gmail.com">ankitguddu@gmail.com</a>> wrote:<br>
<br>
> My source tree structure is:<br>
> Main_folder<br>
</div>>.. Ident.c<br>
<div class="im">>..folder1<br>
>........f11.c<br>
>........f12.c<br>
</div>> [...]<br>
<div class="im">><br>
> Now I am able to get all the source files from all the folders. but<br>
the<br>
> problem is that all folder source files uses one variable v1 of this<br>
Ident.c<br>
> file..<br>
><br>
> So the error iam getting while building the library is :<br>
> unresolved external symbol: v1 (iam working on windows VC++)<br>
<br>
</div>I suggest the following exercise: use VC++ to create a very simple<br>
workspace/"solution" with just one VC++ "project" in it that builds a<br>
library. Add Ident.c and just a few of your other files (maybe just<br>
f11.c) to this project. Then try to build this project.<br>
<br>
Now either one of two things will happen:<br>
<br>
1. You will get the same link errors as before. Then you know your<br>
problem is that you have incorrect C++ code; CMake did not cause the<br>
problem and cannot solve it. You might then try asking a C/C++ forum<br>
what is wrong, but before you do that you should delete as much code<br>
from Ident.c and f11.c as possible while making sure you still get the<br>
same error when you try to build the code. Then you can post the<br>
complete contents of these files when asking your question. (You will<br>
probably not get an answer if you don't post code, or if you post more<br>
than a couple of pages of code. Many people are willing to help, but<br>
not if they have to do a lot of work that you could have done yourself.)<br>
<br>
2. You will not get the same link errors. Then you may be able to find<br>
some difference in the settings of the projects (between the project<br>
created by CMake and the one you created directly in VC++) that explains<br>
why there is an error only in the CMake project.<br>
<br>
I have a very strong hunch you will get the first result.<br>
<br>
David A. Karr<br>
</blockquote><div><br>Thanks for the suggestion David but ht eproblem is still there. i will give you the content of two files with the tree structure. i request you to do the same for me on your machine and see whether it gives error or not..<br>
<br>mainfolder<br>...Ident.c<br>...subfolder<br>.........file.c<br><br>Ident.c contain:<br><br>int number=10;<br>char array[]="hello";<br><br>subfolder/file.c contains:<br><br>#some header files<br>extern int number;<br>
print("iam in sub folder");<br><br>Now cmakelists of mainfolder is:<br><br>Project (mainfolder)<br><br>foreach(fname ${subfolder_srcs})<br>list(APPEND mainfolder_srcs subfodler/${fname})<br>endforeach(fname)<br>
<br>list(APPEND mainfolder_srcs Ident.c)<br>add_library(mylib SHARED ${mainfolder_srcs})<br><br><br>CMakelist of subfolder..<br><br>set(subfolder _srcs file.c)<br>set(subfodler_srcs ${subfolder_srcs} PARENT_SCOPE)<br><br>
Thats it..<br><br>Compiling is ok .. Ident.obj and file.obj created..<br>But when it creating mylib library in linking it says:<br>file.obj : unresolved external symbol: int number <br><br>if the tree structure is like this:<br>
mainfolder<br>....Ident.c<br>....file.c<br><br>Means no subfolder direct file in mainfolder. then there is no problem in creating the library.<br>Because of accessing file from subfolder it creates problem..<br><br>Also if in VC++ if i give addtional option in compilation as /FI"filepath to Ident.c"<br>
Then it works..<br>because file.c is compiled with Ident.c<br>so it works but i dont want to give this flag in compiler option...<br><br>Why it is not taking directly...<br><br>I hope i make my question very clear...<br><br>
Regards-<br>Ankit Jain..<br><br><br><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank">http://www.cmake.org/mailman/listinfo/cmake</a><br>
</blockquote></div><br>