使用Linaro交叉编译时Eclipse提示找不到Crti.o和Crt1.o求助
I’ve run into this exact issue before with older Linaro toolchains—here’s how to get it sorted out quickly:
Why This Happens
You’ve only configured Eclipse to point to the toolchain’s bin directory, but the cross-compiler needs access to the sysroot (the target system’s root filesystem included with the toolchain) where Crt1.o, Crti.o, and other essential startup/linker files live. These files aren’t in the bin folder—they’re buried in the toolchain’s target-specific lib directories.
Step-by-Step Fixes
Locate the actual path of Crt1.o/Crti.o
Open a terminal and run this command to find exactly where these files are stored in your toolchain:find /home/xxx/opt/toolchains/gcc-linaro-5.5.0-2017.10-x86_64_arm-linux-gnueabihf -name "Crt1.o"You’ll get a path like:
/home/xxx/opt/toolchains/gcc-linaro-5.5.0-2017.10-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/libc/usr/lib/Crt1.oThe key parent directory here is
/home/xxx/opt/toolchains/gcc-linaro-5.5.0-2017.10-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/libc—this is your toolchain’s sysroot.Configure Eclipse to use the sysroot
- Right-click your project → Properties → C/C++ Build → Settings
- Go to the Tool Settings tab, expand Cross GCC Linker → Miscellaneous
- In the Other flags field, add this flag (replace with your actual sysroot path):
--sysroot=/home/xxx/opt/toolchains/gcc-linaro-5.5.0-2017.10-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/libc - Alternatively, you can add the directory containing
Crt1.oto the Library search path (-L) field under Cross GCC Linker → Libraries, but using--sysrootis cleaner since it covers all target libraries and headers.
Verify with a manual terminal compile
To rule out Eclipse-specific issues, test the toolchain directly in the terminal:arm-linux-gnueabihf-gcc --sysroot=/home/xxx/opt/toolchains/gcc-linaro-5.5.0-2017.10-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/libc test.c -o testIf this works, your Eclipse configuration was missing the sysroot parameter—double-check the settings you added in step 2.
Optional: Set environment variables in Eclipse
For better integration, go to Properties → C/C++ Build → Environment and add:PATH: Append/home/xxx/opt/toolchains/gcc-linaro-5.5.0-2017.10-x86_64_arm-linux-gnueabihf/binSYSROOT: Set to your toolchain’s sysroot path (from step 1)
This should resolve the "missing Crti.o/Crt1.o" error—let me know if you hit any snags!
内容的提问来源于stack exchange,提问作者Trung Trinh

