Can only build by running cmake again after make

Bug #856878 reported by Jon Nordby
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Smoke-GObject
Fix Released
Undecided
Unassigned

Bug Description

Steps to reproduce:
1. Get a fresh checkout of smoke-gobject
2. cmake .
3. make

Expected outcome:
make succeeds

Actual outcome:
make fails with errors during linking of tests/helloworld/helloworld

Linking CXX executable helloworld
CMakeFiles/helloworld.dir/main.cpp.o: In function `main':
main.cpp:(.text+0x4c): undefined reference to `Gtk::Window::Window(Gtk::WindowType)'
main.cpp:(.text+0x61): undefined reference to `Gtk::Container::setBorderWidth(unsigned int)'
main.cpp:(.text+0xe4): undefined reference to `Gtk::Button::createWithLabel(QString)'
main.cpp:(.text+0x16d): undefined reference to `Gtk::Container::add(Gtk::Widget*)'
main.cpp:(.text+0x179): undefined reference to `Gtk::Widget::show()'
main.cpp:(.text+0x185): undefined reference to `Gtk::Widget::show()'
collect2: ld returned 1 exit status
make[2]: *** [tests/helloworld/helloworld] Error 1

Running cmake and then make again after this causes make to succeed.

Revision history for this message
Jon Nordby (jonnor) wrote :

This is caused by the use of FILE( GLOB ) for finding the sources for modules libraries.
in modules/gtk/CMakeLists.txt: "FILE(GLOB GTK_CPP "${CMAKE_CURRENT_BINARY_DIR}/*.cpp")"

This glob is only evaluated at cmake time, and in the case of a clean build tree the generated sources does not exist. Consequently they are not compiled or linked into the library, and the majority of symbols are missing. This affects all the modules.

I could not find any way to tell cmake to use a glob that is evaluated at make time.

Other ideas on how to fix the issue:
- Run the gsmoke generator at cmake time with a flag to create the list of files that will be generated, and should be compiled into the library.
This requires the generator to be built before cmake happens in the modules. This can either be accomplished by separating out the modules into a separate repository, or by creating a make target that runs cmake and then make inside the modules.

  Let the generator output the names of the files that will be generated

Revision history for this message
Richard Dale (rdale) wrote :

Yes, I did try and fix the GLOB with something similar, but couldn't work out how to do it. So adding some build instructions to the README as described above might be the best work round for now.

Another problem was that we found that all the sources for the modules we being regenerated if you just changed 'gsmokegen', so we changed the build so that the sources for a module would only be regenerated if you did a 'make clean' in its build directory.

Revision history for this message
Jon Nordby (jonnor) wrote :
Revision history for this message
Jon Nordby (jonnor) wrote :

Above fix solves a lot of the issue, however cross-module dependencies are not handled correctly:
- building with -j2+ will cause failures due to cmake trying to build several modules in parallel that are interdependent
- incomplete linking of dependent libraries into smokegtk causes modules/tests/helloworld to fail to build

Dependency information can be found in the .gir files (but is sadly not always complete or correct :( ), so ideally the compiler should also be able to tell use about this at cmake time. If that turns out to be too much effort I'll just manually specify the dependencies in our build files.

Revision history for this message
Jon Nordby (jonnor) wrote :

I now pushed revision 173, which should have fixed the issue completely:
http://bazaar.launchpad.net/~smoke-gobject-devs/smoke-gobject/trunk/revision/173

Changed in smoke-gobject:
status: New → Fix Committed
status: Fix Committed → In Progress
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.