LPCopen linker problem: how to change the linker to the correct workspace?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LPCopen linker problem: how to change the linker to the correct workspace?

Jump to solution
564 Views
jDrum
Contributor III

We are using MCUXpresso IDE 11.8 to build code for the LPC11U68 on our own PCB.

After recovering from a botched import of previously exported backup files, we got the build to function almost normally;  see lpcopen project: problems with importing a saved project .

Apparently there is a linker problem because there are 1200 errors having to do with the *.o files.  The errors are always the same:

multiple definition of `SamplePumpBase';  for example.

Each variable as has the same error, (1200 vars.)

Each error has the following text:

c:/nxp/mcuxpressoide_11.8.0_1165/ide/plugins/com.nxp.mcuxpresso.tools.win32_11.8.0.202306131047/tools/bin/../lib/gcc/arm-none-eabi/12.2.1/../../../../arm-none-eabi/bin/ld.exe: ./src/clock.o:C:\Users\John\Documents\MCUXpressoIDE_11.3.0_5222\workspace\L3MM\Debug/../src/Defs_5.h:428: multiple definition of `SamplePumpBase'; ./src/Factory.o:C:\Users\John\Documents\MCUXpressoIDE_11.3.0_5222\workspace\L3MM\Debug/../src/defs_5.h:428: first defined here

The compiler is working in the correct workspace.  The linker is working in a previous workspace!  (namely 11.3.0)

How to fix? Doing a clean does not fix the problem.

jDrum

0 Kudos
1 Solution
479 Views
jDrum
Contributor III

The short answer to the linker problem was that almost all global variables were defined in the defs5.h file.  That file is called by several of the source files.  In the case that the source files are compiled separately, space for the variables will be assigned multiple times.  Apparently, IDE8_3 was able to compile the project in one go which means that the defs5 file was read only once.

In our case we defined a macro for EXTERN which changed the EXTERN to extern unless a separate #define was set (in main() only) .  This worked for the majority of cases and brought our linker error count down to ~100.  The rest were handled individually.

The long answer is more complicated.  We had a recurrence of the problem of importing projects and their source code into a new workspace.  This was the topic of two previous posts.  When we have more time, we will revisit  those posts.  Briefly, we had a problem with starting a "new" project.  The new-project wizard would not accept our input for the chip and board files in step 5.  The browse buttons brought up totally empty screens.

We even re-installed the IDE (no change).

We now mark this post as "solved"

jDrum

 

View solution in original post

0 Kudos
3 Replies
480 Views
jDrum
Contributor III

The short answer to the linker problem was that almost all global variables were defined in the defs5.h file.  That file is called by several of the source files.  In the case that the source files are compiled separately, space for the variables will be assigned multiple times.  Apparently, IDE8_3 was able to compile the project in one go which means that the defs5 file was read only once.

In our case we defined a macro for EXTERN which changed the EXTERN to extern unless a separate #define was set (in main() only) .  This worked for the majority of cases and brought our linker error count down to ~100.  The rest were handled individually.

The long answer is more complicated.  We had a recurrence of the problem of importing projects and their source code into a new workspace.  This was the topic of two previous posts.  When we have more time, we will revisit  those posts.  Briefly, we had a problem with starting a "new" project.  The new-project wizard would not accept our input for the chip and board files in step 5.  The browse buttons brought up totally empty screens.

We even re-installed the IDE (no change).

We now mark this post as "solved"

jDrum

 

0 Kudos
547 Views
ErichStyger
Senior Contributor V

A few tips:

- check the command line of the linker (you see it in the console) and carefully check what is passed. Is the object file in question with that variable with double definition in there twice?

- unlikely as you say it works in previous IDE version: I have seen similar cases where the code includes a .c file instead of the .h file: maybe search for .c" in your code.

- do a full clean-clean of your project (delete the build (debug) output) folder of your project and do a build again.

I hope this helps,

Erich

0 Kudos
529 Views
jDrum
Contributor III

Thank you @ErichStyger 

We tried your suggestions with the following results.

We couldn't view the command line in the console because the 1200 errors pushed those lines off the screen.

A full clean/clean resulted in identical errors.

We looked at the do-not-edit makefile.  I does not identify the workspace path.

I suspect that a Windows reboot wiped out the correct IDE settings which means that we were updating code in the obsolete workspace.  (It is not easy to check the identity of the workspace in the IDE). Somehow the current project name appeared in that workspace.

We plan to move the update scr code to the correct workspace and try again.

jDrum

 

0 Kudos