[CMake] adding a link directory
Liam Kurmos
quantum.leaf at gmail.com
Sun May 8 13:16:22 EDT 2011
that finally solve my problem! i needed to put extern "C" {} around my
include (not something i knew about). thanks to all who helped!
Liam
On Sun, May 8, 2011 at 5:59 PM, Liam Kurmos <quantum.leaf at gmail.com> wrote:
>> I made a separate exe to test this and it linked with
>> TARGET_LINK_LIBRARIES so this problem is not a cmake one. Something
>> must me different in the too code contexts... if checked the obvious
>> includes etc but atleast i know this is not cmake that is not linking.
>>
>
> actually i withdraw this. an undefined reference can only mean it's
> isnt linking properly... So now my questions is why would one
> executable link fine and not another?
>
> i have:
>
> ADD_EXECUTABLE(main main.cpp Data.cpp Mesh.cpp)
>
> FIND_LIBRARY(TOURTRE_LIBRARY tourtre .)
> TARGET_LINK_LIBRARIES(main ${TOURTRE_LIBRARY})
>
> but essentially the same code in a difference exec gives an undefined
> reference?
>
> ADD_EXECUTABLE(testOVAS testOVAS.cpp Analyser4D.cpp
> abstractFeature.cpp Feature.cpp ImplicitVolume4D.cpp
> Analyser3D.cpp GeoPoint.cpp StepToParamConverter.cpp ...etc.. Data.cpp Mesh.cpp
> )
> TARGET_LINK_LIBRARIES(testOVAS vtkWidgets vtkRendering vtkHybrid vnl
> ${TOURTRE_LIBRARY})
>
> the only difference in the code is the bit that uses the library:
>
> ctContext * ctx = ct_init(
> data.totalSize, //numVertices
> &(totalOrder.front()), //totalOrder. Take the address of the front
> of an stl vector, which is the same as a C array
> &value,
> &neighbors,
> &mesh //data for callbacks. The global functions less, value and
> neighbors are just wrappers which call mesh->getNeighbors, etc
> );
>
> in one case this is just in the main function of main.cpp whereas in
> the other exec if is inside a class function.
>
> from header:
> ctContext * ct_init(
> size_t numVertices,
> size_t *totalOrder,
> double (*value)( size_t v, void* ),
> size_t (*neighbors)( size_t v, size_t* nbrs, void* ),
> void* data
> );
>
>
> The 2 callbacks are just local functions in both cases.
>
> is there something wrong with the coding approach? I thought this
> could be a code error but then i thought i should get some incorrect
> type compile error in that case...
>
>
> Liam
>
More information about the CMake
mailing list