The Cray system requires static libraries, so all symbols are defined during 
the linking process. 

Leaving out the LINKER_LANGUAGE CXX statement, CMake sees all the source files 
as C files, uses the C linker and I get undefined symbol errors. Manually 
linking with the C++ linker but excluding the -lstdc++ flag generates an 
executable.

I really just need CMake to use the C++ linker without adding that flag.

Thanks,

Lucas Pettey, PhD
HPCMP PETTT EQM CTA Lead
ERDC-DSRC OnSite
Vicksburg, MS
512-297-9833 Mobile (preferred)
601-634-2980 Office
lucas.pet...@engilitycorp.com

________________________________________
From: Dan Liew [d...@su-root.co.uk]
Sent: Friday, May 22, 2015 7:19 AM
To: Pettey, Lucas @ EngilityCorp
Cc: cmake@cmake.org
Subject: Re: [CMake] (no subject)

Hi,

On 21 May 2015 at 23:00,  <lucas.pet...@engilitycorp.com> wrote:
> Hello,
>
> I am trying to compile a code written in C, but using an external library
> that contains C++ functions. I am on a Cray system and everything works if I
> manually link with the cray CC wrapper. When I change the linker language
> with this command:
>
> set_property(TARGET adh PROPERTY LINKER_LANGUAGE CXX)
>
> CMake is using the CC wrapper, but adding -lstdc++ to the link line. This
> causes an error. Can anyone tell me how to not get this added library?

Why are you telling CMake that the linker language is C++ in the
target you are building is C code? The C code you are compiling be
must calling into extern "C" functions in the external library you
mention which means the linker (at compile time) should not need to
know about C++ at all. At runtime the linker needs to know that your
external library depends on C++ but you don't need to be concerned
with this because when your external library was built those
dependencies end up in the shared library.

E.g.

```
$ readelf -d /usr/lib/libboost_program_options.so
...
  Tag        Type                         Name/Value
...
0x0000000000000001 (NEEDED)             Shared library: [libstdc++.so.6]
...
```

Does your target build if you just leave  LINKER_LANGUAGE alone (i.e.
set C)? I would expect that it would.

Thanks,
Dan.
-- 

Powered by www.kitware.com

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

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

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

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Reply via email to