This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

multiple definition of "something" Segger

Hello every one.

I am new with Segger and nRF52.

I tried to create my own library for OB1203 sensor.

But i stack here when Segger view this error:

Fullscreen
1
Output/blinky_pca10040_s132 Release/Obj/OB1203.o:C:\Users\dang\Desktop\OB1203v1\examples\peripheral\blinky\pca10040\s132\ses/../../../../../../modules/nrfx/drivers/include/OB1203.h:195: multiple definition of `osc_trim'; Output/blinky_pca10040_s132 Release/Obj/main.o:C:\Users\dang\Desktop\OB1203v1\examples\peripheral\blinky\pca10040\s132\ses/../../../../../../modules/nrfx/drivers/include/OB1203.h:195: first defined here
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Below is my screen shoot

I believe the way i put OB1203.h and OB1203.c is wrong, that is not relate to Segger or nRF52 but i can not find where it wrong. 

Please help me.

Thank you for any support

  • Hi

    According to the SEGGER error, it seems that you have defined the same function/variable "osc_trim" multiple times. Please try removing one of the defines to avoid getting this error. I'm guessing you have defined it in both the header and .c file. Please check it out and try again.

    Best regards,

    Simon

    • Thank you for your help.

      I double checked my project. But "osc_trim" variable is only in OB1203.h file

      Follow the SEGGER error both file SEGGER said multiple definition is OB1203.h file, means one file. That one is not make sense to me. Do you have any else ideal.

      Output/blinky_pca10040_s132 Release/Obj/OB1203.o:C:\Users.......OB1203.h:195: multiple definition of `osc_trim'; Output/blinky_pca10040_s132 Release/Obj/main.o:C:\Users............OB1203.h:195: first defined here

      • It seems like the file is located in multiple output files (both main.o and OB1203.o).

        Best regards,

        Simon

        • Hello Simon.

          Do you mean my file (OB1203.h) is located in Obj folder, same folder of main.o and OB1203.o?

          I checked, but that is not.

          OB1203.c and OB1203.h is i created by my self, maybe it cause because i don't know how put file in right position.

          Attach is picture locate of them.

          Could you help me to take a look?

      • Hi Alex

        How have you added the header file to your project? You should do this by right-clicking on the project ->Options -> Go to the preprocessor tab and add the path to the header file in "User include directories" Remember to set the project configurations to Common in the Options window. If you're having trouble with this I suggest checking out our SEGGER Embedded Studios - Getting Started videos.

        Best regards,

        Simon

        • Hi Simon, thank you for support me.

          Finally, i solve that trouble by moving variable "osc_trim" to OB1203.c and there are no error so far.

          I think that is not good way to solve the trouble, but i still not understand why it happened.

          If possible, please continues help me find root of that trouble. 

          "How have you added the header file to your project?" yes, i understand how do Segger manager file. I added .h file already.

        • Can you upload the OB1203.c and .h files so I can take a look at them?

          Best regards,

          Simon

          • Sure, Simon.

            Not only "osc_trim" variable have trouble, all of variable is same error, but after i moved it from .h to .c they are fine.

            Thank you for your supportOB1203.rar

          • Hi Alex

            I noticed this from one of your earlier replies now. I see that the OB1203 folder is located at the end of a very long path. This can cause SES to be unable to locate header files properly and cause errors like this. Can you try placing OB1203 folder closer to the root and add the new path (all the way to the header file, so .../.../OB1203) in the user include directories.

            Best regards,

            Simon