I would like to make C program for the cortex - M0 processor. I work with 64-bit window machine and Eclipse. I found many things on internet and I am confused:
1.MinGW
2.ARM GCC compiler for windows (which can be set in the advanced system in computer, the PATH variable)
3. ARM GNU compiler from Eclipse market
Among all this , Which compiler can be used for ARM and can I output my results on command line. i.e Can I compile the program and produce results on the console ?
This result below is what I get when I try to compile a hello program using the command: arm-none-eabi-gcc -o -tesres -test.c
c:/program files (x86)/gnu tools arm embedded/6 2017-q1-update/bin/../lib/gcc/ar
m-none-eabi/6.3.1/../../../../arm-none-eabi/lib\libc.a(lib_a-exit.o): In functio
n `exit':
exit.c:(.text.exit+0x2c): undefined reference to `_exit'
c:/program files (x86)/gnu tools arm embedded/6 2017-q1-update/bin/../lib/gcc/ar
m-none-eabi/6.3.1/../../../../arm-none-eabi/lib\libc.a(lib_a-sbrkr.o): In functi
on `_sbrk_r':
sbrkr.c:(.text._sbrk_r+0x18): undefined reference to `_sbrk'
c:/program files (x86)/gnu tools arm embedded/6 2017-q1-update/bin/../lib/gcc/ar
m-none-eabi/6.3.1/../../../../arm-none-eabi/lib\libc.a(lib_a-writer.o): In funct
ion `_write_r':
writer.c:(.text._write_r+0x24): undefined reference to `_write'
c:/program files (x86)/gnu tools arm embedded/6 2017-q1-update/bin/../lib/gcc/ar
m-none-eabi/6.3.1/../../../../arm-none-eabi/lib\libc.a(lib_a-closer.o): In funct
ion `_close_r':
closer.c:(.text._close_r+0x18): undefined reference to `_close'
c:/program files (x86)/gnu tools arm embedded/6 2017-q1-update/bin/../lib/gcc/ar
m-none-eabi/6.3.1/../../../../arm-none-eabi/lib\libc.a(lib_a-fstatr.o): In funct
ion `_fstat_r':
fstatr.c:(.text._fstat_r+0x20): undefined reference to `_fstat'
c:/program files (x86)/gnu tools arm embedded/6 2017-q1-update/bin/../lib/gcc/ar
m-none-eabi/6.3.1/../../../../arm-none-eabi/lib\libc.a(lib_a-isattyr.o): In func
tion `_isatty_r':
isattyr.c:(.text._isatty_r+0x18): undefined reference to `_isatty'
c:/program files (x86)/gnu tools arm embedded/6 2017-q1-update/bin/../lib/gcc/ar
m-none-eabi/6.3.1/../../../../arm-none-eabi/lib\libc.a(lib_a-lseekr.o): In funct
ion `_lseek_r':
lseekr.c:(.text._lseek_r+0x24): undefined reference to `_lseek'
c:/program files (x86)/gnu tools arm embedded/6 2017-q1-update/bin/../lib/gcc/ar
m-none-eabi/6.3.1/../../../../arm-none-eabi/lib\libc.a(lib_a-readr.o): In functi
on `_read_r':
readr.c:(.text._read_r+0x24): undefined reference to `_read'
collect2.exe: error: ld returned 1 exit status
You can use the ARM GNU compiler from Eclipse marketplace. When this is installed, you can Create a new C/C++ project with the correct Project type -
e.g. Executable/STM32F0xx C/C++ project if that's the series of chip you wish to target. Make sure Trace output in the wizard is NOT set to None (no trace output). You can then use trace_printf to write to host console via ST-LINK, as the hello-world example will show.
You may also have to install and configure OpenOCD to capture that output and display it in Eclipse's console. In Eclipse, you just set up an external tool Run > External tools > External tools configuration. Specify the location of openocd.exe, set the working directory and, in Arguments, specify which devkit you're using by using the appropriate config file, e.g. -f board\stm32f072discovery.cfg.
Then build, run OpenOCD and debug.
Under Windows for M0 I've been using IAR Embedded Workbench, which was a nice and smooth experience for me. But as far as I remember it needed a license.
https://en.wikipedia.org/wiki/List_of_ARM_Cortex-M_development_tools
Maybe you should look for free options in this list.
Related
TinyCC and GCC both have supported lib-less linking, in favor of directly linking to a DLL file for some time (since lib's haven't had real purpose since Win3.1). But for some reason in Windows, Clang insists on interpreting the .dll file as a .lib file. According to LLVM's page, here, https://lld.llvm.org/windows_support.html, lld-link does support direct dll linkage, but in practice, I'm not seeing any way to specify. (This is true with LLVM 10.0 and 11.0)
To be clear, I'm not referring to manual loading with LoadLibrary and GetProcAddress. I'm referring to invoking the compiler like this:
"C:\Program Files\mingw-w64\x86_64-8.1.0-win32-seh-rt_v6-rev0\mingw64\bin\gcc" -o rdtest.exe rdtest.c -lgdi32 -luser32 openvr_api.dll C:\windows\system32\opengl32.dll C:\windows\system32\msvcrt.dll
^^ Works
"C:\Program Files\LLVM\bin\clang.exe" -fuse-ld=lld-link -v -o rdtest.exe rdtest.c -lgdi32 -luser32 openvr_api.dll C:\windows\system32\opengl32.dll C:\windows\system32\msvcrt.dll
[...]
1 warning generated.
"C:\\Program Files\\LLVM\\bin\\lld-link" -out:rdtest.exe -defaultlib:libcmt "-libpath:C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Professional\\VC\\Tools\\MSVC\\14.28.29333\\lib\\x64" "-libpath:C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Professional\\VC\\Tools\\MSVC\\14.28.29333\\atlmfc\\lib\\x64" "-libpath:C:\\Program Files (x86)\\Windows Kits\\10\\Lib\\10.0.18362.0\\ucrt\\x64" "-libpath:C:\\Program Files (x86)\\Windows Kits\\10\\Lib\\10.0.18362.0\\um\\x64" -nologo "C:\\Users\\cnlohr\\AppData\\Local\\Temp\\rdtest-a9472b.o" gdi32.lib user32.lib openvr_api.dll "C:\\windows\\system32\\opengl32.dll" "C:\\windows\\system32\\msvcrt.dll"
lld-link: error: openvr_api.dll: bad file type. Did you specify a DLL instead of an import library?
lld-link: error: C:\windows\system32\opengl32.dll: bad file type. Did you specify a DLL instead of an import library?
lld-link: error: C:\windows\system32\msvcrt.dll: bad file type. Did you specify a DLL instead of an import library?
clang: error: linker command failed with exit code 1 (use -v to see invocation)
^^ Fails
This was implemented recently upstream https://reviews.llvm.org/rGa9ff1ce1b9a52add7557cf0579d424c9d0678860 and was backported to the MSYS2 llvm package.
You are misreading LLVM's documentation. I believe the part you are referring to is:
Linking against DLL
Done. LLD can read import libraries needed to link against DLL. Both export-by-name and export-by-ordinal are supported.
They do not mean the same thing as MinGW / TinyCC's "direct" (no .lib) linking. They mean literally "LLD can link to shared libraries on Windows and is able to read the .lib files to do so". Which is true, but you still need the .lib, just like MSVC does.
So the answer is, unfortunately, you cannot make Clang/LLD do this at time of writing.
I'm trying to compile an example C program that links against PortAudio for a MIPSEL OpenWRT architecture targeting the MT7688 chip.
My starting point is this 351MB Docker image that has a working MIPSEL GNU uclibc toolchain (run source env.sh to set environment variables).
I tried to cross-compile PortAudio at first, but I couldn't get it to output MIPS binaries despite configuring Makefile for --host=mips-openwrt-linux-uclibc. So I copied working libasound.so.2, libportaudio.so.2 and libportaudio.so.2 files from my MIPS device and placed them in both the source folder and /usr/lib, then passed explicit include and linker paths:
$CC I/snowboy/examples/C/portaudio/install/include -L/usr/lib -lasound demo.c -o demo -v
> /bin/ld: cannot find -lasound
collect2: error: ld returned 1 exit status
No dice. I am too dumb to understand GCC linker paths, but I've come this far. Can anyone help me to navigate this cross-compilation minefield?
I'm trying to make an "C" application for my NXP(Freescale) imx6 that Debian OS installed on it. My host machine is Ubuntu 16.04. I'm using eclipse as an IDE and I can manage to cross compile until today. I use arm-linux-gnueabihf-gcc as an compiler and arm-linux-gnueabihf-ld as an linker. I added -lasound option to my linker parameter, but still can not build the application. I get an error
arm-linux-gnueabihf-ld: cannot find -lasound
I think I don't have the libasound.so file on my Ubuntu (Host) machine and my linker couldn't link to library to my application.
I copied the libasound.so file from my ARM machine to my host machine to the /home/user/Downloads folder, but still couldn't compile.
Is there a step to use ALSA library in Cross Compilation project before build?
Here is the output of build operation
Building target: tihc_linux_application
Invoking: GCC C Linker
/usr/bin/arm-linux-gnueabihf-ld -static -L/home/user/Downloads -pthread -lasound -o "main" ./src/main.o
/usr/bin/arm-linux-gnueabihf-ld: mode armelf_linux_eabi
/usr/bin/arm-linux-gnueabihf-ld: cannot find -lasound
You ask for static link (via -static) but provide shared library so ld probably ignores it (to be sure you can run with -Wl,--verbose). One option is to cross-compile libalsa from scratch and then use resulting static lib to link your app. Another option is to search for pre-compiled gnueabihf libalsa somewhere...
I'm trying to install SDL on MinGW.
I've downloaded SDL from here (the SDL2-devel-2.0.0-mingw.tar.gz link), then copied the contents of SDL2-2.0.0/x86_64-w64-mingw32/{bin,include,lib} into the matching directories in my MinGW installation.
When I try to compile any file that contains #include ‹SDL2/SDL.h› using gcc test.c -lmingw32 -lSDL2main -lSDL2 -mwindows, GCC complains about undefined reference to WinMain#16 and undefined reference to some SDL functions.
SDL2-devel-2.0.0-mingw.tar.gz contains both 32-bit libraries (i686-w64-mingw32 directory) and 64-bit libraries (x86_64-w64-mingw32 directory).
The error was caused by using a 64-bit version of the library with a 32-bit compiler.
I am trying to use the function EC_KEY_new_by_curve_name(NID_secp256k1) present in openssl. However, when I compile, I get the following error:
undefined symbols for architecture x86_64:
"_EC_KEY_new_by_curve_name", referenced from:
CKey::CKey() in bitcoin.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I have been hinted that macos openssl is not compile with the ECC extensions. Is the problem? If so, how do I correct it?
If you're using the OpenSSL library that comes with MacOS SDK, then it should automatically have 64-bit support built in.
Looking at the first hit on Google, I'm wondering if you are just not including the correct library in your XCode project. Did you get -lcrypto into the project settings, or forget to add libCrypto.dylib to your list of libraries in the project?
On my SnowLeopard (10.6) machine, I see the symbols are defined in libCrypto:
[/usr/lib]:; nm -arch x86_64 libcrypto.0.9.8.dylib | egrep -i new_by_curve
00000000000a4ac0 T _EC_GROUP_new_by_curve_name
00000000000ab540 T _EC_KEY_new_by_curve_name