[CMake] Compiling header files

David Cole david.cole at kitware.com
Tue Nov 16 14:12:23 EST 2010


If you have "unresolved external" errors, then you are (most likely)
missing a target_link_libraries call -- find out what library those
symbols are built into, and link to that library.


On Tue, Nov 16, 2010 at 2:03 PM, David Doria <daviddoria at gmail.com> wrote:
> I am trying to use ADD_LIBRARY to create a .lib file from a collection
> of .cpp and .h files.
>
> If I do:
> ADD_LIBRARY(LibraryName AllOfTheCPPFiles.cpp)
>
> and then try to link against that library, I get many missing-function
> type linker errors. I looked in the .h files and many of them have
> actual function definitions:
>
> (an example):
> class UdpTransmitSocket : public UdpSocket{
> public:
>        UdpTransmitSocket( const IpEndpointName& remoteEndpoint )
>                { Connect( remoteEndpoint ); }
> };
>
> I tried to tell CMake to compile the .h files into the library as well
> by doing this:
>
> set(CMAKE_CXX_SOURCE_FILE_EXTENSIONS ${CMAKE_CXX_SOURCE_FILE_EXTENSIONS} h)
> ADD_LIBRARY(LibraryName AllOfTheCPPFiles.cpp  AllOfTheHFiles.h)
>
> but it didn't seem to change anything. Is there a way this is typically handled?
>
> Thanks,
>
> David
> _______________________________________________
> 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
>


More information about the CMake mailing list