Author Topic: Problems with Projects  (Read 5610 times)

Offline muppetjones

  • Single posting newcomer
  • *
  • Posts: 9
Problems with Projects
« on: November 12, 2009, 09:12:56 pm »
I'm using Code::Blocks on Linux, specifically Ubuntu 9.10.

Problem: My projects cannot find and use the files from other projects.

I have 2 projects: bStats and bStream. Both work and compile just fine within their own projects, and  both have their files in the same place with the same structure (~ used simply for brevity):

~/lib/bSt*/bS*.h
~/lib/bSt*/bS*.cpp

Where the project files are located in:

~/projects/bSt*/

Using these include lines:
Code
#include "bStat/bStat.h"
#include "bStream/bStream.h"

In each package the file is found, and works fine for the respective package. The problem I'm running into is when I actually try to use the package:

Code
bStream bs;

I get the following error

Code
/home/muppetjones/Ubuntu One/projects/bStat/main.cpp||In function ‘int main()’:|
/home/muppetjones/Ubuntu One/projects/bStat/main.cpp|21|error: ‘bStream’ was not declared in this scope|
/home/muppetjones/Ubuntu One/projects/bStat/main.cpp|21|error: expected ‘;’ before ‘bs’|
||=== Build finished: 2 errors, 0 warnings ===|

I know this is not a C++ error -- it is project dependent, which tells me there is a problem calling code from different  projects.

I have tried adding the class directory, the lib directory...everything I can think of and in all the places which seem appropriate, but nothing seems to work. Please help!

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5496
Re: Problems with Projects
« Reply #1 on: November 12, 2009, 09:17:54 pm »
I think the lib library should be added as the include dir in both projects.

Offline muppetjones

  • Single posting newcomer
  • *
  • Posts: 9
Re: Problems with Projects
« Reply #2 on: November 12, 2009, 09:26:54 pm »
I tried a variety of path names. The only two which find the file are:

Code
#include "/home/muppetjones/Ubuntu One/lib/bStat/bStat.h"
#include "/home/muppetjones/Ubuntu One/lib/bStream/bStream.h"

and

Code
#include "bStat/bStat.h"
#include "bStream/bStream.h"

If you mean add the 'lib/' directory to the "search directories", I have done so both for the project and globally. Again, it works for the calling project just fine, i.e. calling "bStat/bStat.h" works fine in the bStat project, but refuses to work in the bStream and vice versa.

Offline muppetjones

  • Single posting newcomer
  • *
  • Posts: 9
Re: Problems with Projects
« Reply #3 on: November 12, 2009, 09:33:30 pm »
Update: I tried, just for the fun of it, using a single project and adding all of the files -- same issue, with a couple of clarifications: the order of includes counts.

Code
#include "/home/muppetjones/Ubuntu One/lib/bStream/bStream.h"
#include "/home/muppetjones/Ubuntu One/lib/bStat/bStat.h"

causes

Code
   bStat m(v);
   bStream bs;

to scream about bStat. Reverse the include, and it throws a fit about bStream.
Apparently I can only include one custom file?

Offline Zini

  • Multiple posting newcomer
  • *
  • Posts: 64
Re: Problems with Projects
« Reply #4 on: November 12, 2009, 10:19:19 pm »
The error message indicates, that there is no problem with the include paths (the compiler would complain about the #include instruction otherwise). This looks like a bug in your code. Let me guess? Cyclic includes (i.e. two headers including each other)? Anyway, I think this is off-topic here.

Offline muppetjones

  • Single posting newcomer
  • *
  • Posts: 9
Re: Problems with Projects
« Reply #5 on: November 12, 2009, 10:22:25 pm »
Nope. No cyclic includes. Neither package uses the other.

My apologies if it is off-topic. Where should this be posted?

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7594
    • My Best Post
Re: Problems with Projects
« Reply #6 on: November 12, 2009, 11:38:39 pm »
Nope. No cyclic includes. Neither package uses the other.

My apologies if it is off-topic. Where should this be posted?

On a website that covers beginning programing.
The Full compiler build log will help the other group help you.

http://wiki.codeblocks.org/index.php?title=FAQ#Q:_How_do_I_troubleshoot_an_compiler_problem.3F

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline muppetjones

  • Single posting newcomer
  • *
  • Posts: 9
Re: Problems with Projects
« Reply #7 on: November 13, 2009, 06:49:46 pm »
I figured out what the problem is, and I'm working on how to change it. Thanks for the link -- I'lll look at it now.

The object files are buried within the project: <project_loc>/obj/Debug/<path to lib>/*.o

Where I want them _just_ in <path to lib>, that is:
lib/bStat/*.o

I'll post the solution asap, unless someone else posts it first.

Offline muppetjones

  • Single posting newcomer
  • *
  • Posts: 9
Re: Problems with Projects
« Reply #8 on: November 13, 2009, 07:16:41 pm »
So...fixed it...but now there's a new problem, lol.

Project > Properties > Build targets (tab) > Objects output dir:

Except (as many of you probably guessed), it now puts my main.o in the top level directory, thus creating conflicts when I compile anything else..._sigh_.

Does anyone have any solutions for this?

Also, I'm pretty positive this needs a new home in a different thread.

Offline muppetjones

  • Single posting newcomer
  • *
  • Posts: 9
Re: Problems with Projects
« Reply #9 on: November 13, 2009, 07:28:54 pm »
Here's the new thread: http://forums.codeblocks.org/index.php/topic,11512.new.html#new
I posted it in "Using Code::Blocks".

Thanks for your help!