Skip to contentSkip to conversation

libstdc++ DSO missing

Buildroot Alex 4 participants 5 messages Sep 9, 2022 – Sep 17, 2022

lore
Share & tools
lore

Alex

author
#0 lore raw

Hi,

I intergrated my application to buildroot. Complie is successfull by when linking I get errors:

x86_64-buildroot-linux-gnu/sysroot/usr/lib64/libstdc++.so.6: error adding symbols: DSO missing from command line

Are libraries missing from buildroot environment?

Additional I get warnings that some .so files not found, but they are available in output/build/<Tool>/lib

But I included this path by $(@D)/../<Tool>/lib

What is missing in build command?
Any ideas what is missing or what to do to handle the DSO missing error???

Thanks!

King regards,

Alex

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#1 lore raw
Quoted 7 lines · Alex

Hi,

I intergrated my application to buildroot. Complie is successfull by when linking I get errors:

x86_64-buildroot-linux-gnu/sysroot/usr/lib64/libstdc++.so.6: error adding symbols: DSO missing from command line

This error means that:
- the linker found a library with a DT_NEEDED dependency on libstdc++.so.6
- the linker found libstdc++.so.6
- the linker is missing symbols
- the linker found the missing symbols in libstdc++.so.6
- but the linker command line does not include libstdc++.so.6
- so the linker is not sure if the user actually intended to link with libstdc++.so.6.
- so it refuses to link.

Since libstdc++.so.6 is the C++ runtime library, this either mean that:
- you are linking a C++ program with ld or gcc instead of g++
- you are linking a C program with a C++ library that requires libstdc++.so.6, in this case you may need -lstdc++ on the linker command line.

Quoted 1 line

Are libraries missing from buildroot environment?

No, only the linker command line is incorrect.

Quoted 2 lines

Additional I get warnings that some .so files not found, but they are available in output/build/<Tool>/lib

The compiler will only search libraries in output/staging/lib or output/staging/usr/lib.
The package for <Tool> should install the libraries there, so that other programs can link with them. This is done by putting

<TOOL>_INSTALL_STAGING = YES

in its .mk file. If <Tool> is a generic-package (and not a autotools/meson/cmake package), then you also need to manually explain how to install libraries to $(STAGING_DIR)/lib:

https://nightly.buildroot.org/manual.html#_infrastructure_for_packages_with_specific_build_systems

Quoted 1 line

But I included this path by $(@D)/../<Tool>/lib

While it may work, this is a kludge.
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

author
#2 lore raw

Thank you for your detailed explanation.

Quoted 20 lines · Alex
Quoted 7 lines

Hi,

I intergrated my application to buildroot. Complie is successfull by when linking I get errors:

x86_64-buildroot-linux-gnu/sysroot/usr/lib64/libstdc++.so.6: error adding symbols: DSO missing from command line

This error means that:
- the linker found a library with a DT_NEEDED dependency on libstdc++.so.6
- the linker found libstdc++.so.6
- the linker is missing symbols
- the linker found the missing symbols in libstdc++.so.6
- but the linker command line does not include libstdc++.so.6
- so the linker is not sure if the user actually intended to link with libstdc++.so.6.
- so it refuses to link.

Quoted 2 lines

Since libstdc++.so.6 is the C++ runtime library, this either mean that:
- you are linking a C++ program with ld or gcc instead of g++

Yap, outside of buildroot, linking calls the g++ but when linking inside buildroot,  calls the x86_64-buildroot-linux-gnu-ld, because $(LD) in the makefile is set to x86_64-buildroot-linux-gnu-ld within buildroot.

Inside the package .mk file of the BUILD_CMDS calls make:

$(MAKE) $(TARGET_CONFIGURE_OPTS)  -C $(@D)

So (a kludge to test), i replaced in the Makefile
$(LD)
by
$(HOST_DIR)/bin/x86_64-linux-g++
Now linking is successfull...
Is there a more "elegant" way to do this...? Not so a kludge like that, mean setting this within the mk file before calling the projekt make... And how to specifey $(CC) also to g++??

Quoted 10 lines

- you are linking a C program with a C++ library that requires libstdc++.so.6, in this case you may need -lstdc++ on the linker command line.

Quoted 1 line

Are libraries missing from buildroot environment?

No, only the linker command line is incorrect.

Quoted 2 lines

Additional I get warnings that some .so files not found, but they are available in output/build/<Tool>/lib

Quoted 6 lines

The compiler will only search libraries in output/staging/lib or output/staging/usr/lib.
The package for <Tool> should install the libraries there, so that other programs can link with them. This is done by putting

<TOOL>_INSTALL_STAGING = YES

in its .mk file.  If <Tool> is a generic-package (and not a autotools/meson/cmake package), then you also need to manually explain how to install libraries to $(STAGING_DIR)/lib:

Indeed I forgot one of the .so to be  installed to staging. After adding this and append to the $(MAKE) call the LD_LIBRARY_PATH="$(@D)../<Tool>/lib" compile and linking is successfull.

Quoted 7 lines

https://nightly.buildroot.org/manual.html#_infrastructure_for_packages_with_specific_build_systems

Quoted 1 line

But I included this path by $(@D)/../<Tool>/lib

While it may work, this is a kludge.

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#3 lore raw
Quoted 21 lines · On Sun, 11 Sep 2022 11:41:51 +0200 Alex <[email protected]> wrote:

Thank you for your detailed explanation.

Quoted 20 lines · Alex
Quoted 7 lines

Hi,

I intergrated my application to buildroot. Complie is successfull by when linking I get errors:

x86_64-buildroot-linux-gnu/sysroot/usr/lib64/libstdc++.so.6: error adding symbols: DSO missing from command line

This error means that:
- the linker found a library with a DT_NEEDED dependency on libstdc++.so.6
- the linker found libstdc++.so.6
- the linker is missing symbols
- the linker found the missing symbols in libstdc++.so.6
- but the linker command line does not include libstdc++.so.6
- so the linker is not sure if the user actually intended to link with libstdc++.so.6.
- so it refuses to link.

Quoted 8 lines
Quoted 3 lines

Since libstdc++.so.6 is the C++ runtime library, this either mean that:
- you are linking a C++ program with ld or gcc instead of g++

Yap, outside of buildroot, linking calls the g++ but when linking inside buildroot,  calls the x86_64-buildroot-linux-gnu-ld, because $(LD) in the makefile is set to x86_64-buildroot-linux-gnu-ld within buildroot.

I don't think it's ever been normal usage to use $(LD) when trying to link anything involving dynamic linkage. As far as I'm aware, your Makefile shouldn't be using $(LD) if you are linking dynamically. As you are linking a C++ application, the link command should be using $(CXX) (make doesn't seem to have a built in rule for linking C++, but it's what I have always used and not had this sort of problem). $(CXX) will be pointing to the correct g++, which will then call out to the correct ld as required, with the correct options.

If you make this change to your Makefile you shouldn't need your kludge.

Richard

Quoted 32 lines

Inside the package .mk file of the BUILD_CMDS calls make:

$(MAKE) $(TARGET_CONFIGURE_OPTS)  -C $(@D)

So (a kludge to test), i replaced in the Makefile
$(LD)
by
$(HOST_DIR)/bin/x86_64-linux-g++
Now linking is successfull...
Is there a more "elegant" way to do this...? Not so a kludge like that, mean setting this within the mk file before calling the projekt make... And how to specifey $(CC) also to g++??

Quoted 18 lines

- you are linking a C program with a C++ library that requires libstdc++.so.6, in this case you may need -lstdc++ on the linker command line.

Quoted 1 line

Are libraries missing from buildroot environment?

No, only the linker command line is incorrect.

Quoted 2 lines

Additional I get warnings that some .so files not found, but they are available in output/build/<Tool>/lib

The compiler will only search libraries in output/staging/lib or output/staging/usr/lib.
The package for <Tool> should install the libraries there, so that other programs can link with them. This is done by putting

<TOOL>_INSTALL_STAGING = YES

Quoted 16 lines
Quoted 3 lines

in its .mk file.  If <Tool> is a generic-package (and not a autotools/meson/cmake package), then you also need to manually explain how to install libraries to $(STAGING_DIR)/lib:

Indeed I forgot one of the .so to be  installed to staging. After adding this and append to the $(MAKE) call the LD_LIBRARY_PATH="$(@D)../<Tool>/lib" compile and linking is successfull.

Quoted 7 lines

https://nightly.buildroot.org/manual.html#_infrastructure_for_packages_with_specific_build_systems

Quoted 1 line

But I included this path by $(@D)/../<Tool>/lib

While it may work, this is a kludge.

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#4 lore raw

Hello!

Quoted 1 line · Richard Ash

make doesn't seem to have a built in rule for linking C++

It does have this builtin rule:

    %: %.cpp
        $(LINK.cpp) $^ $(LOADLIBES) $(LDLIBS) -o $@

with these defaults:

    LINK.cpp = $(LINK.cc)
    LINK.cc = $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)
    CXX = g++

However, the builtin rule for linking object files uses $(CC) (which defaults to cc), irrespective of whether these object files come from C or from C++.

Regards,

Edgar.
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot