NI Linux Real-Time Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot Cross Compile helloworld Example Using Visual Studio Code and CMake

Solved!
Go to solution

Hello,

I followed all steps from nilrt-docs.ni.com and was not able to compile helloworld.c example, I get the following error in the terminal:

 

Executing task: cmake -G Ninja D:\projects-git\helloworld/build

-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: C:/build/2023q4/x64/sysroots/x86_64-w64-mingw32/usr/bin/x86_64-nilrt-linux/x86_64-nilrt-linux-gcc.exe
-- Check for working C compiler: C:/build/2023q4/x64/sysroots/x86_64-w64-mingw32/usr/bin/x86_64-nilrt-linux/x86_64-nilrt-linux-gcc.exe - broken
CMake Error at C:/Program Files/CMake/share/cmake-3.30/Modules/CMakeTestCCompiler.cmake:67 (message):
The C compiler

"C:/build/2023q4/x64/sysroots/x86_64-w64-mingw32/usr/bin/x86_64-nilrt-linux/x86_64-nilrt-linux-gcc.exe"

is not able to compile a simple test program.

It fails with the following output:

Change Dir: 'D:/projects-git/helloworld/build/CMakeFiles/CMakeScratch/TryCompile-rb58ib'

Run Build Command(s): C:/PROGRA~1/Ninja/ninja.exe -v cmTC_5e2f8
[1/2] C:\build\2023q4\x64\sysroots\x86_64-w64-mingw32\usr\bin\x86_64-nilrt-linux\x86_64-nilrt-linux-gcc.exe -o CMakeFiles\cmTC_5e2f8.dir\testCCompiler.c.o -c D:\projects-git\helloworld\build\CMakeFiles\CMakeScratch\TryCompile-rb58ib\testCCompiler.c
FAILED: CMakeFiles/cmTC_5e2f8.dir/testCCompiler.c.o
C:\build\2023q4\x64\sysroots\x86_64-w64-mingw32\usr\bin\x86_64-nilrt-linux\x86_64-nilrt-linux-gcc.exe -o CMakeFiles\cmTC_5e2f8.dir\testCCompiler.c.o -c D:\projects-git\helloworld\build\CMakeFiles\CMakeScratch\TryCompile-rb58ib\testCCompiler.c
x86_64-nilrt-linux-gcc.exe: fatal error: cannot execute 'c:/build/2023q4/x64/sysroots/x86_64-w64-mingw32/usr/bin/x86_64-nilrt-linux/../../libexec/x86_64-nilrt-linux/gcc/x86_64-nilrt-linux/11.3.0/as.exe': CreateProcess: No such file or directory
compilation terminated.
ninja: build stopped: subcommand failed.

 

 

CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:18 (project)


-- Configuring incomplete, errors occurred!

 

I attached also the CMakeConfigureLog.yaml file. It seems that the compilers are not working for some reason, any ideas why?
Thank you!

Lucian
CLA
Download All
0 Kudos
Message 1 of 4
(325 Views)
Solution
Accepted by topic author LucianM

Make sure you unpack the toolchain as admin and also make sure the libwinpthread.dll (or something like that) can be found in a folder on the path environment variable. Try running the cross-compiler directly from explorer or a terminal and see what errors you get. You can just use '--version' with it to try reading the toolchain version info and ensure it actually runs.

~ The wizard formerly known as DerrickB ~
Gradatim Ferociter
Message 2 of 4
(294 Views)

Problem solved after unpacking the toolchain again by starting 7zip as admin. Something went wrong before, I could read the compiler version from terminal but could not compile the simple example. Thanks @IlluminatedG!

Lucian
CLA
0 Kudos
Message 3 of 4
(250 Views)

The toolchain utilizes symlinks in its folder hierarchy, which is a bit unconventional on Windows, and 7zip can't create those unless it's running as admin. It also has multiple capitalizations for some files which makes sense for a Linux system (well not really, who needs multiple capitalizations in an environment that's case sensitive?) and Windows can't handle those either so that results in some noisy errors that don't impact usage. I'm really curious if R&D does any cross-compilation from Windows environments.

~ The wizard formerly known as DerrickB ~
Gradatim Ferociter
0 Kudos
Message 4 of 4
(225 Views)