Olaf,

Unless your code snippets are incomplete, I'm missing the following
statement in ./source/eea/ui/CMakeLists.txt

    target_link_libraries(eea_ui_lib
        eea_ui_schematic_lib)

I'm not sure this is causing the link error, but it's worth a try.

Furthermore, I think the order of add_subdirectory(), add_library(), and
target_link_libraries() is important. You might want to check those as well.

Cheers,
Marcel Loose.

On 21/08/14 13:29, Olaf Peter wrote:
> no idea here? It's seems to be a C++ problem, but how to solve it.
> Changing the order of
>
>  target_link_libraries(eea
>       eea_ui_schematic_lib
>       eea_ui_lib
>
> to
>
>  target_link_libraries(eea
>       eea_ui_lib
>       eea_ui_schematic_lib
>
> makes it even worser - more unresolved symbols. So what happens here?
>
>> for my project I have the following structure in my project directory:
>>
>> ./CMakeLists.txt
>> ./source/CMakeLists.txt
>> ./source/eea/CMakeLists.txt
>> ./source/eea/ui/CMakeLists.txt
>> ./source/eea/ui/schematic/CMakeLists.txt
>>
>> with
>> ---8<---
>> ./CMakeLists.txt:
>> project(eea)
>> ...
>>
>> ---8<---
>> ./source/CMakeLists.txt:
>> add_subdirectory(eea)
>> ...
>>
>> ---8<---
>> ./source/eea/CMakeLists.txt
>> add_executable(eea ...)
>>
>> target_link_libraries(eea
>>      eea_ui_schematic_lib
>>      eea_ui_lib
>>      ...
>> )
>>
>> qt5_use_modules(eea Widgets ...)
>>
>> add_subdirectory(ui)
>> ...
>>
>> ---8<---
>> ./source/eea/ui/CMakeLists.txt
>> project(eea_ui)
>> ...
>> set(eea_ui_SOURCE mainwindow_private.cpp graphics_view.cpp...)
>> add_library(eea_ui_lib STATIC
>>      ${eea_ui_SOURCE}
>>      ...
>> )
>>
>> qt5_use_modules(eea_ui_lib Widgets ...)
>>
>> add_subdirectory(schematic)
>> ...
>> ---8<---
>> ./source/eea/ui/schematic/CMakeLists.txt:
>> project(eea_ui_schematic)
>> ...
>> set(eea_ui_schematic_SOURCE schematics_view.cpp ...)
>> add_library(eea_ui_schematic_lib STATIC
>>      ${eea_ui_schematic_SOURCE}
>>      ...
>> )
>>
>> qt5_use_modules(eea_ui_schematic_lib Widgets ...)
>>
>> So far, so good - all compiles.
>>
>>
>>
>> With
>> ---8<---
>> ./source/eea/ui/mainwindow_private.cpp :
>> ...
>> createWindows() {
>>      SchematicView* schematicView = new SchematicView(q);
>>      ...
>> }
>>
>> ---8<---
>> ./source/eea/ui/graphics_view.cpp:
>> GraphicsView::GraphicsView(QWidget* parent) { ...  }
>>
>> ---8<---
>> ./source/eea/ui/schematic/schematic_view.cpp
>> class SchematicView
>> : public GraphicsView
>> { .... }
>>
>>
>> I got the linker error:
>>
>> ../../lib/libeea_ui_lib.a(mainwindow_private.cpp.o): In function
>> `eea::ui::MainWindowPrivate::createWindows()':
>> mainwindow_private.cpp:(.text+0xbb): warning: undefined reference to
>> `eea::ui::SchematicView::SchematicView(QWidget*)'
>>
>> So, what happened here and how to solve it? Before the contents of
>> ui/schematic moved into the ui directory/project and I've got no errors.
>>
>> Thanks,
>> Olaf
>

<<attachment: loose.vcf>>

-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Reply via email to