Project

General

Profile

/usr/bin/ld: cannot find -lwtfcgi

Added by Anonymous about 12 years ago

Forgive me for wasting time with this WoT, but I simply cannot believe how amazing wt is. I've looked at the source for the samples on the main site, and I can't believe what I'm reading. I do 100% ajax/websocket sites with php & .net, and wt (from afar) looks like a godsend. First, it's c, the fastest, and second, the libs are so incredibly comprehensive that anyone who uses the "php is better b/c it's so much easier/faster to code" is kidding themselves. Thanks to all who had a hand in this.

Sorry, had to get that off my chest.

My problem is that I'm nearly 100% new to c and linux, so I'm having trouble learning how to walk. I'm trying to compile hello.C with g, but I can't seem to get it to find the lib. I've only ever compiled rudimentary c files, so I have no idea what I'm doing.

If this helps, I'm on ub 12.10, installed spdy, fastcgi, and wt (with the first command from http://redmine.webtoolkit.eu/projects/wt/wiki/Installing_Wt_on_Ubuntu) all from apt-get.

When I run

g++ -O3 -L/usr/lib -lwt -lwtfcgi hello.C -o hello.wt

bash says

/usr/bin/ld: cannot find -lwtfcgi
collect2: error: ld returned 1 exit status

I tried taking the advice here (but I'm sure I didn't do it right) http://redmine.emweb.be/boards/2/topics/1227. No go. I've read this http://redmine.emweb.be/projects/wt/wiki/Frequently_Asked_Questions#Q-How-do-I-build-my-newly-written-Hello-World-application, but I'm not familiar enough yet to really know what I'm doing.

Here's my CMakeLists.txt:

#
# The ADD_EXAMPLE macro (defined in examples/CMakeLists.txt) ensures that
# the example is correctly built for the requested connector. It is equivalent
# to the following two lines:
#   ADD_EXECUTABLE(hello.wt hello.C)
#   TARGET_LINK_LIBRARIES(hello.wt ${EXAMPLES_CONNECTOR})
# except when the ISAPI (for Microsoft IIS) connector is used, where it will
# build a DLL with the proper symbols exported.
#
WT_ADD_EXAMPLE(hello.wt hello.C)

#
# If you have Wt installed somehwere, you should use the
# installed Wt header files for your own Wt projects.
# e.g. INCLUDE_DIRECTORIES(/usr/local/include)
# instead of the following:
#
#INCLUDE_DIRECTORIES(${WT_INCLUDE_DIR})
INCLUDE_DIRECTORIES(/usr/local/include)
TARGET_LINK_LIBRARIES(hello.wt ${SSL_LIBRARIES} ${BOOST_WT_LIBRARIES} ${BOOST_WTHTTP_LIBRARIES} ${ZLIB_LIBRARIES} ${ASIO_LIBRARIES})

include <Wt/WApplication>
LINK_DIRECTORIES(/usr/local/lib)

Thank you much all!


Replies (9)

RE: /usr/bin/ld: cannot find -lwtfcgi - Added by Bruno Zerbo about 12 years ago

type this command: g -o hello hello.cc -lwthttp -lwt

look here for details http://www.webtoolkit.eu/wt/doc/tutorial/wt.pdf

you don't need -lwtfcgi it is to use another web server than the ones shipped with Wt

RE: /usr/bin/ld: cannot find -lwtfcgi - Added by Plug Gulp about 12 years ago

@Joe Coder Guy

When I run

g++ -O3 -L/usr/lib -lwt -lwtfcgi hello.C -o hello.wt

bash says

/usr/bin/ld: cannot find -lwtfcgi
collect2: error: ld returned 1 exit status

Check whether the library file libwtfcgi.so is under /usr/lib (or it could be under /usr/local/lib)? If not then build Wt library passing the flag "CONNECTOR_FCGI=ON" to cmake in your build directory e.g.:

cmake -DCONNECTOR_FCGI=ON <<Wt source code directory path here>>

If the libwtfcgi.so library is correctly built then use the following CMakeList.txt:

cmake_minimum_required(VERSION 2.8)

set(PROJECT_NAME hello)

project(${PROJECT_NAME})

find_package(Wt REQUIRED)

include_directories(${Wt_INCLUDE_DIR})
add_executable(${PROJECT_NAME}.wt hello.C)
target_link_libraries(${PROJECT_NAME}.wt ${Wt_FCGI_LIBRARY} ${Wt_LIBRARY})

For more Wt options for cmake, refer the file <>/cmake/FindWt.cmake

HTH,

~Plug

RE: /usr/bin/ld: cannot find -lwtfcgi - Added by Anonymous about 12 years ago

Wow,

find / -name 'libwtfcgi.so'

returns no results.

I misspoke. I actually tried

apt-get install libwt*

and then

apt-get install witty witty-dbg witty-dev witty-doc

I just reinstalled ub 12.10 with spdy & fastcgi with only the

apt-get install witty witty-dbg witty-dev witty-doc

command.

Should I build from the latest source instead? Thank-you very much Plug Gulp!

RE: /usr/bin/ld: cannot find -lwtfcgi - Added by Bruno Zerbo about 12 years ago

If you need the lib wtfcgi you probably have to rebuild how sayd Pulp Gulp. But If you want only try the hello world code then simply remove the -lwtfcgi option... it is not mandatory

RE: /usr/bin/ld: cannot find -lwtfcgi - Added by Anonymous about 12 years ago

Yes, rebuilding worked! I'll add my experience to the wiki...

RE: /usr/bin/ld: cannot find -lwtfcgi - Added by Anonymous about 12 years ago

OK, I was able to build from source, and /usr/local/lib/libwtfcgi.so is now there.

I copied your CMakeLists.txt exactly, and used

cmake -DCONNECTOR_FCGI=ON <</usr/local/lib/>>

and

cmake -DCONNECTOR_FCGI=ON </usr/local/lib/>

For the first, the command line turns into this

>

and hangs.

For the second, it says

-bash: syntax error near unexpected token `newline'

I also tried

cmake -DCONNECTOR_FCGI=ON

and it said

CMake Error at CMakeLists.txt:26 (find_package):
  By not providing "FindWt.cmake" in CMAKE_MODULE_PATH this project has asked
  CMake to find a package configuration file provided by "Wt", but CMake did
  not find one.

  Could not find a package configuration file provided by "Wt" with any of
  the following names:

    WtConfig.cmake
    wt-config.cmake

  Add the installation prefix of "Wt" to CMAKE_PREFIX_PATH or set "Wt_DIR" to
  a directory containing one of the above files.  If "Wt" provides a separate
  development package or SDK, be sure it has been installed.


-- Configuring incomplete, errors occurred!

Line 26 is

find_package(Wt REQUIRED)

Do you know what I should do? With this build, I'm able to use wt server, so I think I did it right (followed the directions from the unix-like instruction page exactly).

Thanks Plug!

RE: /usr/bin/ld: cannot find -lwtfcgi - Added by Anonymous about 12 years ago

This command compiled without error

g++ -O3 -o hello hello.C -lwtfcgi -lwt -lboost_signals

RE: /usr/bin/ld: cannot find -lwtfcgi - Added by Plug Gulp about 12 years ago

@Joe Coder Guy

Do you know what I should do?

Its my mistake I did not mention in my earlier post that the statement inside "<<" and ">>" is what you would provide (in your case the directory path of the Wt source code) without including the "<<" and ">>". Say for example, your source code file hello.C and the CMake script file CMakeList.txt are under the directory /home/username/wt_hello:

/home
 |
 +-- /username
     |
     +-- /wt_hello
         |
         +-- CMakeList.txt
         |
         +-- hello.C

Then you go to the directory /home/username/wt_hello and issue the command:

cmake .

Note the "." at the end of the command. That is the path where your source code is (in this example it is the current directory into which you have just entered i.e. /home/username/wt_hello).

Also note that to properly run your Wt application you need to create a symlink to the Wt's "resource" directory in the "docroot" of your webserver (in this example lets keep your application directory and "docroot" the same i.e. /home/username/wt_hello). So continuing the above example, once you have completed the build of your Wt application you need to create a symlink as follows (under directory /home/username/wt_hello):

ln -s /home/username/wt_src/resources

Where /home/username/wt_src is the directory where the Wt "resource" directory is. See below for what is the directory /home/username/wt_src.

And now launch your application from the /home/username/wt_hello directory as follows:

sudo hello.wt --docroot . --http-address 0.0.0.0

On the other hand, if you want to build the Wt library itself from source code then you follow the instruction as mentioned in the installation documentation. So if you have the Wt library source code under say /home/username/wt_src directory, then your first step is to create a new directory where all the build files can be generated, say for example /home/username/wt_build. Then go to the directory /home/username/wt_build and then issue the commands:

cmake -DCONNECTOR_FCGI=ON /home/username/wt_src
make
sudo make install
make -C examples

This will build Wt libraries, and install them in the default location (/usr/local/lib) and then also build all the examples provided by EmWeb.

HTH,

~Plug

    (1-9/9)