Re: [CMake] how to write a cmakelist to call a function in another c or cxx file

2010-01-17 Thread Yixun Liu
It works. Thank you very much! Hendrik Sattler wrote: > Am Samstag 16 Januar 2010 19:21:42 schrieb Yixun Liu: > >> I do add test.c (see previous email). >> If I change test.c to test.cxx, it works. I do not know why. >> > > Hint: C++ name mangling. > > Add a test.h: > extern "C" { > void

Re: [CMake] how to write a cmakelist to call a function in another c or cxx file

2010-01-16 Thread Hendrik Sattler
Am Samstag 16 Januar 2010 19:21:42 schrieb Yixun Liu: > I do add test.c (see previous email). > If I change test.c to test.cxx, it works. I do not know why. Hint: C++ name mangling. Add a test.h: extern "C" { void func(); } and include it in your main.cxx file. Alternatively, set the LANGUAGE

Re: [CMake] how to write a cmakelist to call a function in another c or cxx file

2010-01-16 Thread Stephan Menzel
I guess it would be a C linkage problem then. Have you got extern "C" {} around the exported symbols? Cheers, Stephan On Sat, Jan 16, 2010 at 7:21 PM, Yixun Liu wrote: > I do add test.c (see previous email). > If I change test.c to test.cxx, it works. I do not know why. > __

Re: [CMake] how to write a cmakelist to call a function in another c or cxx file

2010-01-16 Thread Yixun Liu
I do add test.c (see previous email). If I change test.c to test.cxx, it works. I do not know why. Hendrik Sattler wrote: > Am Samstag 16 Januar 2010 15:40:55 schrieb Yixun Liu: > >> ADD_EXECUTABLE(main main.cxx ) >> >> TARGET_LINK_LIBRARIES(main ITKCommon ITKIO vtkCommon vtkIO ) >> >> It work

Re: [CMake] how to write a cmakelist to call a function in another c or cxx file

2010-01-16 Thread Hendrik Sattler
Am Samstag 16 Januar 2010 15:40:55 schrieb Yixun Liu: > ADD_EXECUTABLE(main main.cxx ) > > TARGET_LINK_LIBRARIES(main ITKCommon ITKIO vtkCommon vtkIO ) > > It works well. > Now I need to ,in main.cxx, invoke a function, let's say func(), > defined in another c file, let's say test.c. You need

Re: [CMake] how to write a cmakelist to call a function in another c or cxx file

2010-01-16 Thread C. Meissa
Hello Liu, > However, after ccmake and then make, I got the error: > main.cxx:(.text+0x10a): undefined reference to `func()' > collect2: ld returned 1 exit status Can you put SET (CMAKE_VERBOSE_MAKEFILE TRUE) to your CMakeLists.txt to check what compiler command is run? bye C.M.

[CMake] how to write a cmakelist to call a function in another c or cxx file

2010-01-16 Thread Yixun Liu
Hi, I am not familiar with writing CMakelist. I have a simple cmakelist file as following. # This project is designed to be built outside the Insight source tree. PROJECT(main) # Find ITK. FIND_PACKAGE(ITK REQUIRED) IF(ITK_FOUND) INCLUDE(${ITK_USE_FILE}) ENDIF(ITK_FOUND) FIND_PACKAGE(VTK REQUI