[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [microblaze-uclinux] FIXED (maybe): C++ link issues



Hi again,

Here's the only two tweaks required on a petalinux-new-app Makefile template to build a C++ binary:

 $(APP): $(APP_OBJS)
-       $(CC) $(LDFLAGS) -o $@ $(APP_OBJS) $(LDLIBS)
+       $(CXX) $(CXX_LDFLAGS) -o $@ $(APP_OBJS) $(LDLIBS) $(CXXLIBS)
 
 clean:
        -rm -f $(APP) *.elf *.gdb *.o
@@ -41,6 +41,8 @@
 %.o: %.c
        $(CC) -c $(CFLAGS) -o $@ $<
 
+%.o: %.cxx
+       $(CXX) -c $(CXXFLAGS) -o $@ $<

Basically, indicate to use the C++ compiler for the final link, using CXX_LDFLAGS and CXXLIBS, and provide a rule so Make knows how to produce .o files from .cxx sources.

This build tested in most recent PetaLinux.  No need to copy libstdc++.a into your build dir, as far as I can see.

Cheers,

John


On Thu, Jun 11, 2009 at 8:37 AM, John Williams <john.williams@xxxxxxxxxxxxx> wrote:
Hi Dan,

On Thu, Jun 11, 2009 at 8:06 AM, Dan Miller <dan@xxxxxxxxxx> wrote:
What I did, to get C++ files to link successfully, is I copied
/home/petalinux-v0.40-rc3/tools/linux-i386/microblaze-uclinux-tools/microblaze-uclinux/lib//libstdc++.a
to
$(ROOTDIR)/lib

and then everything just built!!  The trick was, to copy *only* libstdc++.a, NOT libstdc++.la
(otherwise I get a bunch of errors about non-existent paths that are in the .la file).

I'm surprised it was necessary to copy libstdc++ into place, I'll try to get a look at this today and figure out what's going on.

Now, the one thing I *don't* know is if that particular copy of the library is actually valid or not, since it was buried down in the middle of nowhere.  I confirmed that the executable does not run on the host platform, which confirms that it didn't use the host compiler/linker.  Beyond that, I'll have to wait until our Microblaze board is up and running to test further.

What's cool is that I next imported a 13-file, 5000-line application, made the same couple of changes in the petalinux-generated Makefile, and the whole thing just compiled and linked with no arguments!! 

Can I quote you on that? :)  That's why you use embedded Linux!

John


--
John Williams, PhD, B.Eng, B.IT
PetaLogix - Linux Solutions for a Reconfigurable World
w: www.petalogix.com  p: +61-7-30090663  f: +61-7-30090663



--
John Williams, PhD, B.Eng, B.IT
PetaLogix - Linux Solutions for a Reconfigurable World
w: www.petalogix.com  p: +61-7-30090663  f: +61-7-30090663