PeterVranken / DEVKIT-MPC5748G

Sample code for support of PowerPC development with GCC and NXP evaluation board DEVKIT-MPC5748G
GNU Lesser General Public License v3.0
7 stars 4 forks source link

link error! #1

Closed andywang1005 closed 3 years ago

andywang1005 commented 3 years ago

image

d:/nxp/s32ds_power_v2.1/s32ds/build_tools/powerpc-eabivle-4_9/bin/../lib/gcc/powerpc-eabivle/4.9.4/../../../../powerpc-eabivle/bin/real-ld.exe: cannot find -lm d:/nxp/s32ds_power_v2.1/s32ds/build_tools/powerpc-eabivle-4_9/bin/../lib/gcc/powerpc-eabivle/4.9.4/../../../../powerpc-eabivle/bin/real-ld.exe: cannot find -lc collect2.exe: error: ld returned 1 exit status

I have modified the GNUmakefile, APP ?= code/application/default/ ==> APP ?= code/application/triCore/ srcDirList := code/system/ ==> srcDirList := code/system/ code/application/triCore/

but I still got the problem >_<

PeterVranken commented 3 years ago

Hi,

I just see your email. Without going in depth or trying to reproduce your problem: Did you double-check the path of your compiler installation? -lm and -lc in the linker command line refers to according library files libm.a and libc.a somewhere in the compiler installation. Look for these files and see if their paths are plausible and fit to the setting --sysroot, which selects the variant of the librieries. Run your build without make switch -s to see the full command line of the linker.

Regards, Peter

andywang1005 commented 3 years ago

Hi Peter,

Thanks for your reply; I just find my compiler installation path and files libm.a, libc.a in the following path: D:\NXP\S32DS_Power_v2.1\S32DS\build_tools\powerpc-eabivle-4_9\powerpc-eabivle\newlib\lib

But I did't find the item of setting --sysroot in S32DS. I doubted that my S32DS IDE version(Version: 2.1 Build id: 190624) isn't same with your IDE. image

image

Kind Regards, Andy

PeterVranken commented 3 years ago

Hi Andy,

I think, our understanding of the error message is alright: The standard libraries can't be located by the linker: If I fake the command line (-lm => -lmxxx) then I get the identical error message:

C:/ProgramFiles/NXP/S32DS_Power_v2.1/S32DS/build_tools/powerpc-eabivle-4_9/bin/powerpc-eabivle-gcc.exe -Wl,-Tmakefile/linkerControlFile.ld -Wl,--gc-sections -mbig-endian -mvle -misel=yes -meabi -msdata=default -G8 -mregnames -fshort-double -fsingle-precision-constant -Wl,-sort-common -Wl,-Map="bin/ppc/initial/DEBUG-RAM/DEVKIT-MPC5748G-safe-RTOS.map" -Wl,--cref -Wl,--warn-common,--warn-once,--orphan-handling=warn -Wl,-g -mcpu=e200z4 -mhard-float -Wl,--defsym=ld_linkInRAM=1 --sysroot=C:/ProgramFiles/NXP/S32DS_Power_v2.1/S32DS/build_tools/powerpc-eabivle-4_9/powerpc-eabivle/newlib -o bin/ppc/initial/DEBUG-RAM/DEVKIT-MPC5748G-safe-RTOS.elf @bin/ppc/initial/DEBUG-RAM/obj/listOfObjFiles.txt -lmxxx c:/programfiles/nxp/s32ds_power_v2.1/s32ds/build_tools/powerpc-eabivle-4_9/bin/../lib/gcc/powerpc-eabivle/4.9.4/../../../../powerpc-eabivle/bin/real-ld.exe: cannot find -lmxxx

It's still unclear, why your linker doesn't find the libs. Checking/comparing the --sysroot setting is not possible to me, it's not apparent from your emails. In my installation, and as you can see in the command line before, it is set to .../S32DS_Power_v2.1/S32DS/build_tools/powerpc-eabivle-4_9/powerpc-eabivle/newlib and if I go there, I find the libraries as lib/libc.a and lib/libm.a, which is identical to where you found yours.

You can make the command line visible by calling the build without switch -s. Then check if you see --sysroot=D:/NXP/S32DS_Power_v2.1/S32DS/build_tools/powerpc-eabivle-4_9/powerpc-eabivle/newlib

A brute-force work around (not recommended) could be locating the libs explicitly in the linker command line. You'd modify makefile/compileAndLink.mk such that the folder holding the libs is argument of the switch -L (library search path), i.e. you'd add

-Wl,-LD:/NXP/S32DS_Power_v2.1/S32DS/build_tools/powerpc-eabivle-4_9/powerpc-eabivle/newlib/lib

to the linker's command line.

Your wording "I did't find the item of setting --sysroot in S32DS" could also point to the cause of the problem: The intention in this project is having a build, which is (except for the tool chain installation) independent from the Eclipse IDE. You should be able to run it from any command line tool. You wouldn't need to find the setting in the Eclipse IDE, its set and handled inside the makefile suite (files ./GNUmakefile and ./makefile/*.mk). The only prerequisite are a few environment variables, which are needed to locate the installed tools.

Inside Eclipse, we use the "External Builder" to set up no more than the simple command line to run make.exe. No other build settings are managed through Eclipse property pages.

The required environmental settings are documented at several locations, maybe easiest to find in script setEnv.ps1 in the project's root directory.

I guess, running the build from a shell window will give you more transparency, better feedback, what's happening. Please try. And again: Don't place the normally useful -s in the command line -- this suppresses much of the needed console output.

For your reference, here's my command line and the console output if only a (successful) link step is required:

cd /d c:\home\vranken\projects\DEVKIT-MPC5748GAtGitHub\samples\safe-RTOS\ & mingw32-make -O SAVE_TMP=1 APP=code/application/initial/ build mingw32-make -f makefile/compileAndLink.mk -j 4 --no-print-directory bin/ppc/initial/DEBUG-RAM/DEVKIT-MPC5748G-safe-RTOS.s19 Making DEVKIT-MPC5748G-safe-RTOS for debugging in RAM Linking project. Mapfile is bin/ppc/initial/DEBUG-RAM/DEVKIT-MPC5748G-safe-RTOS.map C:/ProgramFiles/NXP/S32DS_Power_v2.1/S32DS/build_tools/powerpc-eabivle-4_9/bin/powerpc-eabivle-gcc.exe -Wl,-Tmakefile/linkerControlFile.ld -Wl,--gc-sections -mbig-endian -mvle -misel=yes -meabi -msdata=default -G8 -mregnames -fshort-double -fsingle-precision-constant -Wl,-sort-common -Wl,-Map="bin/ppc/initial/DEBUG-RAM/DEVKIT-MPC5748G-safe-RTOS.map" -Wl,--cref -Wl,--warn-common,--warn-once,--orphan-handling=warn -Wl,-g -mcpu=e200z4 -mhard-float -Wl,--defsym=ld_linkInRAM=1 --sysroot=C:/ProgramFiles/NXP/S32DS_Power_v2.1/S32DS/build_tools/powerpc-eabivle-4_9/powerpc-eabivle/newlib -o bin/ppc/initial/DEBUG-RAM/DEVKIT-MPC5748G-safe-RTOS.elf @bin/ppc/initial/DEBUG-RAM/obj/listOfObjFiles.txt -lm C:/ProgramFiles/NXP/S32DS_Power_v2.1/S32DS/build_tools/powerpc-eabivle-4_9/bin/powerpc-eabivle-objcopy.exe -O ihex bin/ppc/initial/DEBUG-RAM/DEVKIT-MPC5748G-safe-RTOS.elf bin/ppc/initial/DEBUG-RAM/DEVKIT-MPC5748G-safe-RTOS.hex C:/ProgramFiles/NXP/S32DS_Power_v2.1/S32DS/build_tools/powerpc-eabivle-4_9/bin/powerpc-eabivle-objcopy.exe -O symbolsrec bin/ppc/initial/DEBUG-RAM/DEVKIT-MPC5748G-safe-RTOS.elf bin/ppc/initial/DEBUG-RAM/DEVKIT-MPC5748G-safe-RTOS.s19

Much success!

Regards Peter

andywang1005 commented 3 years ago

Hi Peter,

Thank you very much. Under your help I made the project successfully by using the command line "mingw32-make -o SAVE_TMP=1 APP=code/application/triCore build" in Power Shell. Fortunately I didn't have to modify makefile/compileAndLink.mk. I only need change a few environment variables according to the file "setEnv.ps1".

I have flashed the program "triCore" to my DEVKIT-MPC5748G board by using the "flash from file" function in S32DS IDE. It works well.

But now I still can't build it in my S32DS IDE . The IDE shows the same error information with this before. d:/nxp/s32ds_power_v2.1/s32ds/build_tools/powerpc-eabivle-4_9/bin/../lib/gcc/powerpc-eabivle/4.9.4/../../../../powerpc-eabivle/bin/real-ld.exe: cannot find -lm d:/nxp/s32ds_power_v2.1/s32ds/build_tools/powerpc-eabivle-4_9/bin/../lib/gcc/powerpc-eabivle/4.9.4/../../../../powerpc-eabivle/bin/real-ld.exe: cannot find -lc collect2.exe: error: ld returned 1 exit status

Kind Regards Andy

PeterVranken commented 3 years ago

Then it's likely the same problem: The Eclipse IDE depends on the same environment variables as the shell build (it just acts as a kind of shell when it starts the external build). The concept is starting the IDE via a launch script, which prepares the environment by loading the same sub-script setEnv.ps1. Please have a look at S32DS-IDE.ps1 and the TODOs inside Peter

andywang1005 commented 3 years ago

Thank you Peter,

Successfully!