-
Notifications
You must be signed in to change notification settings - Fork 299
Description
Description
When building OpENer 2.3.0 on Windows using Visual Studio (or CMake with NMake), the linker fails with an unresolved external symbol getMicroSeconds. The cause is a case mismatch between the function declaration/definition and its usage in networkhandler.c.
Environment
- OS: Windows 10/11
- Compiler: Visual Studio 2022 / 2026 (MSVC)
- CMake version: 3.31+
- OpENer version: 2.3.0 (or current master)
Steps to Reproduce
- Clone the OpENer repository.
- Create a build directory, e.g.,
bin/win32. - Run CMake configuration:
cmake -G "Visual Studio 17 2022" -A Win32 ..\..\source
(or use-G "NMake Makefiles"if preferred) - Build the project (either open the generated
.slnin Visual Studio or runnmake/cmake --build .). - Observe linker error.
Error Log
WIN32PLATFORM.lib(networkhandler.obj) : error LNK2019: unresolved external symbol getMicroSeconds referenced in function GetMilliSeconds
D:\...\Release\OpENer.exe : fatal error LNK1120: 1 unresolved externals
Root Cause
In source/src/ports/WIN32/networkhandler.c, the function GetMicroSeconds is defined, but inside GetMilliSeconds it is called as getMicroSeconds (lowercase 'g'). Since C/C++ is case‑sensitive, the linker cannot find the lowercase version.
Snippet from networkhandler.c
MicroSeconds GetMicroSeconds() {
// implementation using QueryPerformanceCounter...
}
MilliSeconds GetMilliSeconds(void) {
return (MilliSeconds) (getMicroSeconds() / 1000ULL); // <-- lowercase call
}Proposed Fix
Change the call in GetMilliSeconds to use the correct uppercase name:
MilliSeconds GetMilliSeconds(void) {
return (MilliSeconds) (GetMicroSeconds() / 1000ULL);
}After this change, the project compiles successfully.
Additional Context
This issue occurs only on Windows because the networkhandler.c file is platform‑specific. The POSIX implementation does not have this problem.
Suggested Improvement
To avoid similar issues, consider enforcing a consistent naming convention across all platform ports, or add a declaration for the lowercase version if it is intentionally different.
Feel free to adjust any details (like the exact Visual Studio version or paths) before posting. Thank you for contributing to OpENer!