|
I was wondering if someone could help me out as a C++ newbie (also newbie in C++ in Eclipse)
I'm from a Java background, and within eclipse (running on Kubuntu) when I
set external Java projects as references to a project, I can simply do "import externalClass;" and voila, i can use that class in the current project ...
This doesn't seem to be the case for C++ ...
I've created a new project as a SharedLibrary -> Empty Project
Then created my class, say MyClass in this project, say project A.
(then built it)
Now in project B (new project -> empty project but not shared lib) I want to use the class created in A (which i have set as a project reference in B)
but #include MyClass.h throws an error. Am I missing something fundamental with how C++ shared libraries work?
Help would be much appreciated,
gvanto
the noob
|
|
|
|
|
gvanto - it helps to tell us what error occurs (I presume it's a compiler error, that it can't see MyClass.h ?)
Anyway - building against a library in C/C++ requires that you specify two things - the source-code interface (that's MyClass.h in your case) and an object-code interface (hmmmm - Linux - that'll either be a .a or some shared thing - a .so file? - my only *nix experience is with OS X - which is probably close enough!).
You also need to ensure that the directory in which these files live is specified. That means telling project B what directory contains project A's header file(s) and what directory contains project A's library file(s). The header file directory option will live with compiler options, while the library file directory option will live with linker options - I've never used Eclipse (with CDT?), so I can't be more exact than that.
Anyway - give us a bit more detail and maybe we can sort you out!
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
(I suppose you're using the g++ compiler) see [^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Thanks for the link. Some useful fundamental stuff in there.
But a tutorial on using shared C++ libs in eclipse, from start to end and cover things like: which header files to put where? - which project reference to select, which directory structure to use, etc would be good. (Just a simple example would be amazing)
This one here comes close: http://janmagnet.wordpress.com/2007/09/30/eclipse-cdt-and-shared-libraries/[^]
I followed that tutorial exactly and still I simply get a "make: *** [WLFeeder] Error 1, Type: C/C++ Problem " problem ...
Double-clicking it doesn't do anything, no more info, thats it.
If someone who knows how to use CDT in eclipse can make one project reference another (containing a class that needs to be used)
it would be really really awesome. I'm left stumped.
gvanto
modified on Thursday, February 12, 2009 6:55 PM
|
|
|
|
|
ok found the problem: was using shared instead of static library!
thanks guys for your help!!
gvanto
|
|
|
|
|
Hello,
I need to make a message loop that (also) ends when an event is signaled. I could probably do it myself, but I know messing with message loops is a tricky thing. If you could point me to a resource, where someone has already done this and ironed out all the potential bugs, I'll be grateful.
V.
|
|
|
|
|
There's example code here[^].
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
|
thanks for the responses, I'll try to put all the pieces together...
|
|
|
|
|
My application freezes after my while loop is in effect. The thing is everything in the while loop executes while the gui remains frozen and windows saying the application is not responding. Cpu usage is at 3% and its still executing properly, its just that the gui is frozen! I cant click my button which resets activeR to false thus ending the loop!
I first tried a simple Sleep(5000) at the end of the while loop, but that ended up with 100% cpu usage.
So i looked up on t_time and worked this out... like i said, it works... but the gui freezes. It still executes the keypress every 5 seconds though.
void roger()
{
int count = 5;
time_t seconds;
time_t curseconds;
bool seq = false;
curseconds = time (NULL) + count;
while(activeR){
if(activeR && seq){
curseconds = time (NULL) + count;
numRogers = numRogers + 1;
keybd_event(VK_PRIOR, 0xc9, 0, 0);
keybd_event(VK_PRIOR, 0xc9, KEYEVENTF_KEYUP, 0);
seq = false;
}else{
seconds = time (NULL);
if(seconds >= curseconds)
{
seq = true;
}
}
Sleep(1);
}
}
|
|
|
|
|
you need to implement this on a different thread.
your loop utilizes the main thread and thus the UI freezes.
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
As suggested above, you should call this function on a separate thread. If MFC, look up AfxBeginThread.
OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus
Best wishes to Rexx[^]
|
|
|
|
|
That was a fabulous way of doing things not only the wrong way, but to also complicate it beyond recognition.
If I haven't misunderstood it seems like what you want to do is synthesize a PgUp keystroke every fifth second.
Use CWnd::SetTimer() , or similar, to set up a timer that is fired every fifth second and call ::keybd_event() from the WM_TIMER message handler.
You do not need a secondary thread for this.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
lol it looks like you've answered his call "roger()" . I didn't actually look at the intention of the code. It looked like it's a strong while loop. So didn't opt for timers. Yep timers can do if that's his requirement.
OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus
Best wishes to Rexx[^]
|
|
|
|
|
VuNic wrote: it looks like you've answered his call "roger()"
I didn't think of it that way, but now that you mention it, it is actually a rather funny coincidence.
Good one!
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
The UI would appear to be frozen because your application is busy processing roger() function. One way (from the book: "Ugliest things to do") is to do the dirty stuff manually, but I said it is dirty.
Put this within your while loop:
MSG Msg;
while(::PeekMessage(&Msg, NULL, 0, 0, PM_NOREMOVE))
{
AfxPumpMessage();
}
I've assumed you're using MFC, if you're not, you can still call up on TranslateMessage and DispatchMessage (which would make it dirtier)
This would manually pump message during every iteration of the loop and your application's UI won't appear frozen. *BUT*, you must do such things on a separate thread, like everyone else said.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Rajesh R Subramanian wrote: you must do such things on a separate thread, like everyone else said.
Ummm, no, I did not.
In fact I said the opposite based on what it seems like he's trying to do.
His whole while-loop is an attempt to create timer-functionality and "count seconds".
He'd better correct the root cause and use a timer instead of still doing the wrong thing, but disguising it in a thread.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
OK, boo me. I must read the whole thing carefully before replying.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
lol I just did the same.. looking at the loop he had put, I just replied him to go ahead with a worker thread.
OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus
Best wishes to Rexx[^]
|
|
|
|
|
Hi,
I have created SDI application from CView base class, Now I want to type charactors on the client area. But it was derived from CView so i couldn't get control. So I have created one CRichEditView class object. But i dont know to create the RichEditView for the currently active window. Pls help me
|
|
|
|
|
Ummm - why not just change your custom view to derive from CRichEditView ? You'll also have to replace CView with CRichEditView in various places in your view's .cpp file, for example, in an IMPLEMENT_DYNCREATE statement, a BEGIN_MESSAGE_MAP statement and where CView methods are called (e.g. your view's PreCreateWindow method will call CView::PreCreateWindow - that should be changed to CRichEditView::PreCreateWindow ).
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I what to inherit the struct from another struct in IDL file
any idea?
|
|
|
|
|
Gopal_Kanchana wrote: any idea?
Yes.
Hint: Goooooogle is sooooooooooooo powerful ^ (third item looks promising...).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
I didn't get your reply. Please clarify in detail
|
|
|
|
|
Gopal_Kanchana wrote: I didn't get your reply. Please clarify in detail
Using Google will make you a developer with superpowers...
Click the link I provided, in the 'Hint' at the bottom of my previous reply.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|