[CMake] mixed C/C++ link errors on Solaris

j s j.s4403 at gmail.com
Mon Jun 28 22:43:00 EDT 2010


Not familiar with your compiler, but a c++ "main" should be used to ensure
all c++ static global objects are initialized properly. gcc does a good job
at hiding this.

Juan

On Jun 28, 2010 6:46 PM, "Matthew Woehlke" <mw_triad at users.sourceforge.net>
wrote:

I have a library 'bar' that is C++, but exports a C API. So, say, I have
this CMakeLists.txt:

add_library(bar bar.cpp)
add_executable(foo foo.c)
target_link_libraries(foo bar)

On most platforms this is fine, but on Solaris it can't link due to
unresolved externals.

I can work around this by either a) linking foo as C++, or b) forcing bar to
link to libCrun and libCstd. The first is obviously undesirable because it
should be an implementation detail that bar uses C++; users of the library
should not need to care.

Has anyone run into this before? In particular, does anyone know of a nice,
neat, canned solution for grabbing libCrun and libCstd in CMake? (Or is this
a case to use 'target_link_libraries(bar -lCrun -lCstd)' instead of
'find_library(Cstd ...)', etc.?)

-- 
Matthew
Please do not quote my e-mail address unobfuscated in message bodies.
-- 
Now I lay me back to sleep.
The speaker's dull; the subject's deep.
If he should stop before I wake,
Give me a nudge for goodness' sake.
               -- Anonymous

_______________________________________________
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20100628/5076a2f3/attachment.htm>


More information about the CMake mailing list