Support #1486
closedCompile Error on Example application (Auth1)
0%
Description
Hi,
New to Wt (and C) and having massive difficulty projects to compile. Have been at it all day and am loosing the will to live :)
I can get a simple "hello_world" type program to compile and run, so I can't be doing everything wrong, but I'm now trying to take the Auth1 example and starting bending it to my will. I've changed the name of the project, but nothing else.
Compilation seems to fail at the linking stage with a whole load of errors that make it seem like there must be a missing library or something? I've checked and double checked and randomly tried all sorts of things.
If anyone has any suggestions, they would be gratefully received.
Below is my CMakeLists.txt along with the a few lines of make errors.
Platform is Ubuntu 12.04. I can compile the examples with the CMakeLists.txt in the examples folder, but I can't get any of them to compile individual (even if I edit their CMakeLists.txt files)
CMakeLists.txt ¶
cmake_minimum_required(VERSION 2.8)
project(sophont.wt)
set (WT_CONNECTOR "wthttp" CACHE STRING "Connector used (wthttp or wtfcgi)")
set (sophont.wt_VERSION_MAJOR 0)
set (sophont.wt_VERSION_MINOR 1)
ADD_EXECUTABLE(sophont.wt
source/sophont.cpp
source/model/Session.C
source/model/User.C
)
set (WT_LIBS
optimized wt debug wtd
optimized wthttp debug wthttpd
)
set (WT_DBO_LIBS
optimized wtdbo debug wtdbod
optimized wtdbopostgres debug wtdbopostgresd
)
set (BOOST_LIBS
boost_signals boost_regex boost_thread boost_filesystem boost_system
boost_random boost_date_time boost_program_options
)
- tell cmake what it should link your executable to
TARGET_LINK_LIBRARIES (sophont.wt
${WT_LIBS} ${BOOST_LIBS} ${WT_DBO_LIBS}
)
<!-- -->
- tell the linker where all these libraries should be searched for
LINK_DIRECTORIES (
/usr/local/lib
/usr/lib
)
<!-- -->
- tell the compiler where it should look for extra include files
INCLUDE_DIRECTORIES(
/usr/local/include/Wt
/usr/include/boost
)
make errors ¶
CMakeFiles/sophont.wt.dir/source/sophont.cpp.o: In function `AuthApplication::AuthApplication(Wt::WEnvironment const&)':
sophont.cpp:(.text._ZN15AuthApplicationC2ERKN2Wt12WEnvironmentE[_ZN15AuthApplicationC5ERKN2Wt12WEnvironmentE]+0x38): undefined reference to `Wt::WApplication::WApplication(Wt::WEnvironment const&, Wt::WtLibVersion)'
sophont.cpp:(.text._ZN15AuthApplicationC2ERKN2Wt12WEnvironmentE[_ZN15AuthApplicationC5ERKN2Wt12WEnvironmentE]+0x1aa): undefined reference to `Wt::Auth::AuthWidget::AuthWidget(Wt::Auth::AuthService const&, Wt::Auth::AbstractUserDatabase&, Wt::Auth::Login&, Wt::WContainerWidget*)'
sophont.cpp:(.text._ZN15AuthApplicationC2ERKN2Wt12WEnvironmentE[_ZN15AuthApplicationC5ERKN2Wt12WEnvironmentE]+0x211): undefined reference to `Wt::Auth::AuthWidget::setRegistrationEnabled(bool)'
CMakeFiles/sophont.wt.dir/source/sophont.cpp.o: In function `AuthApplication::authEvent()':
sophont.cpp:(.text._ZN15AuthApplication9authEventEv[AuthApplication::authEvent()]+0x23): undefined reference to `Wt::Auth::Login::loggedIn() const'
sophont.cpp:(.text._ZN15AuthApplication9authEventEv[AuthApplication::authEvent()]+0x45): undefined reference to `Wt::Auth::Login::user() const'
sophont.cpp:(.text._ZN15AuthApplication9authEventEv[AuthApplication::authEvent()]+0x84): undefined reference to `Wt::log(std::basic_string<char, std::char_traits, std::allocator > const&)'
sophont.cpp:(.text._ZN15AuthApplication9authEventEv[AuthApplication::authEvent()]+0x10a): undefined reference to `Wt::log(std::basic_string<char, std::char_traits, std::allocator > const&)'
CMakeFiles/sophont.wt.dir/source/sophont.cpp.o:(.rodata._ZTV15AuthApplication[vtable for AuthApplication]+0x58): undefined reference to `Wt::WObject::setRequestTooLarge(long)'
CMakeFiles/sophont.wt.dir/source/sophont.cpp.o:(.rodata._ZTIN2Wt7WServer9ExceptionE[typeinfo for Wt::WServer::Exception]+0x10): undefined reference to `typeinfo for Wt::WException'
CMakeFiles/sophont.wt.dir/source/model/Session.C.o: In function `Session::configureAuth()':
Session.C:(.text+0xe2): undefined reference to `Wt::Auth::AuthService::setAuthTokensEnabled(bool, std::basic_string<char, std::char_traits, std::allocator > const&)'
Session.C:(.text+0x109): undefined reference to `Wt::Auth::AuthService::setEmailVerificationEnabled(bool)'
Session.C:(.text+0x11e): undefined reference to `Wt::Auth::PasswordVerifier::PasswordVerifier()'
Session.C:(.text+0x13c): undefined reference to `Wt::Auth::BCryptHashFunction::BCryptHashFunction(int)'
Session.C:(.text+0x14b): undefined reference to `Wt::Auth::PasswordVerifier::addHashFunction(Wt::Auth::HashFunction*)'
Session.C:(.text+0x15c): undefined reference to `Wt::Auth::PasswordService::setVerifier(Wt::Auth::PasswordService::AbstractVerifier*)'
Session.C:(.text+0x16b): undefined reference to `Wt::Auth::PasswordService::setAttemptThrottlingEnabled(bool)'
Session.C:(.text+0x180): undefined reference to `Wt::Auth::PasswordStrengthValidator::PasswordStrengthValidator()'
Session.C:(.text+0x18d): undefined reference to `Wt::Auth::PasswordService::setStrengthValidator(Wt::Auth::AbstractPasswordService::AbstractStrengthValidator*)'
Session.C:(.text+0x192): undefined reference to `Wt::Auth::GoogleService::configured()'
Updated by Wim Dumon over 12 years ago
Can you do a 'make VERBOSE=1
' and see if the proper libraries are referenced? From the errors it looks like you're not linking to wt.so (or wtd.so). Did you build both release and debug versions of Wt?
BR,
Wim.
Updated by Simon Gardner over 12 years ago
Many thanks Wim.
make VERBOSE=1 2> errors
/usr/bin/cmake -H/home/simon/www/wt/build/apps/sophont -B/home/simon/www/wt/build/apps/sophont ---check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /home/simon/www/wt/build/apps/sophont/CMakeFiles /home/simon/www/wt/build/apps/sophont/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory `/home/www/wt/build/apps/sophont'
make -f CMakeFiles/sophont.wt.dir/build.make CMakeFiles/sophont.wt.dir/depend
make[2]: Entering directory `/home/www/wt/build/apps/sophont'
cd /home/simon/www/wt/build/apps/sophont && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/simon/www/wt/build/apps/sophont /home/simon/www/wt/build/apps/sophont /home/simon/www/wt/build/apps/sophont /home/simon/www/wt/build/apps/sophont /home/simon/www/wt/build/apps/sophont/CMakeFiles/sophont.wt.dir/DependInfo.cmake ---color=
make[2]: Leaving directory `/home/www/wt/build/apps/sophont'
make -f CMakeFiles/sophont.wt.dir/build.make CMakeFiles/sophont.wt.dir/build
make[2]: Entering directory `/home/www/wt/build/apps/sophont'
/usr/bin/cmake -E cmake_progress_report /home/simon/www/wt/build/apps/sophont/CMakeFiles 1
[ 33%] Building CXX object CMakeFiles/sophont.wt.dir/source/sophont.cpp.o
/usr/bin/g -O3 -DNDEBUG -I/usr/local/include/Wt -I/usr/include/boost -o CMakeFiles/sophont.wt.dir/source/sophont.cpp.o -c /home/simon/www/wt/build/apps/sophont/source/sophont.cpp
/usr/bin/cmake -E cmake_progress_report /home/simon/www/wt/build/apps/sophont/CMakeFiles 2
[ 66%] Building CXX object CMakeFiles/sophont.wt.dir/source/model/Session.C.o
/usr/bin/g -O3 -DNDEBUG -I/usr/local/include/Wt -I/usr/include/boost -o CMakeFiles/sophont.wt.dir/source/model/Session.C.o -c /home/simon/www/wt/build/apps/sophont/source/model/Session.C
/usr/bin/cmake -E cmake_progress_report /home/simon/www/wt/build/apps/sophont/CMakeFiles 3
[100%] Building CXX object CMakeFiles/sophont.wt.dir/source/model/User.C.o
/usr/bin/g -O3 -DNDEBUG -I/usr/local/include/Wt -I/usr/include/boost -o CMakeFiles/sophont.wt.dir/source/model/User.C.o -c /home/simon/www/wt/build/apps/sophont/source/model/User.C
Linking CXX executable sophont.wt
/usr/bin/cmake -E cmake_link_script CMakeFiles/sophont.wt.dir/link.txt ---verbose=1
/usr/bin/g -O3 -DNDEBUG CMakeFiles/sophont.wt.dir/source/sophont.cpp.o CMakeFiles/sophont.wt.dir/source/model/Session.C.o CMakeFiles/sophont.wt.dir/source/model/User.C.o -o sophont.wt -rdynamic -lwt -lwthttp -lboost_signals -lboost_regex -lboost_thread -lboost_filesystem -lboost_system -lboost_random -lboost_date_time -lboost_program_options -lwtdbo -lwtdbopostgres
Updated by Wim Dumon over 12 years ago
Hmm I don't see -L/usr/local/lib in that link command. But you don't get an error about not finding the wt library neither. Is it possible that there is an obsolete (or maybe packaged) version of the library residing in /usr/lib? Maybe you have to move the LINK_DIRECTORY statement higher in the CMakeLists.txt.
Wim.
Updated by Simon Gardner over 12 years ago
Thank you sooo much.
Did some digging through the generated make files and guessed that "link.txt" which contains:
/usr/bin/g -O3 -DNDEBUG CMakeFiles/sophont.wt.dir/source/sophont.cpp.o CMakeFiles/sophont.wt.dir/source/model/Session.C.o CMakeFiles/sophont.wt.dir/source/model/User.C.o -o sophont.wt -rdynamic -lwt -lwthttp -lboost_signals -lboost_regex -lboost_thread -lboost_filesystem -lboost_system -lboost_random -lboost_date_time -lboost_program_options -lwtdbo -lwtdbopostgres
Probably ought to include -L/usr/local/lib -L/usr/lib, but doesn't. Added them to the command and it compiled first time :)
I need to go out right now, but I'll do some experimentation with cmake to see if I can work out why the -L's aren't being added and I'll post back here in case it helps others.
Thanks again !
Updated by Simon Gardner over 12 years ago
Moving LINK_DIRECTORIES to above ADD_EXECUTABLE in the CMakeLists.txt did fix the problem :)
The issue is discussed (though not conclusively) here: http://www.cmake.org/pipermail/cmake/2009-May/029530.html
Updated by Koen Deforche over 12 years ago
- Status changed from New to InProgress
- Assignee set to Wim Dumon