* [Qemu-devel] [Makefile] Compiling Qemu to dynamic library
@ 2015-01-07 8:36 Halsey Pian
0 siblings, 0 replies; 4+ messages in thread
From: Halsey Pian @ 2015-01-07 8:36 UTC (permalink / raw)
To: qemu-devel
[-- Attachment #1: Type: text/plain, Size: 1557 bytes --]
Dear All,
Recently, I would try to compile qemu to a so in order to call qemu internal functions in my program, I'm trying to do this by
steps,
1. Add rules in qemu-2.1.2/ rules.mak
%.so:
$(call quiet-command,rm -f $@ && $(LINKPROG) $(QEMU_INCLUDES) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) -fPIC -shared -DBUILD_DSO $(CFLAGS)
$($@-cflags) $(LDFLAGS) $(LIBS) -o $@ $^," GEN $(TARGET_DIR)$@")
2. Add target in qemu-2.1.2/Makefile
qemu-kvm-obj = vl.o blockdev.o migration.o migration-unix.o qtest.o migration-fd.o ioport.o savevm.o cpus.o
qemu-kvm-obj += net/net.o net/queue.o
qemu-kvm-obj += ui/console.o
qemu-kvm-obj += qom/object.o
qemu-kvm-obj += hw/usb/bus.o
qemu-kvm-obj += pixman/pixman/pixman-bits-image.o pixman/pixman/pixman-utils.o
qemu-kvm-obj += qapi/qapi-visit-core.o
libqemu.so : $(block-obj-y) $(util-obj-y) qemu-img.o vmstate.o qemu-file.o $(qemu-kvm-obj) vl.o qapi-event.o migration.o
blockdev.o migration-unix.o qtest.o migration-fd.o
as you know, the main entrance for final binary qemu-system-x86_64 is located in vl.c, I just want it and qemu-img.o to be included
in the so library, so it seems that there are many dependent objects above should have to be included, that would be suffering
problem to be fixed below during doing this,
There are many platform dependent source code i.e. cpus.c memory.c, how to compile them into so for specific platform? Is there some
guidance for building qemu to so? could you give help on this?
Thanks a lot!
Best Regards
Halsey Pian
[-- Attachment #2: Type: text/html, Size: 9933 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [Makefile] Compiling Qemu to dynamic library
@ 2015-01-08 4:02 Halsey Pian
2015-01-08 10:39 ` Peter Maydell
0 siblings, 1 reply; 4+ messages in thread
From: Halsey Pian @ 2015-01-08 4:02 UTC (permalink / raw)
To: qemu-devel
[-- Attachment #1: Type: text/plain, Size: 2432 bytes --]
Hi All,
During building this so library, I found that there are many functions with same name in stubs and other source file, for example,
There are two implement functions with same name slirp_pollfds_fill in slirp.c and main-loop.c.
./stubs/slirp.c:void slirp_pollfds_fill(GArray *pollfds, uint32_t *timeout)
./main-loop.c: slirp_pollfds_fill(gpollfds, &timeout);
Do you know when qemustub should be used? libqemustub.a is only used for qemu-img, qemu-nbd, qemu-io, but not for
qemu-system-x86_64(and other platform binary)?
Thanks!
Best Regards
Halsey Pian
From: Halsey Pian [mailto:halsey.pian@gmail.com]
Sent: 2015年1月7日 16:37
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [Makefile] Compiling Qemu to dynamic library
Dear All,
Recently, I would try to compile qemu to a so in order to call qemu internal functions in my program, I’m trying to do this by
steps,
1. Add rules in qemu-2.1.2/ rules.mak
%.so:
$(call quiet-command,rm -f $@ && $(LINKPROG) $(QEMU_INCLUDES) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) -fPIC -shared -DBUILD_DSO $(CFLAGS)
$($@-cflags) $(LDFLAGS) $(LIBS) -o $@ $^," GEN $(TARGET_DIR)$@")
2. Add target in qemu-2.1.2/Makefile
qemu-kvm-obj = vl.o blockdev.o migration.o migration-unix.o qtest.o migration-fd.o ioport.o savevm.o cpus.o
qemu-kvm-obj += net/net.o net/queue.o
qemu-kvm-obj += ui/console.o
qemu-kvm-obj += qom/object.o
qemu-kvm-obj += hw/usb/bus.o
qemu-kvm-obj += pixman/pixman/pixman-bits-image.o pixman/pixman/pixman-utils.o
qemu-kvm-obj += qapi/qapi-visit-core.o
libqemu.so : $(block-obj-y) $(util-obj-y) qemu-img.o vmstate.o qemu-file.o $(qemu-kvm-obj) vl.o qapi-event.o migration.o blockdev.
o migration-unix.o qtest.o migration-fd.o
as you know, the main entrance for final binary qemu-system-x86_64 is located in vl.c, I just want it and qemu-img.o to be included
in the so library, so it seems that there are many dependent objects above should have to be included, that would be suffering
problem to be fixed below during doing this,
There are many platform dependent source code i.e. cpus.c memory.c, how to compile them into so for specific platform? Is there some
guidance for building qemu to so? could you give help on this?
Thanks a lot!
Best Regards
Halsey Pian
[-- Attachment #2: Type: text/html, Size: 11636 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [Makefile] Compiling Qemu to dynamic library
2015-01-08 4:02 [Qemu-devel] [Makefile] Compiling Qemu to dynamic library Halsey Pian
@ 2015-01-08 10:39 ` Peter Maydell
0 siblings, 0 replies; 4+ messages in thread
From: Peter Maydell @ 2015-01-08 10:39 UTC (permalink / raw)
To: Halsey Pian; +Cc: QEMU Developers
On 8 January 2015 at 04:02, Halsey Pian <halsey.pian@gmail.com> wrote:
> ./stubs/slirp.c:void slirp_pollfds_fill(GArray *pollfds, uint32_t *timeout)
>
> ./main-loop.c: slirp_pollfds_fill(gpollfds, &timeout);
> Do you know when qemustub should be used? libqemustub.a is only used for
> qemu-img, qemu-nbd, qemu-io, but not for qemu-system-x86_64(and other
> platform binary)?
No, the stub library is always linked. We rely on the linker's
behaviour of only pulling a .o file out of the .a archive if
it is needed to satisfy a symbol dependency not provided by one
of the other .o files in the link. So if the program we're
building provides an implementation of the function (in this
example, if the binary links main-loop.c) then we will use
that. If the program being built doesn't provide an implementation
then we'll use the stub implementation.
-- PMM
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [Makefile] Compiling Qemu to dynamic library
@ 2015-01-12 2:18 Halsey Pian
0 siblings, 0 replies; 4+ messages in thread
From: Halsey Pian @ 2015-01-12 2:18 UTC (permalink / raw)
To: qemu-devel
[-- Attachment #1: Type: text/plain, Size: 2963 bytes --]
Hi All,
I have a workaround solution to achieve this. I could just get all the object files required by specific platform executable binary
by adding some codes in Makefile, and then compile them to the dynamic library. Sorry for reading this mail thread. Please ignore
it. Thanks!
Best Regards
Halsey Pian
From: Halsey Pian [mailto:halsey.pian@gmail.com]
Sent: 2015年1月8日 12:03
To: qemu-devel@nongnu.org
Subject: RE: [Qemu-devel] [Makefile] Compiling Qemu to dynamic library
Hi All,
During building this so library, I found that there are many functions with same name in stubs and other source file, for example,
There are two implement functions with same name slirp_pollfds_fill in slirp.c and main-loop.c.
./stubs/slirp.c:void slirp_pollfds_fill(GArray *pollfds, uint32_t *timeout)
./main-loop.c: slirp_pollfds_fill(gpollfds, &timeout);
Do you know when qemustub should be used? libqemustub.a is only used for qemu-img, qemu-nbd, qemu-io, but not for
qemu-system-x86_64(and other platform binary)?
Thanks!
Best Regards
Halsey Pian
From: Halsey Pian [mailto:halsey.pian@gmail.com]
Sent: 2015年1月7日 16:37
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [Makefile] Compiling Qemu to dynamic library
Dear All,
Recently, I would try to compile qemu to a so in order to call qemu internal functions in my program, I’m trying to do this by
steps,
1. Add rules in qemu-2.1.2/ rules.mak
%.so:
$(call quiet-command,rm -f $@ && $(LINKPROG) $(QEMU_INCLUDES) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) -fPIC -shared -DBUILD_DSO $(CFLAGS)
$($@-cflags) $(LDFLAGS) $(LIBS) -o $@ $^," GEN $(TARGET_DIR)$@")
2. Add target in qemu-2.1.2/Makefile
qemu-kvm-obj = vl.o blockdev.o migration.o migration-unix.o qtest.o migration-fd.o ioport.o savevm.o cpus.o
qemu-kvm-obj += net/net.o net/queue.o
qemu-kvm-obj += ui/console.o
qemu-kvm-obj += qom/object.o
qemu-kvm-obj += hw/usb/bus.o
qemu-kvm-obj += pixman/pixman/pixman-bits-image.o pixman/pixman/pixman-utils.o
qemu-kvm-obj += qapi/qapi-visit-core.o
libqemu.so : $(block-obj-y) $(util-obj-y) qemu-img.o vmstate.o qemu-file.o $(qemu-kvm-obj) vl.o qapi-event.o migration.o blockdev.
o migration-unix.o qtest.o migration-fd.o
as you know, the main entrance for final binary qemu-system-x86_64 is located in vl.c, I just want it and qemu-img.o to be included
in the so library, so it seems that there are many dependent objects above should have to be included, that would be suffering
problem to be fixed below during doing this,
There are many platform dependent source code i.e. cpus.c memory.c, how to compile them into so for specific platform? Is there some
guidance for building qemu to so? could you give help on this?
Thanks a lot!
Best Regards
Halsey Pian
[-- Attachment #2: Type: text/html, Size: 14394 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-01-12 2:18 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-08 4:02 [Qemu-devel] [Makefile] Compiling Qemu to dynamic library Halsey Pian
2015-01-08 10:39 ` Peter Maydell
-- strict thread matches above, loose matches on Subject: below --
2015-01-12 2:18 Halsey Pian
2015-01-07 8:36 Halsey Pian
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).