Building "Hello World" as found in "A gentle intro. to Wt ..."
Added by Ted Smith about 2 years ago
Hi,
What is the correct way to build "Hello World" from listing 1 of:
A gentle introduction to the Wt C++ Toolkit for Web Applications.
This article is a tutorial distributed with Wt 3.1.1.
(I would include the short C++ program, but angle-brackets confuse the forum submission process)
I am confused by the lack of a definition for main() in the code.
A different but related question follows.
----------------------------------------
A different version of "Hello" is distributed in the examples of Wt 3.1.1.
It is hello.C. It does include a
definition for main() (and no definition for wmain()).
I have successfully compiled the non-FastCGI version with the command:
gcc -o hello.wthttp hello.C -I/usr/local/include -I/usr/local/include/Wt -L/usr/local/lib -lwt -lwthttp
It successfully runs on the wt-server (wthttp) with the command:
./hello.wthttp --docroot . --http-address 192.168.0.100 --http-port 8080
However, my compilation fails when I change -lwthttp to -lfcgi and try to compile with
gcc -o hello.fcgi hello.C -I/usr/local/include -I/usr/local/include/Wt -L/usr/local/lib -lwt -lfcgi
This is an attempt to make a FastCGI executable.
But compilation fails because Wt::WRun() is not defined in -lfgci (in otherwords libfgci.so).
This makes some sense since WRun() launches the wt-server, while FastCGI wouldn't need such a launch.
What is the correct way to compile this code for FastCGI?
Is it true that when compiling for non-FastCGI (i.e., wthttp) a definition for main() and a call to Wt::WRun()
are required, but when compiling for FastCGI no main() is define and compilation produces a non-executable
(perhaps a shared object)?
Thanks.
Replies
RE: Building "Hello World" as found in "A gentle intro. to Wt ..." - Added by Wim Dumon about 2 years ago
Hello,
The article also mentions 'Originally published in Software Developers Journal April 2006 issue, and brought
up-to-date for Wt version 1.1.0.'. Back then, we did some things a bit different. Most of the content of the article is still valid, though.
But that does not make your point less valid: we will update this article to the current version.
To answer your questions:- wmain does no longer exist (the library used to contain the main symbol but that was not our best idea). Now, you have to call WRun from your main(), or instantiate a WServer. See our hello world example.
- Wt's fcgi connector is not -lfcgi, but -lwtfcgi. wtfcgi should contain Wt::WRun
- Both built-in webserver and fcgi connector produce an executable
Best regards,
Wim.
RE: Building "Hello World" as found in "A gentle intro. to Wt ..." - Added by Ted Smith about 2 years ago
Wim,
Thanks for your helpful response.
I agree that it is important to update "A gentle intro. ...", especially since it is include as a tutorial with Wt 3.1.1. Even with the cautionary first line about the date and older version, it is confusing to new users since the changes are somewhat fundamental.