1
>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

我也试过这个:

>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

没有工作。我在 ubuntu 11.10 下有一个更新的 boost 1_49_0

4

2 回答 2

1

hangman 不是单个文件示例;链接器抱怨在不同的源 (.C) 文件中定义的符号。我不熟悉 ubuntu 安装,但我猜它包含一个正确构建示例的 CMakeLists.txt 文件。如果这个假设是正确的,你必须使用 cmake 创建一个 Makefile,然后运行 ​​make。

于 2012-08-14T16:45:22.043 回答
1

正如 user52875 所写,您需要从 Auth 模块编译 Session.cpp,或链接 Session.o,可能还有 Hangmangame.cpp。

于 2015-03-15T21:29:46.637 回答