User forums > Help

Project doesn't compile under Code::Blocks

(1/1)

robheus:
I have a small C project involving several C source files. Code::Blocks can't compile it, due to unresolved function names. However when compiling and linking the same sources under the shell, it compiles and links ok.
How can I trace down this nasty error. I know the sources are ok and compile/link successfully, but why not under Code::Blocks.
NB. I developed the sources under Code::Blocks, and initially, this error did not happen. Only after some changes were made (refactoring functions, renaming and/or replacing them, etc.) this suddenly happened.

Some details:

The error reported that some function calls in Source A to functions declared in Source B do not get resolved.
However a couple of functions called from A and declared in B seem to be fine, and are not reported as unresolved.
I checked for misspellings and proper declarations (declared in A with full function prototypes as external, and declared and defined in B, including function prototypes as global function).

For example:

Source A:

--- Code: ---//////////////////////////
extern void my_func_1(void);

......

int do_something(void)
{
       my_func_1();
}
////////////////////////

--- End code ---

Source B:

--- Code: ---//////////////////////////////

void my_func_1(void);

....

void my_func_1(void)
{
     /// function body/definition
}
//////////////////////

--- End code ---

I checked for all functions called from A and defined in B that this syntax is used, but some of those functions can not be resolved, and others do.

XayC:
This may happen when some object files are not updated. Try to Clean and then Rebuild the project.

Regards, XayC

robheus:
Thanks for the hint, but already tried that several time (from Code::Blocks Build->Clean and by issuing rm -f *.o from the obj directory where Code::Blocks stores object files for the current Project target (Debug)).

Still, the same problem persists.
I know the problem is not in the code. Changes I make in the code in Code::Blocks is reflected correctly in the executable I make when compiling/linking manually, but Code::Blocks keep reporting unresolved references.

Should I perhaps remove/delete all Code::Blocks relevant files (except sources), and re-enter a new project from scratch with my source files????

Jenna:
Before you do this you can turn on full commandline logging and look if the compiler uses the same syntax with C::B then it uses from console.

To do this switch "Settings -> Compiler and Debugger... -> Global Compiler settings -> [the compiler you use] -> Other settings" (the rightmost tab) -> Compiler logging" to "Full command line".

Navigation

[0] Message Index

Go to full version