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

Matthew Woehlke mw_triad at users.sourceforge.net
Mon Jun 28 19:45:53 EDT 2010


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



More information about the CMake mailing list