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:
#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:
bStream bs;
I get the following error
/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!
I think the lib library should be added as the include dir in both projects.
I tried a variety of path names. The only two which find the file are:
#include "/home/muppetjones/Ubuntu One/lib/bStat/bStat.h"
#include "/home/muppetjones/Ubuntu One/lib/bStream/bStream.h"
and
#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.
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.
#include "/home/muppetjones/Ubuntu One/lib/bStream/bStream.h"
#include "/home/muppetjones/Ubuntu One/lib/bStat/bStat.h"
causes
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?
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.
Nope. No cyclic includes. Neither package uses the other.
My apologies if it is off-topic. Where should this be posted?
Quote from: muppetjones 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?
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.
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.
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.
Here's the new thread: http://forums.next.codeblocks.org/index.php/topic,11512.new.html#new
I posted it in "Using Code::Blocks".
Thanks for your help!