Click to See Complete Forum and Search --> : frustrating behavior


crokett
11-29-2001, 03:47 PM
Wondering if anyone has seen this behavior. In a C++ app I can call a constructor at the global level and perform operations on the resulting object. However, when I copy the code down into main()- where it really needs to be - the compiler tells me that I am have an undefined reference to the constructor. :confused: This is happening with two different classes. I can post the code if you need it, but I was hoping someone else had seen this behavior

thanks

Stuka
11-29-2001, 03:53 PM
Definitely post the code - it sounds like a scoping problem, but it's hard to be sure. Also, post the error messages the compiler spits out.

crokett
11-29-2001, 05:08 PM
I am an idiot. :o I spent about an hour on this thinking it was a scope issue too. I posted this topic after a few minutes of not finding anything on google. I went back to google, changed the search and found out it was a link option. I just got a clean compile. If you ever use the QT libraries in Linux, and you get this problem, try this when you run your build:

g++ -L $QTDIR/lib -lqt -I$QTDIR/include hello.cpp -o hello
I'd still like to know why it worked as a global and not inside any methods.