[CMake] Linking object file with executable

ankit jain ankitguddu at gmail.com
Tue May 19 08:08:15 EDT 2009


Hi all,

My Cmakelists contains:

set(myobj  ${CMAKE_CURRENT_SOURCE_DIR}/../objfolder/myfile.obj)
add_executable(myexe  main.c ${myobj})

This myfile.obj object file is generated while building objfolder before
creating this executable

Now on building this executable i got a warning:

main.obj: warning: earlier declaration of a function f1() found in
myfile.obj: second definition ignored..

This means it is taking the f1() function from myfile.obj but i want f1()
function to be taken from main.obj..

What to do?

Also it is imp. to link this myfile.obj file to myexe  executable since it
depends on other functions of this object file..
So this object file has to be there.
Just tell me how function f1() can be taken from main.c rahter than from
myfile.obj evenif it still gives warning as:

myfile.obj:warning: earlier definition of function f1() found in main.c
(since if it takes f1() from main.c): second def. ignored

Regards-
Ankit Jain
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090519/64c7c58d/attachment-0001.htm>


More information about the CMake mailing list