I cannot figure out how to fix this linking problem in GCC.
I am running CodeBlocks 13.12, under Windows 8, GCC+MingWG 4.8.1.
I have created a project having two files:
main.c
#include <complex.h>
int main(void)
{
double complex (*FUNC)(double complex) = conj;
return 0;
}
test.c
#include <complex.h>
double complex (*CEXP)(double complex) = cexp;
double complex (*CONJ)(double complex) = conj;
When the project is compiled in CodeBlocks (I use the compiler option -std=c11, only),
an error results, saying: "Undefined reference to conj".
I think this is extrange, since the function conj is defined in complex.h, as function cexp is, but the reference to cexp seems to work well.
On the other hand, the error is not triggered for the reference to conj in file main.c.
(SORRY: It seems that the error is triggered in main.c, also)
Is this a particular issue of GCC?
How I must configure CodeBlocks to fix this problem?
Thanks in advance.
More information. The compiler window shows these lines in CodeBlocks:
mingw32-gcc.exe -Wall -g -std=c11 -g -std=c11 -c C:\Users\Machine\Desktop\myapp\myapp.c -o obj\Debug\myapp.o
mingw32-gcc.exe -Wall -g -std=c11 -g -std=c11 -c C:\Users\Machine\Desktop\myapp\test.c -o obj\Debug\test.o
mingw32-g++.exe -o bin\Debug\sempha.exe obj\Debug\myapp.o obj\Debug\test.o
obj\Debug\myapp.o: In functionmain': C:/Users/Machine/Desktop/myapp/myapp.c:9: undefined reference toconj' obj\Debug\test.o:test.c:(.data+0x4): undefined reference to `conj' collect2.exe: error: ld returned 1 exit status
ALSO: I've tried to write the option -lm in several places on CodeBlocks without any success (for example, in Settings/Compiler/Other options, or Settings/Compiler/Linker, or Project/Build options..., etc.).
Aucun commentaire:
Enregistrer un commentaire