Recent

Author Topic: microhttp guidance please  (Read 1935 times)

Michael Collier

  • Sr. Member
  • ****
  • Posts: 323
microhttp guidance please
« on: August 02, 2024, 10:26:13 pm »
Hi,

I'm playing with the simpleserver example fpcupdeluxe/fpcsrc/packages/fcl-web/examples/simpleserver and noticed {$DEFINE USEMICROHTTP}

Looks interesting but I don't know what to download / install to get the demo to link "Error: Error while linking"

I'm using linux at the moment and found references to installing micro-httpd via apt-get.
I also found download libmicrohttpd here https://www.gnu.org/software/libmicrohttpd/

Can anyone point me in the right direction please?

What should I do to get the demo to link?

Also curious about what the end-user would need to download / install for the application to run?

TIA
Mike


PierceNg

  • Sr. Member
  • ****
  • Posts: 387
    • SamadhiWeb
Re: microhttp guidance please
« Reply #1 on: August 03, 2024, 04:11:55 am »
On Ubuntu 20.04.

Code: Text  [Select][+][-]
  1. % sudo apt install libmicrohttpd-dev
  2. ...
  3.  
  4. %  ls -l
  5. total 924
  6. -rw-r--r-- 1 pierce pierce     28 Oct 16  2021 index.css
  7. -rw-r--r-- 1 pierce pierce    308 Oct 16  2021 index.html
  8. -rw-r--r-- 1 pierce pierce  24301 Oct 16  2021 mime.types
  9. -rw-r--r-- 1 pierce pierce   1023 Oct 16  2021 README.txt
  10. -rw-r--r-- 1 pierce pierce   1924 Oct 16  2021 simpleserver.lpi
  11. -rw-r--r-- 1 pierce pierce  10747 Jan 13  2022 simpleserver.pas
  12.  
  13. % lazbuild simpleserver.lpi
  14. ...
  15. (9015) Linking /home/pierce/pkg/fpc/share/fpcsrc/3.2.2/packages/fcl-web/examples/simpleserver/simpleserver
  16. (1008) 9764 lines compiled, 0.8 sec
  17. (1021) 39 warning(s) issued
  18. (1022) 22 hint(s) issued
  19. (1023) 2 note(s) issued
  20.  
  21. % ./simpleserver -p 8080
  22. 2024-08-03 09:55:07.360 [etInfo] Listening on port 8080, serving files from directory: /home/pierce/pkg/fpc/share/fpcsrc/3.2.2/packages/fcl-web/examples/simpleserver/ (using SSL: false)
  23. 2024-08-03 09:55:07.360 [etInfo] Using index page index.html
  24. Server created.
  25.  
  26. % curl http://localhost:8080/
  27. <http>
  28. <link rel="stylesheet" href="index.css">
  29. <body>
  30. <H1>Simple server demo</H1>
  31. If you see this page, it demonstrates that the simple server demo serves the
  32. <span class="important">index.html</span> page. <p>
  33. If it shows index.html in a
  34. different style, it means the css is loaded as well.
  35. </body>
  36. </http>

End user needs libmicrohttpd.so.12:

Code: Text  [Select][+][-]
  1. % ldd simpleserver | egrep micro
  2. (standard input):       libmicrohttpd.so.12 => /lib/x86_64-linux-gnu/libmicrohttpd.so.12 (0x00007f33b374e000)

MarkMLl

  • Hero Member
  • *****
  • Posts: 7649
Re: microhttp guidance please
« Reply #2 on: August 03, 2024, 09:13:48 am »
End user needs libmicrohttpd.so.12:

OP's out of order for not telling us what OS he was running: "Linux" is a kernel and potentially includes a multitude of embedded systems etc. However on Debian:

Code: Text  [Select][+][-]
  1. $ apt-cache search microhttpd
  2. ...
  3. libmicrohttpd-dev - library embedding HTTP server functionality (development)
  4. ...
  5.  

and

Code: Text  [Select][+][-]
  1. $ apt-file search libmicrohttpd.so.12
  2. libmicrohttpd12: /usr/lib/x86_64-linux-gnu/libmicrohttpd.so.12
  3. libmicrohttpd12: /usr/lib/x86_64-linux-gnu/libmicrohttpd.so.12.60.0
  4.  

There's a minor disparity in the package name there, but it's probably that -dev package which ensures that files and symlinks are in place.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

Michael Collier

  • Sr. Member
  • ****
  • Posts: 323
Re: microhttp guidance please
« Reply #3 on: August 07, 2024, 03:27:20 am »
..Linux working ok..

Trying also on windows11 64 bit machine, error missing DLL (libmicrohttpd-10.dll)

The latest windows download (32 bit?) conatains DLL version 12 (libmicrohttpd-12.dll)
https://ftpmirror.gnu.org/libmicrohttpd/libmicrohttpd-latest-w32-bin.zip

Found pre-compiled DLL (libmicrohttpd-10.dll) in old download here (32 bit?)..
https://ftp.gnu.org/gnu/libmicrohttpd/libmicrohttpd-0.9.35-w32.zip

Pascal code specifies version 10 here,,
/fpcupdeluxe/fpcsrc/packages/libmicrohttpd/src
Code: Pascal  [Select][+][-]
  1. const
  2.   MHD_LIB_NAME = {$IFDEF MSWINDOWS}'libmicrohttpd-10'{$ELSE}'microhttpd'{$ENDIF};  
  3.  

I can't seem to get the simpleserver to run, get error 0xc0000022

Not sure what options to use for compiling and/or files to download to get it working..

Tried variations, nothing worked for me but was mostly guessing..

Thaddy

  • Hero Member
  • *****
  • Posts: 15663
  • Censorship about opinions does not belong here.
Re: microhttp guidance please
« Reply #4 on: August 07, 2024, 07:43:36 am »
What happens if you copy  libmicrohttpd.pp and the example over to a new directory and change the version to libmicrohttpd-12 ?
You need to use a 32bit FPC compiler. Could not find a precompiled 64 bit dll version for Windows, although you might be able to build it from source.
« Last Edit: August 07, 2024, 08:08:50 am by Thaddy »
If I smell bad code it usually is bad code and that includes my own code.

Michael Collier

  • Sr. Member
  • ****
  • Posts: 323
Re: microhttp guidance please
« Reply #5 on: August 08, 2024, 02:31:13 am »
What happens if you copy  libmicrohttpd.pp and the example over to a new directory and change the version to libmicrohttpd-12 ?
It gave error 0xc0000022

You need to use a 32bit FPC compiler.
I used fpcupdeluxe to install i386 compiler and tried with that (Target OS=Win32 and Target CPU=i386) I can't seem to compile Win64 & i386 (I get FPC configuration warning)

I've gone through all combinations I can think of to compile 32/64 bit and trying different DLL (10 & 12).

Always same error 0xc0000022



Thaddy

  • Hero Member
  • *****
  • Posts: 15663
  • Censorship about opinions does not belong here.
Re: microhttp guidance please
« Reply #6 on: August 08, 2024, 07:51:34 am »
I seem to remember that error 0xc0000022 is a permissions issue. Try to run as administrator and if that works, add a manifest resource with elevated rights.
Example manifest:
Code: XML  [Select][+][-]
  1. <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
  2. <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  3.   <assemblyIdentity version="1.0.0.0" processorArchitecture="*" name="YourApplicationName" type="win32"/>
  4.   <description>Your application description</description>
  5.   <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
  6.     <security>
  7.       <requestedPrivileges>
  8.         <requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>
  9.       </requestedPrivileges>
  10.     </security>
  11.   </trustInfo>
  12. </assembly>

It may be enough to add this instead:
Code: XML  [Select][+][-]
  1. <requestedExecutionLevel level="highestAvailable" uiAccess="false"/>
The latter means that if the user is in the administrator group, requireAdministrator will be in effect.
Users that are not in the administrator group can not run the application, but will be notified that they have insufficient rights.

« Last Edit: August 08, 2024, 08:07:42 am by Thaddy »
If I smell bad code it usually is bad code and that includes my own code.

Michael Collier

  • Sr. Member
  • ****
  • Posts: 323
Re: microhttp guidance please
« Reply #7 on: August 09, 2024, 12:25:58 am »
I seem to remember that error 0xc0000022 is a permissions issue.

Ok yes that seemed to be the problem..

The exe and DLL's reside on a linux drive, the windows machine has a drive mapped to their location.

When I copy the exe and DLL's to windows desktop and run from there it is ok, but (so far...) must use exe compiled as 32 bit and use the version 10 DLL's - but at least it is running now.

Michael Collier

  • Sr. Member
  • ****
  • Posts: 323
Re: microhttp guidance please
« Reply #8 on: August 11, 2024, 11:09:22 pm »
I'd like to get macOS (macbook air) working too..

Found libmicrohttpd on this site, is it the correct download? (couldn't find libmicrohttpd-dev as per linux):
https://formulae.brew.sh/formula/libmicrohttpd

So I installed the Homebrew system (https://brew.sh/)
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

And installed libmicrohttpd
brew install libmicrohttpd

I can see header file (microhttpd.h) and dylib files ( libmicrohttpd.12.dylib and 'shortcut' libmicrohttpd.dylib ). I've tried copying these files into simpleserver project directory (tried other directories, and setting library paths) but get linker errors.

The errors are 'undefined symbols for architecture x86_64' and list of names of functions that I can find in header file.

I'm not sure what to try next..?

 

TinyPortal © 2005-2018