[CMake] Undefined reference

Raphael Kubo da Costa rakuco at FreeBSD.org
Thu Nov 3 10:19:54 EDT 2011


Mauricio Klein
<mauricio.klein.msk at gmail.com> writes:

> I can compile all my codes without problems, but in the linkage step, i
> receive a lot of errors about undefined reference to OpenSSL functions
> (yes, my code uses OpenSSL).
>
> In my own (and ugly :P) Makefile, i use "-lssl" flag in g++ compile line.
>
> My question is: how can i pass this flag in CMake.
> Also, i'm not sure if i'm using CMake correctly. Is correctly use "-lssl"
> flag in CMake or i need to copy the library to a folder inside my project
> and link to this copy?

You need to find OpenSSL with `find_package(OpenSSL)' and then, assuming
it is found (ie. OPENSSL_FOUND is true), link to its libraries with
`target_link_libraries(YOUR_APP ${OPENSSL_LIBRARIES})'.



More information about the CMake mailing list