Author Topic: Project doesn't compile under Code::Blocks  (Read 3238 times)

robheus

  • Guest
Project doesn't compile under Code::Blocks
« on: May 31, 2008, 09:57:05 am »
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();
}
////////////////////////

Source B:
Code
//////////////////////////////

void my_func_1(void);

....

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

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.
« Last Edit: May 31, 2008, 10:07:02 am by robheus »

Offline XayC

  • Multiple posting newcomer
  • *
  • Posts: 94
Re: Project doesn't compile under Code::Blocks
« Reply #1 on: May 31, 2008, 10:03:19 am »
This may happen when some object files are not updated. Try to Clean and then Rebuild the project.

Regards, XayC

robheus

  • Guest
Re: Project doesn't compile under Code::Blocks
« Reply #2 on: May 31, 2008, 10:46:48 am »
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????


Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Project doesn't compile under Code::Blocks
« Reply #3 on: May 31, 2008, 11:00:54 am »
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".