I'm trying to make print usable for an arm64 platform (bare-metal, compiler is aarch64-none-elf-gcc).
If I naively compile a simple hello_world.c program containing printf, I get errors as I expected. The errors are like below.
ckim#chan-ubuntu:~/prj/abdsn/ab21u/ab21zeus/simoob$ arm-none-elf-gcc tt.c
....aarch64-none-elf/lib/libc.a(lib_a-exit.o): in function `exit':
/tmp/dgboter/bbs/rhev-vm1--rhe6x86_64/buildbot/rhe6x86_64--aarch64-none-elf/build/src/newlib-cygwin/newlib/libc/stdlib/exit.c:64: undefined reference to `_exit'
....aarch64-none-elf/lib/libc.a(lib_a-sbrkr.o): in function `_sbrk_r':
/tmp/dgboter/bbs/rhev-vm1--rhe6x86_64/buildbot/rhe6x86_64--aarch64-none-elf/build/src/newlib-cygwin/newlib/libc/reent/sbrkr.c:51: undefined reference to `_sbrk'
....aarch64-none-elf/lib/libc.a(lib_a-writer.o): in function `_write_r':
/tmp/dgboter/bbs/rhev-vm1--rhe6x86_64/buildbot/rhe6x86_64--aarch64-none-elf/build/src/newlib-cygwin/newlib/libc/reent/writer.c:49: undefined reference to `_write'
....aarch64-none-elf/lib/libc.a(lib_a-closer.o): in function `_close_r':
/tmp/dgboter/bbs/rhev-vm1--rhe6x86_64/buildbot/rhe6x86_64--aarch64-none-elf/build/src/newlib-cygwin/newlib/libc/reent/closer.c:47: undefined reference to `_close'
....aarch64-none-elf/lib/libc.a(lib_a-lseekr.o): in function `_lseek_r':
/tmp/dgboter/bbs/rhev-vm1--rhe6x86_64/buildbot/rhe6x86_64--aarch64-none-elf/build/src/newlib-cygwin/newlib/libc/reent/lseekr.c:49: undefined reference to `_lseek'
....aarch64-none-elf/lib/libc.a(lib_a-readr.o): in function `_read_r':
/tmp/dgboter/bbs/rhev-vm1--rhe6x86_64/buildbot/rhe6x86_64--aarch64-none-elf/build/src/newlib-cygwin/newlib/libc/reent/readr.c:49: undefined reference to `_read'
....aarch64-none-elf/lib/libc.a(lib_a-fstatr.o): in function `_fstat_r':
/tmp/dgboter/bbs/rhev-vm1--rhe6x86_64/buildbot/rhe6x86_64--aarch64-none-elf/build/src/newlib-cygwin/newlib/libc/reent/fstatr.c:55: undefined reference to `_fstat'
....aarch64-none-elf/lib/libc.a(lib_a-isattyr.o): in function `_isatty_r':
/tmp/dgboter/bbs/rhev-vm1--rhe6x86_64/buildbot/rhe6x86_64--aarch64-none-elf/build/src/newlib-cygwin/newlib/libc/reent/isattyr.c:52: undefined reference to `_isatty'
collect2: error: ld returned 1 exit status
The toolchain is looking for _exit, _sbrk, _write, _close, _lseek, _lread, _fstat, _isatty which I should probably supply for the linker to link. But I guess because arm64 is being widely used, there should be some codes I can just reference/download and fix a little for our UART IP and use. Can anyone give me some direction?
In the past, someone in our team seem to have borrowed linux code and separate printf which uses our uart IP (using sparc architecture). I'm not sure if I should do the similar thing for this case too.
Related
I have problem with building my C++ project using CLion, MINGw64.
So this is the problem I cannot handle with ._.
Everything works on Linux but on Win10 I have this log:
libBiblioteka.a(Rent.cpp.obj): In function `boost::uuids::detail::random_provider_base::random_provider_base()':
C:/msys64/mingw64/include/boost/uuid/detail/random_provider_bcrypt.ipp:40: undefined reference to `BCryptOpenAlgorithmProvider'
libBiblioteka.a(Rent.cpp.obj): In function `boost::uuids::detail::random_provider_base::get_random_bytes(void*, unsigned long long)':
C:/msys64/mingw64/include/boost/uuid/detail/random_provider_bcrypt.ipp:76: undefined reference to `BCryptGenRandom'
libBiblioteka.a(Rent.cpp.obj): In function `boost::uuids::detail::random_provider_base::destroy()':
C:/msys64/mingw64/include/boost/uuid/detail/random_provider_bcrypt.ipp:93: undefined reference to `BCryptCloseAlgorithmProvider'
collect2.exe: error: ld returned 1 exit status
I have read these references are unavaiable on win10. But there is an question:
Is there any way to workaround this?
Those are not defined in libcrypt but in libbcrypt.
Did you have the same typo in your linker flags (you should have -lbcrypt)?
I just recently built and installed the hsa branch of gcc according to the associated wiki. Everything went relatively well until I got around to making the samples, vectorCopy and matrixMultiply. Here is the error output I got for matrixMultiply when running the make command (again, following the recommendations of the wiki):
/hsailgcc/lib64/libgomp.so: undefined reference to `hsa_region_get_info'
/hsailgcc/lib64/libgomp.so: undefined reference to `hsa_init'
/hsailgcc/lib64/libgomp.so: undefined reference to `hsa_signal_create'
/hsailgcc/lib64/libgomp.so: undefined reference to `hsa_agent_iterate_regions'
/hsailgcc/lib64/libgomp.so: undefined reference to `hsa_ext_program_create'
/hsailgcc/lib64/libgomp.so: undefined reference to `hsa_signal_store_relaxed'
/hsailgcc/lib64/libgomp.so: undefined reference to `hsa_executable_get_symbol'
/hsailgcc/lib64/libgomp.so: undefined reference to `hsa_ext_program_add_module'
/hsailgcc/lib64/libgomp.so: undefined reference to `hsa_signal_wait_acquire'
/hsailgcc/lib64/libgomp.so: undefined reference to `hsa_ext_program_destroy'
/hsailgcc/lib64/libgomp.so: undefined reference to `hsa_memory_allocate'
/hsailgcc/lib64/libgomp.so: undefined reference to `hsa_status_string'
/hsailgcc/lib64/libgomp.so: undefined reference to `hsa_iterate_agents'
/hsailgcc/lib64/libgomp.so: undefined reference to `hsa_ext_program_finalize'
/hsailgcc/lib64/libgomp.so: undefined reference to `hsa_executable_create'
/hsailgcc/lib64/libgomp.so: undefined reference to `hsa_agent_get_info'
/hsailgcc/lib64/libgomp.so: undefined reference to `hsa_queue_create'
/hsailgcc/lib64/libgomp.so: undefined reference to `hsa_executable_freeze'
/hsailgcc/lib64/libgomp.so: undefined reference to `hsa_queue_add_write_index_relaxed'
/hsailgcc/lib64/libgomp.so: undefined reference to `hsa_executable_symbol_get_info'
/hsailgcc/lib64/libgomp.so: undefined reference to `hsa_executable_load_code_object'
I am using Lubuntu 15.04 with the standard kernel (3.19). I am using slightly old driver and runtime components that correspond to HSA 1.0 Provisional rather than 1.0 Final, since Okra (which is needed for HSA-OpenMP-GCC) is not yet up-to-date and can not be used with the latest drivers and firmware. I have "sanity checked" the runtime and Okra, and both tests (vector_copy and Squares, respectively) function properly. I am also able to use aparapi-lambda successfully with the same setup.
The hardware is an A10-7700k on an Asus A88x-Pro motherboard with 16Gb of RAM.
So, does anyone know why I am getting these errors? I am under the suspicion that the GCC hsa branch has been updated to follow the 1.0 Final specification which is not yet compatible with Okra, which would prevent anyone from actually being able to use the compiler until someone finally updates Okra. But, I can't be too sure about that.
edit: Here is the new makefile:
GCCHSAIL=$(GCC_HSA)/bin/gcc
LDFLAGS=-lhsa-runtime64 -lhsa-runtime-ext64 -lhsakmt -L $(GCC_HSA)/lib64 -L ~/HSA-Runtime-AMD-master/lib -L opt/hsa/lib -L ~/libhsakmt/build/lnx64a -Wl,-rpath,$(GCC_HSA)/lib64
CFLAGS=-lm -fopenmp -Wall -O3
all : matmul
clean :
rm -rf *.o matmul test.output
# GCC Specifics
matmul.o : matmul.c
$(GCCHSAIL) -c $(CFLAGS) $<
matmul : matmul.o
$(GCCHSAIL) matmul.o $(CFLAGS) -o $# $(LDFLAGS)
The old makefile had no switches making reference to required .so files. With the new makefile, now I get the following errors:
/hsailgcc/lib64/libgomp.so: undefined reference to `hsa_ext_program_add_module'
/hsailgcc/lib64/libgomp.so: undefined reference to `hsa_executable_symbol_get_info'
/hsailgcc/lib64/libgomp.so: undefined reference to `hsa_executable_load_code_object'
/hsailgcc/lib64/libgomp.so: undefined reference to `hsa_executable_freeze'
/hsailgcc/lib64/libgomp.so: undefined reference to `hsa_executable_create'
/hsailgcc/lib64/libgomp.so: undefined reference to `hsa_executable_get_symbol'
/hsailgcc/lib64/libgomp.so: undefined reference to `hsa_ext_program_finalize'
There are fewer errors now, though, for whatever reason, 7 of them persist.
edit edit: Problem solved. The GCC hsa branch has moved on to support HSA 1.0F and no longer depends on Okra. That means that the old driver components and old runtime I used to maintain Okra compatibility are incompatible with the present build of GCC hsa. That should be simple enough to fix. Thanks for all the help with compiler switches.
I'm currently trying to compile suricata (http://suricata-ids.org/) with luajit support on my arch linux distribution with these commands:
./configure --enable-luajit --with-libpcap-includes=/usr/local/pfring/include \
--with-libpcap-libraries=/usr/local/pfring/lib --with-libnss-libraries=/usr/lib \
--with-libnss-includes=/usr/include/nss/ --with-libnspr-libraries=/usr/lib \
--with-libnspr-includes=/usr/include/nspr \
--with-libluajit-includes=/usr/local/include/luajit-2.0/ \
--with-libluajit-libraries=/usr/lib/
then:
make
but I get the following errors when I make the project:
detect-luajit.o: In function `LuaDumpStack':
detect-luajit.c:(.text+0x46e): undefined reference to `lua_tonumberx'
detect-luajit.o: In function `DetectLuajitMatchBuffer':
detect-luajit.c:(.text+0x5d6): undefined reference to `lua_getglobal'
detect-luajit.c:(.text+0x6b9): undefined reference to `lua_pcallk'
detect-luajit.c:(.text+0x7d5): undefined reference to `lua_tonumberx'
detect-luajit.o: In function `DetectLuajitMatch':
detect-luajit.c:(.text+0xaac): undefined reference to `lua_getglobal'
detect-luajit.c:(.text+0xde4): undefined reference to `lua_pcallk'
detect-luajit.c:(.text+0xf00): undefined reference to `lua_tonumberx'
detect-luajit.o: In function `DetectLuajitThreadInit':
detect-luajit.c:(.text+0x1864): undefined reference to `lua_pcallk'
detect-luajit.o: In function `DetectLuaSetupPrime':
detect-luajit.c:(.text+0x1fe7): undefined reference to `lua_pcallk'
detect-luajit.c:(.text+0x2167): undefined reference to `lua_getglobal'
detect-luajit.c:(.text+0x24bf): undefined reference to `lua_pcallk'
collect2: error: ld returned 1 exit status
make[2]: *** [suricata] Error 1
I first though it was an issue coming from the lua version. So I tried to install both the lua 5.1.5 and 5.2.2, remaking the library and symbolic links as well, and nothing worked.
Thanks for your help
In Debian and Ubuntu, the library files are installed into /usr/lib/x86_64-linux-gnu/. If arch does the same, your configure line should include: --with-libluajit-libraries=/usr/lib/x86_64-linux-gnu/
I've spent quite a bit of time trying to get an expat based sample program to compile.
I was receiving the following error message when I tried to compile
gcc -Wall -lexpat line.c -o blah
line.c: In function ‘main’:
line.c:99:8: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘XML_Size’ [-Wformat]
/tmp/ccUa3vfD.o: In function `printcurrent':
line.c:(.text+0x42): undefined reference to `XML_SetDefaultHandler'
line.c:(.text+0x4d): undefined reference to `XML_DefaultCurrent'
line.c:(.text+0x60): undefined reference to `XML_SetDefaultHandler'
/tmp/ccUa3vfD.o: In function `main':
line.c:(.text+0x162): undefined reference to `XML_ParserCreate'
line.c:(.text+0x1ad): undefined reference to `XML_UseParserAsHandlerArg'
line.c:(.text+0x1c9): undefined reference to `XML_SetElementHandler'
line.c:(.text+0x1dd): undefined reference to `XML_SetCharacterDataHandler'
line.c:(.text+0x1f1): undefined reference to `XML_SetProcessingInstructionHandler'
line.c:(.text+0x2b2): undefined reference to `XML_Parse'
line.c:(.text+0x2c2): undefined reference to `XML_GetErrorCode'
line.c:(.text+0x2ca): undefined reference to `XML_ErrorString'
line.c:(.text+0x2d8): undefined reference to `XML_GetCurrentLineNumber'
collect2: ld returned 1 exit status
I had already run the following commands:
sudo apt-get install expat libexpat1 libexpat1-dev libxmltok1-dev
So I messed around for ages, trying to get the error message to go away so I could compile this (simple) little program, but to no avail.
Eventually, out of sheer randomness, I decided to switch to a Virtual Terminal.
I ran exactly the same command, this time it worked without a problem.
Can anyone tell me why this is? Is there something I need to run in order to refresh the library paths?
The linker line (i.e. the flags you give with -l and your input file names) are order-dependent. Libraries are only used to define functions used on their left side, but not on their right. Use:
gcc -Wall line.c -lexpat -o blah
See the question library is linked but reference is undefined for more information.
Instructions in the blinky.zip, gcc-section, Teensy++ v.2. Makefile and blinky.c are in the zip. I modified the blinky.c by defining F_CPU at the start because not using Makefile, please, see below. So why do I get the errs and how can I compile the C-files for at90usb1286 chip?
$ avr-gcc -mmcu=atmega88 blinky.c
In file included from blinky.c:28:
/usr/local/lib/gcc/avr/4.2.2/../../../../avr/include/util/delay.h:90:3: warning: #warning "Compiler optimizations disabled; functions from <util/delay.h> won't work as designed"
/tmp//ccB66ecl.o: In function `main':
blinky.c:(.text+0x3e): undefined reference to `usb_init'
/tmp//ccB66ecl.o: In function `morse_character':
blinky.c:(.text+0x24c): undefined reference to `print_P'
blinky.c:(.text+0x36e): undefined reference to `print_P'
blinky.c:(.text+0x378): undefined reference to `usb_debug_putchar'
blinky.c:(.text+0x37e): undefined reference to `print_P'
blinky.c:(.text+0x386): undefined reference to `print_P'
blinky.c:(.text+0x390): undefined reference to `usb_debug_putchar'
blinky.c:(.text+0x394): undefined reference to `usb_debug_putchar'
blinky.c:(.text+0x416): undefined reference to `print_P'
blinky.c:(.text+0x4fa): undefined reference to `print_P'
blinky.c:(.text+0x6f8): undefined reference to `print_P'
/tmp//ccB66ecl.o: In function `morse_P':
blinky.c:(.text+0x834): undefined reference to `print_P'
Those are link errors. You could do a compile only (notice that I added the -c flag):
avr-gcc -c -mmcu=atmega88 blinky.c
You would then have to link that with your other objects to create a binary.
Alternately, you could provide all the source files in a single command line and the compiler will compile and link them:
avr-gcc -mmcu=atmega88 blinky.c print.c usb_debug_only.c