Skip to content

Ulfius failed to link microhttpd on mingw64 using CMake #268

Description

@raccoman

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):

  • Windows 11
  • Ulfius 2.7.13
  • git clone

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 ()

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions