I am trying to convert UART loopback program to corresponding hex code. The command
riscv32-unknown-elf-gcc test.c -march=rv32im
riscv32-unknown-elf-gcc -o test test.c
both the command giving error
test.c:2:10: fatal error: rt/rt_api.h: No such file or directory
#include <rt/rt_api.h>
^~~~~~~~~~~~~
compilation terminated.
what is the exact command for compiling the c code with APIs, I am using Pulppissimo toolchain..
my program is
https://github.com/pulp-platform/pulp-rt-examples/tree/master/periph/uart/loopback
You have this error because rt/rt_api.h is not present in your riscv gcc search path.
To see the folders present in search path you can add -v option to your command or use:
riscv32-unknown-elf-cpp -v /dev/null /dev/null
What you can do is find the location of rt/rt_api.h and giving the path you find to gcc. Your command will be:
riscv32-unknown-elf-gcc -o test test.c -Ipath
Related
I am trying to build at the command prompt the following:
g++ -c ../../TRUNK/StringUtl.cpp -o StringUtl.o // ok
g++ -c ../../TRUNK/CircularBuf.cpp -o CircularBuf.o // ok
g++ -c ../../TRUNK/UartComm.cpp -o UartComm.o // fatal error: CircularBuf.h: No such file or directory THE header to his cpp file has #include "CircularBuf.h"
UartComm.h: contents at the top of file
//---------------------------------------------------------------------------------------
// General inclusions
//---------------------------------------------------------------------------------------
#include <stdio.h>
#include "CircularBufClass.h"
This error is beacuse g++ is not able to find the header files. You would need to provide path of your header files using -I<Path> option.
Eg:
g++ -Iyourheaderfilepath/ -c ../../TRUNK/UartComm.cpp -o UartComm.o
I am trying to build a very simple Makefile, that intends to use a homemade library (libf904QC.a) made of Fortran modules. The library is in /usr/local/lib64 whereas the corresponding .mod files are in /usr/local/include/f904QC
Here is the Makefile
# Makefile
NAME=NPManip
FFLAGS= -ffpe-trap=overflow -c -O3
LFLAGS=
PATH2LIB=/usr/local/lib64/
INCLUDEDIR=/usr/local/include/f904QC/
#
LIB=-L$(PATH2LIB) -I$(INCLUDEDIR) -lf904QC.a
OBJS = \
tools_NPManip.o\
NPManip.o
%.o: %.f90
gfortran $(LIB) $(FFLAGS) $*.f90
NPM: $(OBJS)
gfortran $(LFLAGS) $(OBJS) $(LIB) -o $(NAME)
clean:
#if test -e $$HOME/bin/$(NAME); then \
rm $$HOME/bin/$(NAME); \
fi
rm *.o *.mod
mrproper: clean
rm $(NAME)
install:
ln -s $(shell pwd)/$(NAME) $$HOME/bin/.
I get the following error message :
gfortran tools_NPManip.o NPManip.o -L/usr/local/lib64/ -I/usr/local/include/f904QC/ -lf904QC.a -o NPManip
/usr/lib64/gcc/x86_64-suse-linux/4.7/../../../../x86_64-suse-linux/bin/ld: cannot find -lf904QC.a
collect2: error: ld returned 1 exit status
make: * [NPM] Erreur 1
Where is the mistake? It is not obvious to me since libf904QC.o is actually located in /usr/local/lib64, which is defined by the -L option.
Thnak you for your help
You should specify either the full path to the library /usr/local/lib64/libf904QC.a or alternatively -L/usr/local/lib64 -lf90QC, without the .a in that case. From man ld:
-l namespec
--library=namespec
Add the archive or object file specified by namespec to the list of files to link. This option may be used any number of
times. If namespec is of the form :filename, ld will search the library path for a file called filename, otherwise it
will search the library path for a file called libnamespec.a.
-L searchdir
--library-path=searchdir
Add path searchdir to the list of paths that ld will search for archive libraries and ld control scripts. You may use
this option any number of times. The directories are searched in the order in which they are specified on the command
line. Directories specified on the command line are searched before the default directories. All -L options apply to
all -l options, regardless of the order in which the options appear. -L options do not affect how ld searches for a
linker script unless -T option is specified.
I am using MinGW64 (Windows 7) without MSYS and I have the following problem:
I have one dll, written in C99, which has to have the .mexw64 suffix so it can be used by Matlab. I would like to be able to link this dll form another dll (mexw64) dynamically but gcc won't allow me to link directly. I cannot do static linking, because both dlls have many functions of the same name which can be hidden by not exporting their symbols when creating the shared library.
So far, I have tried:
To create a symbolic link (with correct suffix and preffix) using mklink. This works, but I was not able to run mklink from the makefile. Maybe it is due to the fact I am not using MSYS which could have ln -s (I havent checked).
To do the copy of the first dll and correcting the suffix and prefix. This worked better than I expected, because on runtime the second dll actually uses the original .mexw64 and not the dll copy. I guess it is just because the .mexw64 is found first, but why is that .mexw64 searched in the first place? How the system know it is actually a dll?
My question is, is this correct/safe enough? Are there any other options?
Thanks for comments.
You should build a proper implib, either as a linker output or from a .def.
Linker:
$ gcc -shared -o testimpl.mexw64 testimpl.c -Wl,--out-implib,libtestimpl.a
$ dlltool -I libtestimpl.a
testimpl.mexw64
Or create a .def file, specifying an explicit LIBRARY:
$ cat testimpl.def
LIBRARY testimpl.mexw64
EXPORTS
test #1
$ dlltool -d testimpl.def -l libtestimpl.a
$ dlltool -I libtestimpl.a
testimpl.mexw64
And finally, link stuff:
$ gcc -o test.exe test.c libtestimpl.a
# or
$ gcc -o test.exe test.c -L. -ltestimpl
$ grep testimpl.mexw64 test.exe
Binary file test.exe matches
I am trying to learn and use Elfreader by compiling a simple hello world program to a elf file as-
gcc -o test test.c
The file compiles correctly and runs perfect.
But when I try to run ReadElf on it by
readelf -h test
it returns
readelf: Error: Not and ELF file - it has the wrong magic bytes at the start
What do you think I am doing wrong, or is there a problem with my linker script?
Let me know if you need any additional info from me.
You can check file format type follow as :
$ objdump -t hello.exe
hello.exe: file format pei-i386
Maybe I guess your file is not elf format.
in the error log:
CLSQL is doing:
gcc -I /usr/local/include/mysql -I /usr/include/mysql -I /sw/include/mysql -I /opt/local/include/mysql -I /usr/local/mysql/include -fPIC -c clsql_mysql.c -o clsql_mysql.o
and gets error:
clsql_mysql.c:34:19: mysql.h: No such file or directory
and a bunch of C errors because it doesn't include a header.
I want it to do:
gcc -I /usr/local/include/mysql -I /usr/include/mysql -I /sw/include/mysql -I /opt/local/include/mysql -I /usr/local/mysql/include <b>-I /usr/local/mysql/include/mysql</b> -fPIC -c clsql_mysql.c -o clsql_mysql.o
I tried running: (clsql:push-library-path #P"/usr/local/mysql/include/mysql/") already. Didn't work.
HALP!
check that file exists and no permissions problem by inserting #include with full name at the beginning of clsql_mysql.c file:
#include "/usr/local/mysql/include/mysql/mysql.h"
if compiles well - undo changes and resolve path provided by -I parameter
if doesn't compile and says "file does'nt exist" - check that file exists and no permission problems
I'm not familiar with CLSQL specifically, but if it uses cffi-grovel to generate that command, then prior to loading it you should try adding your "-I/usr/local/mysql/include/mysql/" to the cffi-grovel::*cc-flags* list. You could also add it in the asd file, as the grovel-file asdf component takes an optional cc-flags argument.