lpereira / lwan

Experimental, scalable, high performance HTTP server
https://lwan.ws
GNU General Public License v2.0
5.92k stars 549 forks source link

Unknown type name 'lwan_t' #208

Closed Globik closed 6 years ago

Globik commented 6 years ago

How to compile helloworld.c?? also trying to compile with pkg-config , there is an error stdc-predef.h fatal error /lwan-build-config.h no such file or directory. Though it is there in usr local include lwan What include ausserdem lwan.h?

Globik commented 6 years ago

Hm, an old example from the wiki? Should be struct lwan l; !!!!

Globik commented 6 years ago

What is a library for this functions compress, uncompress and compressBound???

lpereira commented 6 years ago

Indeed, the wiki must be updated. Some things changed in the way Lwan is built, and some data structures also changed their names as you found out. Feel free to update it, as it's a wiki page. :)

As far as those functions, they're defined in Zlib. The build system should take care of finding it in your system; if it doesn't, then I'd like to know more about it: what operating system you're trying to build Lwan on, version, architecture, etc.

Globik commented 6 years ago

Hi, I am on 32bit Lubuntu system) zlib I'v found and linked as -lz. Successfully compiled hello_world example, created in the same folder a file hello_world.conf, but if I am trying to run this programm it complains that it could not find handler hello_world, though this function in place in my source file on c. No idea. May be LD_LIBRARY_PATH is wrong on my system. Echo shows me exactly /usr/local/lib. And those function dlsym can't find those symbol. It's very strange. I saw nm ./hello_world those symbol 'hello_world'. Tests and benchmarks could nt also start the job, I am missing some modules on pythons site, but the lwan.exe runs like a charm, I got it with my browser, server started but with error message, says that has faild download favicon and other things. wwwroot I see only in source directory. Freegeoip.exe also complains that it can not find a conf file 'freegeoip.conf'. Apropos, is Lwan can handle POST requests? I see that it can handle GET requests.

lpereira commented 6 years ago

One thing at a time, please :)

Please post your hello_world.c, hello_world.conf, and the diff to CMakeFiles.txt to a Gist. This should help figure out what's the issue. FWIW, it's not LD_LIBRARY_PATH: Lwan opens the executable to find the symbol and do not rely on this environment variable.

What Python module is missing? You need to install the requests module; maybe the documentation needs to be more clear on this.

You can run Lwan without a configuration file. Run it with --help for details.

As far as Freegeoip goes, setting it up is slightly tricky as it requires a SQLite database in addition to the configuration file. I can't provide the database itself, but I can provide a script that builds it if you need.

Yes, it can handle GET, HEAD, POST, OPTIONS, and DELETE, and it's easy to add more verbs.

fiorix commented 6 years ago

Not directly related to this, but one could contribute to an improvement for the freegeoip code to use maxmind's api to their binary mmdb database file.

Globik commented 6 years ago

@lpereira I have created a gist with hello_world adventure. A little confuse with cmake, so I compiled from command line. Conf files one need to write each new line with tabulation? Have added also nm inspection. Symbol "hello_world" is there on place. Why lwan_functions have "U"? Those are undefined or at run time resolved? https://gist.github.com/Globik/cd61b9aec2800c9762ea55cbe47d887d

lpereira commented 6 years ago

If you're setting the URL map, you don't need to add prefixes to the configuration file. You can rewrite the hello_world.conf to be like this:

listener *:8080 {
}

However, if you'd like to add prefixes using the configuration file, remove the call to lwan_set_url_map(), and do not declare the handlers as a static function. If the handler is static, dlopen() will fail to locate the symbol as it won't be exported.

Globik commented 6 years ago

Got it. First approach.

lpereira commented 6 years ago

Closing the issue, as it seems it's resolved. Feel free to reopen or fill another one.