This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Global Class Decleration

Hi,

I am using uVision4 for LPC3250.

I declare my class in my header file and define its functions in the corresponding cpp file.

My question is this, how can I reach the object of this class when I create it in another file.

For example, in a.cpp:

MyClass MyObject;

in b.cpp

MyBoject.value = 5;

I want my object to be global.

Thanks for your helps.

Parents
  • Hi,

    Andy,
    Yes, I am aware that I am getting a Linker error. The code is compiled without a problem.

    I manually did not link any library or module. I just wrote a very simple class and created its instance. Should I link any library?

    Are you sure that a module that defines MyObject is being linked?
    No module defining MyObject is linked. Should there be?

    Per,
    I checked spellings, there is no wrong with spellings.

    I have 4-5 #defines, I dont think they would cause any problem.

    And you are sending the relevant object file to the linker?
    I dont know how to send the object file to the linker. Can you please explain?

    Besides, I am still spending time to globalize my object. It is really important.

    Thanks for your helps.

Reply
  • Hi,

    Andy,
    Yes, I am aware that I am getting a Linker error. The code is compiled without a problem.

    I manually did not link any library or module. I just wrote a very simple class and created its instance. Should I link any library?

    Are you sure that a module that defines MyObject is being linked?
    No module defining MyObject is linked. Should there be?

    Per,
    I checked spellings, there is no wrong with spellings.

    I have 4-5 #defines, I dont think they would cause any problem.

    And you are sending the relevant object file to the linker?
    I dont know how to send the object file to the linker. Can you please explain?

    Besides, I am still spending time to globalize my object. It is really important.

    Thanks for your helps.

Children