|
It appears you guys were right. This is a linker issue.
Eclipse lets you specify a reference to your other project.
Being a devoted Visual Studio for .NET developer, I guess I assumed adding the reference was suffice.
However, I've found the specific settings needed for linking the library.
For future references to this post:
1. Open the project's settings.
2. Expand "C/C++ Build" and select "Settings".
3. Under "Tool Settings" expand "GCC C++ Linker" and select "Libraries".
4. Add the name of the library on the top box, and the path to its files on the bottom one.
(Note that the path to the library should be the project's Debug directory)
So now the project gets compiled, and the linker no longer whines about not finding the library.
However I get some new linking errors.
The new console output is as follows:
make all
Building target: Maple
Invoking: GCC C++ Linker
g++ -L"/LibraryPath/Debug" -o"Maple" ./Source/Maple.o -lCursesPlus
/LibraryPath/Debug/libCursesPlus.so: undefined reference to `CursesPlus::CursesPlusEngine::initialized'
.
.
.
collect2: ld returned 1 exit status
make: *** [Maple] Error 1
The vertical three dots hold place for a series of "undefined reference to..." errors, which are similar to the first error, but specify a different member of CursesPlusEngine .
And to make it clear: Maple is my main executable project, and libCursesPlus is my library project.
--Edit--
All of the above members are defined as private static in their corresponding header files.
modified on Tuesday, August 31, 2010 4:56 AM
|
|
|
|
|
Since you've only got 1 library and 1 runner, and I assume you're not trying to use code from runner in the library, there is only one possibility left: you forgot to add the proper source file(s) to your project(s)...
|
|
|
|
|
It appears I had to declare the static member variables in both the header files, and the source files.
The project now compiles successfully.
What's the idea behind this repetitive declaration?
It's not like a function which is declared in the header, and defined in the source.
It's simply a variable... Oo *Confused*
|
|
|
|
|
When you declare a static data member in a class you're telling the compiler: "This class has a static member called <whatever>." When you define it outside of a class you're telling the compiler: "You know that variable <whatever>? This is where you reserve memory for it and initialise it with <whatever>."
So it really is identically like a function which is declared in a header and defined in the source.
Cheers,
Ash
PS: It's also identical to the behaviour of global variables - declare in a header, define in source. Which is a big hint why statics are bad, bad, bad...
|
|
|
|
|
Aescleal wrote: PS: It's also identical to the behaviour of global variables - declare in a header, define in source. Which is a big hint why statics are bad, bad, bad...
That's a rather sweeping statement. Parts of the language are there for a reason. There are cases where you absolutely need them. Can you misuse them? Certainly. But just yelling bad, bad, bad, ignores the valid cases.
Once you agree to clans, tribes, governments...you've opted for socialism. The rest is just details.
|
|
|
|
|
So where would you use a class static instead of just declaring a variable in an anonymous namespace? i.e. where would you use:
class A
{
private:
static B b;
};
A::B b( b_init );
over:
namespace
{
B b;
}
'Cause I'm not sure I can see any case where that would be of any use. And if you're talking about using public class static data member why not use a global? They've got exactly the same visibility, thread safety issues and initialisation order problems.
|
|
|
|
|
Aescleal wrote: So where would you use a class static instead of just declaring a variable in an anonymous namespace?
...Whenever the non-local is associated with a type, think of the "class object" idioms: reflectors, serializers, registrars etc... Especially in generic code, class statics can be looked up parametrically, which can't be achieved with traditional non-locals.
Aescleal wrote: They've got exactly the same visibility, thread safety issues and initialisation order problems
This remains true and makes c++ non-locals of either kind a dangerous business...
|
|
|
|
|
I suppose the classic example is where you want to keep stats on the class such has how many instances are currently running rampant. Why should I have to go reference another namespace? Like many things in the C world, there's plenty there to shoot yourself in the foot with, you need to exercise proper caution.
Once you agree to clans, tribes, governments...you've opted for socialism. The rest is just details.
|
|
|
|
|
Tim Craig wrote: I suppose the classic example is where you want to keep stats on the class such has how many instances are currently running rampant.
Yes, this is a classic one, where a static member must be associated with a class... As an example to the generic argument from above, consider an InstanceCountabe policy:
template<class T>
class InstanceCountable { :)
static int sCounter;
protected:
InstanceCountable() {
InstanceCountable<T>::sCounter++;
}
~InstanceCountable() {
InstanceCountable<T>::sCounter--;
}
public:
static GetCount() {
return InstanceCountable<T>::sCounter;
}
};
template<class T>
int InstanceCountable<T>::sCounter(0);
class A : public InstanceCountable<A> {
};
class B : public InstanceCountable<B> {
};
int main() {
A a1, a2;
std::array<B, 10> barr;
std::cout <<
A::GetCount() << std::endl
B::GetCount() << std::endl;
}
|
|
|
|
|
No! You may declare your static class members only once. What you have missed, is the definition (which also has to be unique), and it needs to be provided outside of the class, for non-const and non-trivial objects.
class AStuff {
public:
void Hello() {
}
};
class A {
public:
static AStuff sStaticAMember;
};
AStuff A::sStaticAMember;
The constructor for A::sStaticAMember will be called by the runtime (dynamic initialization) if the instance is used by the program. You do not (really) have the control over when this is going to happen, neither when the destructor is going to be called. This is one of the reason why the poster above damned "statics" ... and basically I have to agree with him.
Are you using C# otherwise? If yes, then forget about the comfort of static class objects and their well defined initialization there - and enter one of the many dark zones of c++. I assume you will probably run into the problem of undefined order of initializations of your non-local objects, but we stand ready to help
modified on Tuesday, August 31, 2010 12:56 PM
|
|
|
|
|
This is all a bit overwhelming for me...
I also read some articles regarding the subject, but I still can't <b><i>completely</i></b> get my head around it.
I should hit the books for a while and establish a more solid understanding of C++'s principles and design issues.
For now, I would add this question though...
What is the "danger" in what I did? i.e. declaring a private static member variable inside a class...
|
|
|
|
|
Well, there are several "dangers" in that, but don't panic! It's a perfectly legal c++ construct - which can be used in safe manner if:
1. the functionality of your program does not depend on the time when the global objects are initialized/deinitialized
2. the globals do not depend on the state of each other in an undefined manner
3. you can assure that these global objects are initialized at all - speaking in terms of the holy standard "they are used in the program".
With regards to point 3: Under certain circumstances, linkers do not include these globals into the program, if they don't see an explicit usage of them. This behavior collides with many popular idioms such as pluggable factories, reflectors or serializers: Here, the framework relies on dynamic initialization (this is a process which runs before your program starts) of static class objects with non-trivial constructors which perform certain functionality on instantiation - e.g. register a factory method for a type in an another global collection of factory methods.
|
|
|
|
|
I understand...
Thank you Paul, and everyone else for your help and opinions.
For now, I shell continue and educate myself on the matter...
Will "meet" again... (Soon I might add... )
|
|
|
|
|
Hello Everybody,
abc.emf file has some lines and text inside it stored in vector form.
Have tried various way of drawing this emf file on Bitmap as follows:
Metafile metafile("abc.emf");
height = metafile.GetHeight();
width = metafile.GetWidth();
Rect rcdst(0, 0, width, height);
Bitmap bmp(width, height, PixelFormat32bppARGB)
Graphics gr(&bmp);
[1]
gr.DrawImage(&metafile, rcdst, 0, 0, width, height, UnitPixel);
[2]
gr.EnumerateMetafile(&metafile, Point(0, 0), metaCallback, &metafile);
metaCallback was defined appropriately and inside that used Metafile::PlayRecord() for drawing.
Now, when i save this bmp in uncompressed format like tif then the quality of text is
not coming properly.
When i display the same emf file on CDC then the quality of text is proper, means antialised.
Please suggest how the quality of emf can be maintained while drawing it on bitmap.
Also, highlight any other method through which this can be done.
Thanks.
|
|
|
|
|
My applications uses many dll libs.
I suspecting these dlls may has the memory leaks.
All dll uses "#define new DEBUG_NEW" for memory allocation.
when my application ends, the dll's teriminated before reporting memory leaks.
because of that i can't find the leaks of dll(I think).
ListBoxs.DLL Terminating!
EVENTS.DLL Terminating!
Detected memory leaks!
Dumping objects ->
{174217} normal block at 0x04545900, 1024 bytes long.
Data: < > CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD
{174216} normal block at 0x044E8A20, 36 bytes long.
Data: <HG YT YT > 48 47 97 01 A2 CD CD CD 00 59 54 04 00 59 54 04
{174215} normal block at 0x045454B8, 1024 bytes long.
I need to get the memory leak info of ListBoxs.DLL & EVENTS.DLL
how to get those dll leak details?
|
|
|
|
|
If your are OK in your LIBs and their clients code,
you could control (for example by tracing) the symmetry
of new/delete and constructor/destructor calls...
...or use a tool (for example Bounce Checker)
At the Debugging print all addresses of used modules (Break->Debug->Views->Modules)
to compare the ending output with them
and know the module(s) of the leak(s).
virtual void BeHappy() = 0;
|
|
|
|
|
You can start by using google[^]. This question has been asked and answered a few times.
|
|
|
|
|
Bound Checker!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
|
Hi all
How can i get blackberry IMEI Number?
Please help me.
|
|
|
|
|
Google!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
i use google but there havn't found any API and example then i ask here.
|
|
|
|
|
i guess on your BlackBerry u need to type this key combination
*#06#
this works on all branded ones - Nokia,LG,Samsung,Motorola,Siemens
|
|
|
|
|
Thanks but how can i retrieve through programing?
|
|
|
|
|
By picking one of the links and following directions?
I just hit google with this text: "c++ retrieve blackberry imei[^]"
Heavens knows what you'll find...
|
|
|
|