dart-lang / dart-lang/samples

LNK1104: cannot open file 'm.lib' - on 'ffi/structs' on Windows

Open
#207 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Dart
Stars
656
Forks
228
Avg merge
19h 14m
Merged PRs (30d)
4

Description

Windows does not use m.lib as its math library is included in the standard library. The `CMakeLists.txt` should read:

```
cmake_minimum_required(VERSION 3.7 FATAL_ERROR)
project(structs_library VERSION 1.0.0 LANGUAGES C)
add_library(structs_library SHARED structs.c structs.def)
if (NOT WIN32)
target_link_libraries(structs_library PUBLIC m)
endif (NOT WIN32)
add_executable(structs_test structs.c)
if (NOT WIN32)
target_link_libraries(structs_test PUBLIC m)
endif (NOT WIN32)

set_target_properties(structs_library PROPERTIES
PUBLIC_HEADER structs.h
VERSION ${PROJECT_VERSION}
SOVERSION 1
OUTPUT_NAME "structs"
XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "Hex_Identity_ID_Goes_Here"
)
```

With `m` operations not running on winddows.

Contributor guide

Open the contributing guide

Research direction

Start with the CMakeLists.txt for ffi/structs and compare how structs_library and structs_test link the math library. Configure and build the sample on Windows, then verify that both targets build without trying to link m.lib while non-Windows builds retain the existing math-library linkage.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, cmake
Domain
build-system, operating-systems
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.