[CMake] Import library for executables?

Ryan Pavlik rpavlik at iastate.edu
Wed Sep 1 12:39:52 EDT 2010


  On 9/1/10 7:52 AM, Hariharan Iyer wrote:
>  Hello folks,
>
> I'm building an executable called foo.exe (project name foo) and a 
> library called foo.lib (project name libfoo) that the executable 
> depends on. I have an ImportLibrary line for foo.exe which looks like 
> this:
> ImportLibrary="<path>\lib\Debug\foo.lib"
>
> and an OutputFile line for foo.lib that looks like this:
> OutputFile="<path>\lib\Debug\foo.lib"
>
> My build for the executable (foo.exe) fails with the following error:
>
> "LINK : fatal error LNK1149: output filename matches input filename 
> 'foo.lib'"
>
> A few questions:
> 1. I'm not sure if the error is because of the same name, but in any 
> case, it seems to be wrong because one of the two libraries will be 
> overwritten by the other. How do I avoid this (apart from using 
> different names, of course) ?
> 2. Why is an import library required for the executable ? Isn't it 
> only for DLL's?
>
> Regards,
> Hari
Are you using CMake?  I don't recognize the code you post - if you are 
looking for help specifically for a visual studio project, this is not 
the right forum for your question.  In CMake, you'd do it something like 
this:

add_library(libfoo libsource.cpp libsource.h libsource2.cpp)
add_executable(foo foo.cpp foo2.cpp)
target_link_libraries(foo libfoo)

Ryan

-- 
Ryan Pavlik
Human-Computer Interaction Graduate Student
Virtual Reality Applications Center
Iowa State University

http://academic.cleardefinition.com/



More information about the CMake mailing list