Page 1 of 1

[Solved] Cannot make Ndless-SDK on Windows 10

Unread postPosted: 22 Apr 2016, 07:33
by santacruz
I just installed Windows 10 on a new computer and tried installing the SDK. Loaded everything, built the SDK toolchain, then started trying to make the project.

I kept getting an error saying strnlen was not declared.

Code: Select all
genzehn.cpp: In function ‘std::string zehn_get_string(uint32_t, std::vector<unsigned char>&)’:
genzehn.cpp:39:73: error: ‘strnlen’ was not declared in this scope
     return std::string(start, strnlen(start, extra_data.size() - pos - 1));


A simple search will point you to a StackOverFlow article explaining <cstring> isn't included in the file. Well, open up /ndless/ndless-sdk/tools/luna/genzehn.cpp, look at the third line, and it is included.

Turns out strnlen was a Linux-specific function and cross platform compiling may not be supported. More http://stackoverflow.com/questions/30203551/undefined-reference-to-strnlen-despite-string-h-include

So, the easiest fix is just include the original strnlen code http://stackoverflow.com/questions/21536064/how-does-strnlen-work-in-c

Code: Select all
size_t strnlen(const char *s, size_t max_len)
{
    size_t i = 0;
    for(; (i < max_len) && s[i]; ++i);
    return i;
}


Copy this in somewhere above line 39 and you're good to go.


I hope this helps someone. I didn't find it documented anywhere, then again, I didn't look very hard.