babelouest / ulfius

Web Framework to build REST APIs, Webservices or any HTTP endpoint in C language. Can stream large amount of data, integrate JSON data with Jansson, and create websocket services
https://babelouest.github.io/ulfius
GNU Lesser General Public License v2.1
1.07k stars 183 forks source link

Ulfius failed to link microhttpd on mingw64 using CMake #268

Open raccoman opened 11 months ago

raccoman commented 11 months ago

Describe the issue I'm trying to link ulfius to my cmake project on Windows. I would like to have ulfius sourcecode inside my libs/ folder, then let cmake compile using add_subdirectory(libs/ulfius) and directly linking target ulfius_static. It seems to works just fine except for microhttpd.

To Reproduce I cloned ulfius inside libs/ folder, then I downloaded microhttpd-w32-bin.zip extracted the libmicrohttpd-0.9.77-w32-bin\x86_64\MinGW\static\mingw64 contents inside libs/. Then I copied an Ulfius example and compiled my porject using Cmake (crf. Additional Context)

Expected behavior It should successfully compile

Screenshots immagine

System (please complete the following information):

Additional context Here is my CMakeLists.txt

cmake_minimum_required(VERSION 3.22.1)
project(myapp C)

if (WIN32)
    set(MHD_LIBRARY ${PROJECT_SOURCE_DIR}/libs/microhttpd-w32/lib/libmicrohttpd.a)
    set(MHD_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/libs/microhttpd-w32/include)
endif ()
add_subdirectory(libs/ulfius-2.7.13)

include_directories(include)
set(SOURCES)

add_executable(${PROJECT_NAME} main.c ${SOURCES})

target_link_libraries(${PROJECT_NAME}
        ulfius_static)

if (NOT WIN32)
    target_link_libraries(${PROJECT_NAME} m)
endif ()
babelouest commented 11 months ago

Hello,

Unfortunately, I don't know much on windows build or mingw64, I believe it's possible since I think other were able to build it, but I wouldn't know how.

sfhacker commented 7 months ago

Alo.

Sorry, we do not understand this issue.

image

image

4cecoder commented 5 months ago

I've been looking into this as well and still haven't found a smooth solution to building ulfius on windows

However, maybe trying zig cc command to build on windows.

link your libs and stuff and disable websockets to build easier for windows

With some tweaking of this command, I think we might be able to get some results on windows

zig cc -I /path/to/libmicrohttpd/bin -I /path/to/orcania -I /path/to/yder -o ulfius.o ulfius.c

sfhacker commented 5 months ago

I've never used zig in my life. However, if it works fine on different platforms and/or OSes (e.g. Mac, Linux & Windows), we should give it a try. More than happy to assist.