Hi all,
I have managed to compile a custom C library (libscc-sec) as part of the l4 packages. Now I would like to use it in the bootstrap package (make a call to a function in the library). I did the following:
a. Added the library as a requirement in pkg/bootstrap/Control
requires: drivers_uart drivers_of libc l4util cxx_io libscc-sec
b. Modified the pkg/bootstrap/server/src/Make.rules so that it also looks for libscc-sec by:
L4_LIBS = -static -nostdlib $(DRV_LIBS) -lcxx_base -lcxx_io -llibscc-sec
But on compiling, I get an error that says that -llibscc-sec not found
The package is getting compiled and I can see the library libscc-sec.a in the build folder. What am I missing?
Thanks, ramya
On 02.09.2014 11:37, Masti Ramya Jayaram wrote:
b. Modified the pkg/bootstrap/server/src/Make.rules so that it also looks for libscc-sec by:
L4_LIBS = -static -nostdlib $(DRV_LIBS) -lcxx_base -lcxx_io -llibscc-sec
But on compiling, I get an error that says that -llibscc-sec not found
The package is getting compiled and I can see the library libscc-sec.a in the build folder. What am I missing?
Use '-lscc-sec' instead of '-llibscc-sec' in 'L4_LIBS' ;-)
Quoting from the manpage of ld: | -l 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.
Regards, Jan
Sorry about the multiple emails. I managed to get past the library not found error - it was a matter of nomenclature.
However, now I am trying to call a function in the library through an included header file (which is part of the library) and it fails (undefined reference).
My header file: init.h
#define BLAH 10 int abcd = 5; int hello();
Code in my init.c
int hello(){ printf("Hello"); }
My C++ code:
extern "C"{ #include <l4/libscc-sec/init.h> }
int main(){ printf("Vars from lib %x, %x", BLAH. abcd) hello(); }
The program fails to compile with the calls to the function hello. If I remove hello, it compiles.
I made sure that I am indeed using the extern "C" directive. I also tried putting the function declaration in here instead of the header file itself but it does not help.
Thanks, ramya ________________________________________ From: l4-hackers [l4-hackers-bounces@os.inf.tu-dresden.de] on behalf of Masti Ramya Jayaram [rmasti@inf.ethz.ch] Sent: 02 September 2014 11:37 To: l4-hackers@os.inf.tu-dresden.de Subject: Adding a custom library to l4/pkg/bootstrap
Hi all,
I have managed to compile a custom C library (libscc-sec) as part of the l4 packages. Now I would like to use it in the bootstrap package (make a call to a function in the library). I did the following:
a. Added the library as a requirement in pkg/bootstrap/Control
requires: drivers_uart drivers_of libc l4util cxx_io libscc-sec
b. Modified the pkg/bootstrap/server/src/Make.rules so that it also looks for libscc-sec by:
L4_LIBS = -static -nostdlib $(DRV_LIBS) -lcxx_base -lcxx_io -llibscc-sec
But on compiling, I get an error that says that -llibscc-sec not found
The package is getting compiled and I can see the library libscc-sec.a in the build folder. What am I missing?
Thanks, ramya
_______________________________________________ l4-hackers mailing list l4-hackers@os.inf.tu-dresden.de http://os.inf.tu-dresden.de/mailman/listinfo/l4-hackers
On 02.09.2014 13:32, Masti Ramya Jayaram wrote:
However, now I am trying to call a function in the library through an included header file (which is part of the library) and it fails (undefined reference).
Could you give the *exact* error message? BTW, this is something you should always do if you want people to be able to help you ;-)
My guess at this point would be that the undefined reference is not your 'hello' function but 'printf'...
I made sure that I am indeed using the extern "C" directive. I also tried putting the function declaration in here instead of the header file itself but it does not help.
The function declaration is not the problem here. If it was, the compiler would give you an error along the lines of "'hello' was not declared in this scope".
Regards, Jan
Hey Jan,
Sorry for underspecifying it. Here are the details.
I have a library called scc-sec under the l4/pkg directory. It has one file:
a. init.c that contains
void hello(){ printf("hello"); }
I compile this as a library and I can see the scc-sec.so and scc-sec.a in the l4/build/pkg/scc-sec directory
Now in l4/pkg/bootstrap:
a. Control file requires: (added) scc-sec
b. Make.rules: -lscc-sec
c. startup.cc
I declare the function as:
extern "C" { void hello(); }
and somewhere in startup() function, I call it
hello();
On trying to compile this, I get (exact error as it is compiled)
in path_to-startup.cc: undefined reference to function "hello()"
I do not think it is the printf because it explicitly gives me an undefined reference to hello :)
Thanks in advance for helping with this, Ramya
________________________________________ From: l4-hackers [l4-hackers-bounces@os.inf.tu-dresden.de] on behalf of Jan Bierbaum [jan.bierbaum@os.inf.tu-dresden.de] Sent: 02 September 2014 21:56 To: l4-hackers@os.inf.tu-dresden.de Subject: Re: Adding a custom library to l4/pkg/bootstrap
On 02.09.2014 13:32, Masti Ramya Jayaram wrote:
However, now I am trying to call a function in the library through an included header file (which is part of the library) and it fails (undefined reference).
Could you give the *exact* error message? BTW, this is something you should always do if you want people to be able to help you ;-)
My guess at this point would be that the undefined reference is not your 'hello' function but 'printf'...
I made sure that I am indeed using the extern "C" directive. I also tried putting the function declaration in here instead of the header file itself but it does not help.
The function declaration is not the problem here. If it was, the compiler would give you an error along the lines of "'hello' was not declared in this scope".
Regards, Jan
_______________________________________________ l4-hackers mailing list l4-hackers@os.inf.tu-dresden.de http://os.inf.tu-dresden.de/mailman/listinfo/l4-hackers
On 09/03/2014 09:51 AM, Masti Ramya Jayaram wrote:
Hey Jan,
Sorry for underspecifying it. Here are the details.
I have a library called scc-sec under the l4/pkg directory. It has one file:
a. init.c that contains
void hello(){ printf("hello"); }
I compile this as a library and I can see the scc-sec.so and scc-sec.a in the l4/build/pkg/scc-sec directory
Now in l4/pkg/bootstrap:
a. Control file requires: (added) scc-sec
b. Make.rules: -lscc-sec
Is "-lscc-sec" the literal content of this file? That doesn't do anything.
c. startup.cc
I declare the function as:
extern "C" { void hello(); }
and somewhere in startup() function, I call it
hello();
On trying to compile this, I get (exact error as it is compiled)
in path_to-startup.cc: undefined reference to function "hello()"
I do not think it is the printf because it explicitly gives me an undefined reference to hello :)
To me this looks like you don't actually link to your scc-sec library. Does your Makefile for bootstrap include something like REQUIRES_LIBS = scc_sec ?
Martin
Hey Martin,
No I did not have the require_libs declared. I will try that.
Thanks, ramya ________________________________________ From: l4-hackers [l4-hackers-bounces@os.inf.tu-dresden.de] on behalf of Martin Küttler [martin.kuettler@gmail.com] Sent: 04 September 2014 09:27 To: l4-hackers@os.inf.tu-dresden.de Subject: Re: Adding a custom library to l4/pkg/bootstrap
On 09/03/2014 09:51 AM, Masti Ramya Jayaram wrote:
Hey Jan,
Sorry for underspecifying it. Here are the details.
I have a library called scc-sec under the l4/pkg directory. It has one file:
a. init.c that contains
void hello(){ printf("hello"); }
I compile this as a library and I can see the scc-sec.so and scc-sec.a in the l4/build/pkg/scc-sec directory
Now in l4/pkg/bootstrap:
a. Control file requires: (added) scc-sec
b. Make.rules: -lscc-sec
Is "-lscc-sec" the literal content of this file? That doesn't do anything.
c. startup.cc
I declare the function as:
extern "C" { void hello(); }
and somewhere in startup() function, I call it
hello();
On trying to compile this, I get (exact error as it is compiled)
in path_to-startup.cc: undefined reference to function "hello()"
I do not think it is the printf because it explicitly gives me an undefined reference to hello :)
To me this looks like you don't actually link to your scc-sec library. Does your Makefile for bootstrap include something like REQUIRES_LIBS = scc_sec ?
Martin
_______________________________________________ l4-hackers mailing list l4-hackers@os.inf.tu-dresden.de http://os.inf.tu-dresden.de/mailman/listinfo/l4-hackers
l4-hackers@os.inf.tu-dresden.de