Skip to content

How to compile #2

Closed
Closed

Description

@fabriziotappero

hello,
I'd like to cross compile this web server for a riscv64 architecture but I have some problems. Current instructions are a bit unclear to me.

HOWEVER you must provide functions to access your sockets. A Posix/Berkeley sockets example is provided (as well as a WinSock example). Therefor you must be able to compile on a Posix system with Berkeley sockets.

what does that mean?

when you say:

So to compile a basic server:
gcc main.c SocketsCon.c FileServer.c WebServer.c -o example.exe

where should I place myself? in src/ there is a main.c but there is not FileServer.c so.. this command will not work. If I move to the hello world example this command is also incorrect. If I use the one on the bat file, I do manage to cross compile it but when I run it I get:

# sh hello_world_server 
hello_world_server: line 3: syntax error: unexpected word (expecting ")")

If would be great if you could clarify. Thanks a lot

Activity

  1. TheBeef commented on Jan 19, 2024

    @TheBeef
    Owner

    Hi fabriziotappero,

    I have updated the readme to try to make it a bit clearer.

    However here is the answers to your questions directly :)

    Question 1
    HOWEVER you must provide functions to access your sockets. A Posix/Berkeley sockets example is provided (as well as a WinSock example). Therefor you must be able to compile on a Posix system with Berkeley sockets.

    what does that mean?

    Bitty HTTP is not locked into one socket library, if you have some other kind of sockets library (other than Posix sockets for example) you can connect in to them. I have seen SPI based chips that had very different socket API's. Bitty HTTP was build to support these type of things.

    I did provide example use standard Berkeley sockets (and a different one for Windows sockets) in the src/SocketsCon.c file. If you are running on a Linux or other Unix like system you can just use them and not have to worry about the details.

    Question 2
    when you say:

    So to compile a basic server: gcc main.c SocketsCon.c FileServer.c WebServer.c -o example.exe

    where should I place myself?

    This was a generic example that doesn't work with any of the provided examples. It was assuming that you would copy the needed files to your own directory before compiling.

    So if you wanted to use it from the bittyhttp directory you would use:

    gcc src/main.c src/SocketsCon.c src/Examples/HelloWorld/FileServer.c src/WebServer.c -o example.exe
    This would be for a Linux build.

    For windows it would be
    gcc src\main.c src\SocketsConWin.c src\Examples\HelloWorld\FileServer.c src\WebServer.c -o example.exe -lws2_32

    Question 3

    # sh hello_world_server 
    hello_world_server: line 3: syntax error: unexpected word (expecting ")")
    

    Not sure what's going on here. sh is a shell and I'm not sure where hello_world_server came from.

    To run the bat / .sh file (for hello world):
    Linux:

    cd src/Examples/HelloWorld
    ./build.sh
    ./HelloWorld.exe
    

    Windows:

    cd src/Examples/HelloWorld
    build
    HelloWorld
    

    The should be all there is to it (assuming that gcc is installed and setup)

    Hope this helps.

  2. TheBeef commented on Jan 19, 2024

    @TheBeef
    Owner

    Oh, you should also check out http://bittyhttp.com/Development.html for more documentation.

  3. Repository owner locked and limited conversation to collaborators on Feb 3, 2024
  4. converted this issue into a discussion #3 on Feb 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions