This is the mail archive of the ecos-discuss@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Building and linking Static library with the eCos executable.


On Thursday 26 June 2008, jawad rehman wrote:
> Hi there,
>
> I have a problem in to add a static library with an application
> executable for eCos. Actually I have two projects and have made three
> cmake files for both the project. One is to include the sub folders
> for the projects and second  is for the project to create a static
> library by using cmake add_library statement and third cmake file is
> for the other project to build the executable for the eCos where I am
> link the the static library but I got the following errors;
>
> Linking CXX executable helloDemo.elf
> CMakeFiles/helloDemo.dir/demo.o: In function `main':
> CMakeFiles/helloDemo.dir/demo.o(.text+0x19): undefined reference to
> `Hello::Print()'
> collect2: ld returned 1 exit status
> make[2]: *** [Demo/helloDemo.elf] Error 1
> make[1]: *** [Demo/CMakeFiles/helloDemo.dir/all] Error 2
> make: *** [all] Error 2
>
> I think the eCos "USEECOS" include does not support the add_library
> statement. Is  there any way to create a static libray for the eCos
> executable or some thing like add_library .
>
> Following are the list files.
>
> 1)      CMakeList.txt in the root folder which include sub folders for the
> build.
>
> project (HELLO)
> add_subdirectory (Hello)
> add_subdirectory (Demo)
>
> 2). CMakeList.txt in the hello project to build a static library.
> add_library (Hello hello.cxx)
>
> 3.  CMakeList.txt in the demo project to build an eCos executable .

This CMakeLists.txt is basically correct. The problem is that you build only 
the executable for eCos, the library is built for the build host. 
So I would suggest to put the following three lines after the project() 
command in the top level CMakeLists.txt.

> include(UseEcos)
> ECOS_ADD_INCLUDE_DIRECTORIES()
> ECOS_USE_I386_ELF_TOOLS()

> include_directories (${HELLO_SOURCE_DIR}/Hello)
> link_directories (${HELLO_BINARY_DIR}/Hello)

You don't need this line, this is only when you use the "complex" directory 
layout as described in http://www.linuxdevices.com/articles/AT6762290643.html
> ECOS_ADJUST_DIRECTORY(target_SRCS ${SRC_LIST})

> ECOS_ADD_EXECUTABLE(helloDemo demo.cxx demo_b.cxx)
> target_link_libraries (helloDemo Hello)
>
> Please provide some advise, it would really be appreciated.

If these hints don't help, please let me know. 
In that case please do 
"make clean; make VERBOSE=1" and post the output, so I can see what's 
happening.

Alex

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]