Hi!
I run some c-code on my cDAQ and using eclipse to compile it. However i would like to use the function malloc in the c-code but I get some error when compiling.
#include <stdio.h> #include <stdlib.h> void getAvg(double a[200000], double fs, double freq) { int *array=malloc(16); return; }
When compiling the C-code above I get the error from eclipse:
14:02:59 **** Incremental Build of configuration Debug for project PommacTest **** Info: Internal Builder is used for build x86_64-nilrt-linux-gcc -O0 -g3 -Wall -c -fmessage-length=0 -o test.o "..\\test.c" ..\test.c: In function 'getAvg': ..\test.c:16:10: warning: unused variable 'array' [-Wunused-variable] x86_64-nilrt-linux-gcc -shared -o libPommacTest.so test.o c:/program files (x86)/national instruments/eclipse/14.0/x64/sysroots/i686-nilrtsdk-mingw32/usr/bin/x86_64-nilrt-linux/../../libexec/x86_64-nilrt-linux/gcc/x86_64-nilrt-linux/4.7.2/ld.exe: test.o: relocation R_X86_64_PC32 against undefined symbol `malloc@@GLIBC_2.2.5' can not be used when making a shared object; recompile with -fPIC c:/program files (x86)/national instruments/eclipse/14.0/x64/sysroots/i686-nilrtsdk-mingw32/usr/bin/x86_64-nilrt-linux/../../libexec/x86_64-nilrt-linux/gcc/x86_64-nilrt-linux/4.7.2/ld.exe: final link failed: Bad value collect2.exe: error: ld returned 1 exit status 14:02:59 Build Finished (took 295ms)
Is it possible to use malloc and if so what might be the problem causing the error?