Search code examples
wt

error compiling hangman example in wt with ubuntu 11.10


>g++ -o hangman hangman.C -lwthttp -lwt -lboost_signals
/tmp/cc5puOIR.o: In function `createApplication(Wt::WEnvironment const&)':
hangman.C:(.text+0x19b): undefined reference to `HangmanGame::HangmanGame(Wt::WContainerWidget*)'
/tmp/cc5puOIR.o: In function `main':
hangman.C:(.text+0x3dc): undefined reference to `Session::configureAuth()'
collect2: ld returned 1 exit status

I also tried this:

>g++ -o hangman hangman.C -I/usr/local/include -L/usr/local/lib -lwthttp -lwt -lboost_random -lboost_regex -lboost_signals -lboost_system -lboost_thread -lboost_filesystem -lboost_program_options -lboost_date_time
/usr/bin/ld: warning: libboost_program_options.so.1.46.1, needed by /usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../../../lib/libwthttp.so, may conflict with libboost_program_options.so.1.49.0
/usr/bin/ld: warning: libboost_system.so.1.46.1, needed by /usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../../../lib/libwthttp.so, may conflict with libboost_system.so.1.49.0
/usr/bin/ld: warning: libboost_thread.so.1.46.1, needed by /usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../../../lib/libwt.so, may conflict with libboost_thread.so.1.49.0
/usr/bin/ld: warning: libboost_regex.so.1.46.1, needed by /usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../../../lib/libwt.so, may conflict with libboost_regex.so.1.49.0
/usr/bin/ld: warning: libboost_signals.so.1.46.1, needed by /usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../../../lib/libwt.so, may conflict with libboost_signals.so.1.49.0
/usr/bin/ld: warning: libboost_date_time.so.1.46.1, needed by /usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../../../lib/libwt.so, may conflict with libboost_date_time.so.1.49.0
/usr/bin/ld: warning: libboost_filesystem.so.1.46.1, needed by /usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../../../lib/libwt.so, may conflict with libboost_filesystem.so.1.49.0
/tmp/ccgojfHq.o: In function `createApplication(Wt::WEnvironment const&)':
hangman.C:(.text+0x19b): undefined reference to `HangmanGame::HangmanGame(Wt::WContainerWidget*)'
/tmp/ccgojfHq.o: In function `main':
hangman.C:(.text+0x3dc): undefined reference to `Session::configureAuth()'
collect2: ld returned 1 exit status

none worked. I have an updated boost 1_49_0 under ubuntu 11.10


Solution

  • hangman is not a single file example; the linker complains on a symbol that is defined in a different source (.C) file. I'm not familiar with the ubuntu install, but I guess it includes a CMakeLists.txt file that properly builds the example. If this assumption is right, you have to use cmake to create a Makefile, and then run make.