*while looking at Norman's mail*: ok, thats my fault I missed the malloc/free implementation in 'mini_c', so it's just about C/C++ linkage differences.
On 03/15/2011 09:27 PM, Amadeo Cuadrado wrote: > Thanks Stefan for your answer. > > Would it be possible to statically link libc into my project? With respect to your question: of course, it's possible in general. I guess you like to use libc on top of Fiasco.OC, where ldso isn't enabled yet? Otherwise I would recommend you to use ldso instead. Please try it, by uncommenting the following two lines in 'libc/lib/mk/libc.mk': SHARED_LIB = yes LD_OPT += --version-script=$(REP_DIR)/src/lib/libc/Version.def Regards Stefan > > Amadeo > > > -----Original Message----- > From: Stefan Kalkowski [mailto:[email protected]] > Sent: Tuesday, March 15, 2011 1:16 PM > To: [email protected] > Subject: Re: Use of malloc primitives in Genode > > Hello Amadeo, > > if you really want to use stdlib's malloc and free, you'll have to link > against our 'libc'. The 'mini_c' library you've choosen doesn't provide > malloc/free. It's just a small dummy library for the png-library in our > demo-repository, that provides a few string-handling functions. > > If you only need malloc/free without additional libc functionality, > there is a simple implementation in our C++ support-library in: > > base/src/base/cxx/malloc_free.cc > > which uses the heap-allocator from Genode's base environment. To not > clash with the definition of e.g. the implementation in the 'libc' both > symbols are hidden after linking the C++ support library, so you cannot > use it directly, but it might help you as a starting point, if you don't > want to link against whole 'libc'. > > Regards > Stefan > > On 03/15/2011 08:53 PM, Amadeo Cuadrado wrote: >> Hello, >> >> >> >> When I try to build the app below in Genode, the following linking error >> happens: >> >> >> >> main.o: In function `main': >> >> .../main.cc:6: undefined reference to `malloc(unsigned int)' >> >> .../main.cc:8: undefined reference to `free(void*)' >> >> >> >> What am I missing here? Thanks! >> >> >> >> Amadeo >> >> >> >> >> >> :::::::::::::: >> >> main.cc >> >> :::::::::::::: >> >> #include <stdlib.h> >> >> >> >> #define N 10 >> >> >> >> int main(void) { >> >> int *v = (int *) malloc(N*sizeof(int)); >> >> for (int i=0; i<N; i++) v[i] = i; >> >> free(v); >> >> } >> >> :::::::::::::: >> >> target.mk >> >> :::::::::::::: >> >> TARGET = foo >> >> SRC_CC = main.cc >> >> LIBS = cxx env mini_c >> >> >> >> >> >> ------------------------------------------------------------------------------ >> Colocation vs. Managed Hosting >> A question and answer guide to determining the best fit >> for your organization - today and in the future. >> http://p.sf.net/sfu/internap-sfd2d >> >> >> >> _______________________________________________ >> Genode-main mailing list >> [email protected] >> https://lists.sourceforge.net/lists/listinfo/genode-main > -- Stefan Kalkowski Genode Labs http://www.genode-labs.com/ · http://genode.org/ Genode Labs GmbH · Amtsgericht Dresden · HRB 28424 · Sitz Dresden Geschäftsführer: Dr.-Ing. Norman Feske, Christian Helmuth ------------------------------------------------------------------------------ Colocation vs. Managed Hosting A question and answer guide to determining the best fit for your organization - today and in the future. http://p.sf.net/sfu/internap-sfd2d _______________________________________________ Genode-main mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/genode-main
