undefined reference to conj, conjf, conjl

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:


#include <complex.h>
int main(void)  
    double complex (*FUNC)(double complex) = conj;   
    return 0;  


#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:UsersMachineDesktopmyappmyapp.c -o objDebugmyapp.o
mingw32-gcc.exe -Wall -g -std=c11 -g -std=c11 -c C:UsersMachineDesktopmyapptest.c -o objDebugtest.o
mingw32-g++.exe -o binDebugmyapp.exe objDebugmyapp.o objDebugtest.o
objDebugmyapp.o: In function main':
C:/Users/Machine/Desktop/myapp/myapp.c:9: undefined reference to
objDebugtest.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.).

MOREOVER: The function conj is defined as “inline” by MinGW32 in . I souspect that this could be the problem, but using option -fno-inline has not any effect.

NM program: By following the suggestion of o11c, I used the nm program. The following output is obtained:

<snip, not what was needed>

Source: gcc

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.