How do I link a *.a file that doesn't start with "lib" to an executable?  For example, if I have a library named foo.a with a function called getnum, how do I link to foo.a in CMakeLists.txt?

If my executable file is
---main.cpp---
extern int getnum();
int main(int, char**)    { cout << getnum() << endl;}
----------------
and my CMakeFile is
---CMakeLists.txt---
PROJECT(TESTPROJECT)
ADD_EXECUTABLE(test main.cpp foo.a)
-----------------------
I'll get an error about an undefined reference to getnum when I run the makefile.

If I use TARGET_LINK_LIBRARIES(test foo), I'll get an error about not begin able to find the library, since it's using the -l flag for the linker.  I'd rather not have to rename foo.a, because it will affect other existing software.

Thanks,
-Ed
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to