I'm trying to fix an undefined reference to memcpy_s()
error. I've included string.h
in my file and the memcpy()
function works okay, and I've also tried including memory.h
. I'm on x64 Windows 7 and using gcc 4.8.1 to compile.
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
void doMemCopy(char* buf, size_t buf_size, char* in, int chr) {
memcpy_s(buf, buf_size, in, chr);
}
memory for buf
has been allocated in the main function, which calls doMemCpy(buf, 64, in, bytes)
. in
is a string read from standard input
Exact error from cmd terminal:
undefined reference to "memcpy_s" collect2.exe: error: ld returned 1 exit status
buf
andin
been allocated? What is the exact error you get? Show the context where you call the function – Septicidalbuf
has been allocated in the main() function, andin
is a string read from standard input. The error I got wasundefined reference to "memcpy_s" collect2.exe: error: ld returned 1 exit status
– Hydraulics