News:

As usual while waiting for the next release - don't forget to check the nightly builds in the forum.

Main Menu

Windows gcc linking problem in Code::blocks

Started by recobb, October 30, 2010, 05:12:28 PM

Previous topic - Next topic

recobb

I feel like I'm missing something simple here, but I can't figure out what it is.

CB is latest version, just downloaded as the whole package with Mingw32 gcc compiler on Windows XP.  I have a console application with 3 separate .c files.  All 3 files compile successfully, but the linker gives me 'undefined reference to' errors for functions that are defined in a different object file than the one it is being called in.  When I look in the CB Management window, under Symbols, I see the function that the linker cannot find listed as a Global Function, which would presumably mean that it is available to all parts of the program.

If I copy one of the error-producing functions to the .c file that generates the linker error, that particular error goes away.

If I compile from a Windows command line:
gcc file1.c file2.c file3.c -o output.exe
The compiler and linker have no problem producing the .exe

So why, within the CB ide, can't the linker find the references in other objects in the same project?   I used all the default CB settings for a console application.

UPDATE: I turned on compiler logging, and tried each of the compile and link steps that were listed in the log on the Windows command line.  I was surprised to see, for a c program, that mingw32-g++ was invoked for the linking step (instead of mingw32-gcc - in the new project wizard I did specify a C program, not C++).  Be that as it may, even using the g++ version for the linking step the exact same command that failed in the compiler log was successful in the Windows command window.  ???

Thanks!

Richard C.

tanq

Check executable names in Compiler Settings window. Correct names: c compiler = gcc.exe, c++ compiler = g++.exe, linker for dynamic libs = gcc.exe
I remember that 3-rd parameter is wrong in c::b by default.